summaryrefslogtreecommitdiff
path: root/Build/Standalone.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-12-14 15:52:44 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-12-14 16:07:59 -0400
commit3780a5eb0a01e3d31fc0de2410f7b01518710a0e (patch)
tree0b187086ee7cb6ed6dd1c49b4dd0871c856a27cd /Build/Standalone.hs
parentd6adaf499124c11e3d79252821ef400d2a87b155 (diff)
move thirdparty program installation for standalone bundle into haskell program
This allows it to use Build.SysConfig to always install the programs configure detected. Amoung other fixes, this ensures the right uuid generator and checksum programs are installed. I also cleaned up the handling of lsof's path; configure now checks for it in PATH, but falls back to looking for it in sbin directories.
Diffstat (limited to 'Build/Standalone.hs')
-rw-r--r--Build/Standalone.hs78
1 files changed, 78 insertions, 0 deletions
diff --git a/Build/Standalone.hs b/Build/Standalone.hs
new file mode 100644
index 000000000..cf0abbc13
--- /dev/null
+++ b/Build/Standalone.hs
@@ -0,0 +1,78 @@
+{- Makes standalone bundle.
+ -
+ - Copyright 2012 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+{-# LANGUAGE CPP #-}
+
+module Build.Standalone where
+
+import Control.Applicative
+import Control.Monad.IfElse
+import System.Environment
+import Data.Maybe
+import System.FilePath
+import System.Directory
+import System.IO
+import Control.Monad
+import Data.List
+import Build.SysConfig as SysConfig
+
+import Utility.PartialPrelude
+import Utility.Directory
+import Utility.Process
+import Utility.Monad
+import Utility.SafeCommand
+import Utility.Path
+
+{- Programs that git-annex uses, to include in the bundle.
+ -
+ - These may be just the command name, or the full path to it. -}
+thirdpartyProgs :: [FilePath]
+thirdpartyProgs = catMaybes
+ [ Just "git"
+ , Just "cp"
+ , Just "xargs"
+ , Just "gpg"
+ , Just "rsync"
+ , Just "ssh"
+ , Just "sh"
+ , headMaybe $ words SysConfig.uuid -- may include parameters
+ , ifset SysConfig.curl "curl"
+ , ifset SysConfig.wget "wget"
+ , ifset SysConfig.bup "bup"
+ , SysConfig.lsof
+ , SysConfig.sha1
+ , SysConfig.sha256
+ , SysConfig.sha512
+ , SysConfig.sha224
+ , SysConfig.sha384
+ ]
+ where
+ ifset True s = Just s
+ ifset False _ = Nothing
+
+progDir :: FilePath -> FilePath
+#ifdef darwin_HOST_OS
+progDir topdir = topdir
+#else
+progDir topdir = topdir </> "bin"
+#endif
+
+installProg :: FilePath -> FilePath -> IO ()
+installProg dir prog = searchPath prog >>= go
+ where
+ go Nothing = error $ "cannot find " ++ prog ++ " in PATH"
+ go (Just f) = unlessM (boolSystem "install" [File f, File dir]) $
+ error $ "install failed for " ++ prog
+
+main = getArgs >>= go
+ where
+ go [] = error "specify topdir"
+ go (topdir:_) = do
+ let dir = progDir topdir
+ createDirectoryIfMissing True dir
+ forM_ thirdpartyProgs $ installProg dir
+