[pkg-haskell-tools] 01/03: Added honouring and checking consistency of architectures.

Sven Bartscher svenb-guest at moszumanska.debian.org
Wed Aug 19 15:47:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

svenb-guest pushed a commit to branch architectures
in repository pkg-haskell-tools.

commit f1da4e91f233d22d15fd6dcf6e850532a320b175
Author: Sven Bartscher <sven.bartscher at weltraumschlangen.de>
Date:   Wed Aug 19 11:38:45 2015 +0200

    Added honouring and checking consistency of architectures.
---
 debian/control  |  2 ++
 dht.cabal       |  1 +
 src/make-all.hs | 43 +++++++++++++++++++++++++++++++++----------
 3 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/debian/control b/debian/control
index 7f767d2..7f66e2e 100644
--- a/debian/control
+++ b/debian/control
@@ -20,6 +20,8 @@ Build-Depends: debhelper (>= 9),
  libghc-split-dev (>= 0.2),
  libghc-split-dev (<< 0.3),
  libghc-text-dev,
+ libghc-missingh-dev (>= 1.3.0.1),
+ libghc-missingh-dev (<< 1.4),
 Standards-Version: 3.9.6
 Homepage: https://wiki.debian.org/Haskell
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-haskell/pkg-haskell-tools.git
diff --git a/dht.cabal b/dht.cabal
index 24ab27d..e3af0f9 100644
--- a/dht.cabal
+++ b/dht.cabal
@@ -28,5 +28,6 @@ executable make-all
     debian == 3.87.*,
     optparse-applicative == 0.11.*,
     split == 0.2.*
+    MissingH >= 1.3.0.1 && < 1.4
   hs-source-dirs:      src
   default-language:    Haskell2010
diff --git a/src/make-all.hs b/src/make-all.hs
index 4fbbb64..64d1449 100644
--- a/src/make-all.hs
+++ b/src/make-all.hs
@@ -5,6 +5,7 @@ import Control.Applicative hiding (many)
 import qualified Data.Text as T
 import Data.List
 import Data.List.Split
+import Data.String.Utils (strip)
 import Data.Maybe
 import Data.Monoid
 import Control.Monad
@@ -159,8 +160,8 @@ removeEpoch s | ':' `elem` s = tail $ dropWhile (/= ':') s
               | otherwise    = s
 
 
-changesFileName s v = s ++ "_" ++ v ++ "_amd64.changes"
-logFileName s v = s ++ "_" ++ v ++ "_amd64.build"
+changesFileName s v a = s ++ "_" ++ v ++ "_" ++ a ++ ".changes"
+logFileName s v a = s ++ "_" ++ v ++ "_" ++ a ++ ".build"
 sourceFileName s v = s ++ "_" ++ v ++ ".dsc"
 
 binaryPackagesOfSource :: String -> Action [(String, String)]
@@ -236,6 +237,13 @@ newtype GetExcludedSources = GetExcludedSources () deriving (Show,Typeable,Eq,Ha
 newtype GetDebBuiltBy = GetDebBuiltBy String  deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
 newtype GetBinToDeb = GetBinToDeb String  deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
 
+newtype Architecture = Arch String deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
+
+checkArch :: (Monad m) => String -> String -> String -> m ()
+checkArch should is full = unless (  (should `isPrefixOf` is)
+                                  || ("all"  `isPrefixOf` is)) $
+                           fail $ "Can't build this file " ++ full ++ " with schroot with architecture " ++ should
+
 manpage :: String
 manpage = unlines [ "TODO" ]
 
@@ -271,6 +279,14 @@ shakeMain conf@(Conf {..}) = do
     getExcludedSources <- addOracle $ \GetExcludedSources{} ->
         return $ excludedPackages
 
+    getArch <- addOracle $ \a -> let fix = a `asTypeOf` () in
+        fmap (Arch . strip . fromStdout) $
+             cmd (Stdin "dpkg --print-architecture; exit")
+                     (Cwd "/") -- To avoid warings about the current directory not existing in the schroot.
+                     [ "schroot"
+                     , "-c", schrootName
+                     ]
+
     targetDir </> "cache/sources.txt" %> \out -> do
         sources <- getDirectoryDirs "p"
         excluded <- getExcludedSources (GetExcludedSources ())
@@ -324,12 +340,13 @@ shakeMain conf@(Conf {..}) = do
         binToDeb = getBinToDeb . GetBinToDeb
 
     targetDir </> "cache/all-changes-files.txt" %> \out -> do
+        Arch arch <- askOracle ()
         putNormal "# enumerating all changes files..."
         sources <- readFileLines $ targetDir </> "cache/sources.txt"
         versioned <- forM sources $ \s -> do
             v <- versionOfSource s
             return (s,v)
-        writeFileChanged out $ unlines $ map (uncurry changesFileName) versioned
+        writeFileChanged out $ unlines $ map (flip (uncurry changesFileName) arch) versioned
 
     targetDir </> "cache/binaries/*.txt" %> \out -> do
         let s = dropExtension $ takeFileName $ out
@@ -346,17 +363,21 @@ shakeMain conf@(Conf {..}) = do
     -- Binary packages depend on the corresponding changes file log
     targetDir </> "*.deb" %> \out -> do
         let filename = takeFileName out
-        let [_pkgname,version,_] = splitOn "_" filename
+        let [_pkgname,version,end] = splitOn "_" filename
+        Arch arch <- askOracle ()
+        checkArch arch end filename
         sourceMB <- debBuiltBy filename
         case sourceMB of
             Nothing -> fail $ "File " ++ filename ++ " not built by us."
-            Just source -> need [targetDir </> changesFileName source version]
+            Just source -> need [targetDir </> changesFileName source version arch]
 
     -- Changes files depend on the corresponding log file
     targetDir </> "*.changes" %> \out -> do
         let filename = takeFileName out
-        let [source,version,_] = splitOn "_" filename
-        let logfile = targetDir </> logFileName source version
+        let [source,version,end] = splitOn "_" filename
+        Arch arch <- askOracle ()
+        checkArch arch end filename
+        let logfile = targetDir </> logFileName source version arch
         need [logfile]
         ok <- doesFileExist out
         unless ok $ do
@@ -367,8 +388,10 @@ shakeMain conf@(Conf {..}) = do
     -- Build log depends on the corresponding source, and the dependencies
     targetDir </> "*.build" %> \out -> do
         let filename = takeFileName out
-        let [source,version,_] = splitOn "_" filename
-        let changes = changesFileName source version
+        let [source,version,end] = splitOn "_" filename
+        Arch arch <- askOracle ()
+        checkArch arch end filename
+        let changes = changesFileName source version arch
 
         ensureVersion source version
 
@@ -418,6 +441,7 @@ shakeMain conf@(Conf {..}) = do
                 ["sbuild"
                 , "-c", schrootName
                 , "-A"
+                , "--no-source"
                 , "--no-apt-update"
                 , "--dist", distribution
                 , "--chroot-setup-commands=bash " ++ fixup
@@ -444,4 +468,3 @@ shakeMain conf@(Conf {..}) = do
         sourceFiles <- getDirectoryFiles ("p" </> source) ["debian//*"]
         need [ "p" </> source </> f | f <- sourceFiles]
         unit $ cmd  (EchoStdout False) (Traced "debian2dsc") "dht" "debian2dsc" "-o" targetDir ("p" </> source </> "debian")
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-haskell/pkg-haskell-tools.git



More information about the Pkg-haskell-commits mailing list