[pkg-haskell-tools] 03/04: Added phony targets for all source packages. Needs some investigation, why it now tries to build ghc by itself...

Sven Bartscher svenb-guest at moszumanska.debian.org
Sat Aug 22 10:35:40 UTC 2015


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

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

commit 03db3b1fe685c069188951ef895c03598d0f713d
Author: Sven Bartscher <sven.bartscher at weltraumschlangen.de>
Date:   Thu Aug 20 12:59:12 2015 +0200

    Added phony targets for all source packages.
    Needs some investigation, why it now tries to build ghc by itself...
---
 src/make-all.hs | 55 ++++++++++++++++++-------------------------------------
 1 file changed, 18 insertions(+), 37 deletions(-)

diff --git a/src/make-all.hs b/src/make-all.hs
index 6e97039..0b8edb7 100644
--- a/src/make-all.hs
+++ b/src/make-all.hs
@@ -11,7 +11,7 @@ import Control.Monad
 import Text.Read
 import System.Directory (createDirectory, copyFile)
 import qualified System.Directory
-import System.Directory.Extra (listFiles)
+import System.Directory.Extra (listFiles, listContents)
 import System.Exit
 import System.Environment
 
@@ -32,8 +32,6 @@ import qualified Debian.Version.Common as DC
 import Text.Parsec hiding (option, oneOf)
 import Text.Parsec.String
 
-import Text.PrettyPrint.HughesPJ (render)
-
 import Utils
 import Link
 
@@ -266,15 +264,6 @@ newtype GetBinToDeb = GetBinToDeb String  deriving (Show,Typeable,Eq,Hashable,Bi
 
 newtype GetArch = GetArch () deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
 
-getPkgVersion :: String -> Action String
-getPkgVersion package = do
-  let changesFile = "p" </> package </> "debian/changelog"
-  rawChanges <- readFile' changesFile
-  either (fail . unlines) (\(entry, _) ->
-                           return $ showV $ DC.logVersion entry)
-                        $ DC.parseEntry rawChanges
-      where showV = render . DC.prettyDebianVersion
-
 manpage :: String
 manpage = unlines [ "TODO" ]
 
@@ -293,7 +282,7 @@ main = do
        <> header "make-all - Rebuilds a set of packages" )
 
     run conf = do
-         packages <- System.Directory.getDirectoryContents "p"
+         packages <- getSourcePackages $ excludedPackages conf
          testBindMount conf $ shake (makeShakeOptions conf) (shakeMain conf packages)
 
 testBindMount :: Conf -> IO () -> IO ()
@@ -314,6 +303,15 @@ testBindMount (Conf {..}) act = do
             , "Actually, the latter optimization is not yet implemented...."
             ]
 
+getSourcePackages :: [FilePath] -> IO [FilePath]
+getSourcePackages excluded = do
+  sources <- listContents "p" -- Filtering out files can be avoided, because a file can't contain a debian directory and will be filtered out in the next step.
+  let sources' = filter (`notElem` excluded) sources
+  sources'' <- flip filterM sources' $ \s ->
+      (&&) <$> System.Directory.doesFileExist (s </> "debian/control")
+           <*> System.Directory.doesFileExist (s </> "debian/changelog")
+  return $ map takeFileName sources''
+
 makeShakeOptions :: Conf -> ShakeOptions
 makeShakeOptions Conf{..} = shakeOptions
     { shakeFiles = targetDir </> ".shake"
@@ -324,12 +322,9 @@ makeShakeOptions Conf{..} = shakeOptions
     , shakeProgress = progressSimple
     }
 
-shakeMain conf@(Conf {..}) packages = do
+shakeMain conf@(Conf {..}) sources = do
     if null targets then want ["all"] else want targets
 
-    getExcludedSources <- addOracle $ \GetExcludedSources{} ->
-        return $ excludedPackages
-
     getArch' <- addOracle $ \GetArch{} -> do
         Stdout archString <- cmd
             [ "schroot"
@@ -343,26 +338,13 @@ shakeMain conf@(Conf {..}) packages = do
             _ -> fail $ "Unexpected output from dpkg --print-architecture: \""++ archString ++"\""
     let getArch = getArch' (GetArch ())
 
-
-    targetDir </> "cache/sources.txt" %> \out -> do
-        sources <- getDirectoryDirs "p"
-        excluded <- getExcludedSources (GetExcludedSources ())
-        let sources' = filter (`notElem` excluded) sources
-        sources'' <- flip filterM sources' $ \s ->
-            (&&) <$> doesFileExist ("p" </> s </> "debian" </> "control")
-                 <*> doesFileExist ("p" </> s </> "debian" </> "changelog")
-        putNormal "# enumerating sources..."
-        writeFileChanged out (unlines sources'')
-
     targetDir </> "cache/all-binaries.txt" %> \out -> do
-        sources <- readFileLines $ targetDir </> "cache/sources.txt"
         binaries <- concat <$> mapM readFileLines
             [ targetDir </> "cache" </> "binaries" </> s <.> "txt" | s <- sources ]
         putNormal "# enumerating all binaries..."
         writeFileChanged out $ unlines binaries
 
     targetDir </> "cache/built-by.txt" %> \out -> do
-        sources <- readFileLines $ targetDir </> "cache/sources.txt"
         builtBy <- liftM (sort . concat) $ forM sources $ \s -> do
             pkgs <- readFileLines $ targetDir </> "cache/binaries/" ++ s ++ ".txt"
             return [(pkg,s) | pkg <- pkgs]
@@ -399,7 +381,6 @@ shakeMain conf@(Conf {..}) packages = do
     targetDir </> "cache/all-changes-files.txt" %> \out -> do
         arch <- getArch
         putNormal "# enumerating all changes files..."
-        sources <- readFileLines $ targetDir </> "cache/sources.txt"
         versioned <- forM sources $ \s -> do
             v <- versionOfSource s
             return (s,v)
@@ -525,9 +506,9 @@ shakeMain conf@(Conf {..}) packages = do
         need [ "p" </> source </> f | f <- sourceFiles]
         unit $ cmd  (EchoStdout False) (Traced "debian2dsc") "dht" "debian2dsc" "-o" targetDir ("p" </> source </> "debian")
 
-    phonys $ \package -> if package `elem` packages
-                         then Just $ do
-                           version <- getPkgVersion package
-                           Arch arch <- getArch ()
-                           need [targetDir </> changesFileName package version arch]
-                         else Nothing
+    phonys $ \source -> if source `elem` sources
+                        then Just $ do
+                          version <- versionOfSource source
+                          arch <- getArch
+                          need [targetDir </> changesFileName source version arch]
+                        else Nothing

-- 
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