[pkg-haskell-tools] 02/03: dht make-all: Test whether the bindmount is in place

Joachim Breitner nomeata at moszumanska.debian.org
Wed Aug 19 13:56:58 UTC 2015


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

nomeata pushed a commit to branch master
in repository pkg-haskell-tools.

commit ca1dd9d4dc52f643f517b745a124ae7ee5c6d884
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Wed Aug 19 15:54:40 2015 +0200

    dht make-all: Test whether the bindmount is in place
---
 src/Utils.hs    |  5 +++++
 src/make-all.hs | 22 +++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/Utils.hs b/src/Utils.hs
index 1829cec..adea67f 100644
--- a/src/Utils.hs
+++ b/src/Utils.hs
@@ -39,3 +39,8 @@ withTempDir tmpdir act = do
     (dir,del) <- liftIO $ newTempDir tmpdir
     act dir `actionFinally` del
 
+withTempDirIO :: FilePath -> (FilePath -> IO a) -> IO a
+withTempDirIO tmpdir act = do
+    (dir,del) <- newTempDir tmpdir
+    act dir `finally` del
+
diff --git a/src/make-all.hs b/src/make-all.hs
index 532bbe0..b312ebb 100644
--- a/src/make-all.hs
+++ b/src/make-all.hs
@@ -253,7 +253,27 @@ main = do
        <> progDesc "Rebuilds a set of packages"
        <> header "make-all - Rebuilds a set of packages" )
 
-    run conf = shake (makeShakeOptions conf) (shakeMain conf)
+    run conf = testBindMount conf $ shake (makeShakeOptions conf) (shakeMain conf)
+
+
+testBindMount :: Conf -> IO () -> IO ()
+testBindMount (Conf {..}) act = do
+    -- Test if the bindmount directory works
+    withTempDirIO bindMountDir $ \tmpdir -> do
+        Exit c <- cmd ["schroot", "-c", schrootName, "--", "test", "-d", tmpdir]
+        if (c == ExitSuccess)
+        then act
+        else putStrLn $ unlines
+            [ "Inside the schroot " ++ schrootName ++", the directory " ++ bindMountDir
+            , "is not available. Please configure the schroot to bindmount this directory"
+            , "(e.g. in /etc/schroot/default/fstab), or choose a different directory using"
+            , "the --bindmount parameter."
+            , ""
+            , "For best performance, choose a directory on a tmpfs file system or"
+            , "the same partition as --output (currently " ++ targetDir ++ ")."
+            , "Actually, the latter optimization is not yet implemented...."
+            ]
+
 
 makeShakeOptions :: Conf -> ShakeOptions
 makeShakeOptions Conf{..} = shakeOptions

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