summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2016-03-08 01:38:28 -0400
committerJoey Hess2016-03-08 01:38:28 -0400
commita6862da9ce7a479d34f58637e79289aa428e69f3 (patch)
treea1ad08bcb92d098a16baef2fb36874bbb56ef460 /src/Propellor
parent2415e5faa684c58f01264b53b28503aee226db1f (diff)
fix reversion in bootstrap spin of system with no declared OS
The freebsd changes caused a bootstrap of a system with no declared OS to not work, where before it was assumed to be some debian-like system where apt can be used. Brought back this assumption.
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/Bootstrap.hs46
-rw-r--r--src/Propellor/Spin.hs15
2 files changed, 35 insertions, 26 deletions
diff --git a/src/Propellor/Bootstrap.hs b/src/Propellor/Bootstrap.hs
index 633a2ff4..11e59e6f 100644
--- a/src/Propellor/Bootstrap.hs
+++ b/src/Propellor/Bootstrap.hs
@@ -16,7 +16,7 @@ type ShellCommand = String
-- Should be run inside the propellor config dir, and will install
-- all necessary build dependencies and build propellor.
bootstrapPropellorCommand :: Maybe System -> ShellCommand
-bootstrapPropellorCommand msys = maybe "true" checkDepsCommand msys ++
+bootstrapPropellorCommand msys = checkDepsCommand msys ++
"&& if ! test -x ./propellor; then "
++ buildCommand ++
"; fi;" ++ checkBinaryCommand
@@ -40,7 +40,7 @@ buildCommand = intercalate " && "
-- Run cabal configure to check if all dependencies are installed;
-- if not, run the depsCommand.
-checkDepsCommand :: System -> ShellCommand
+checkDepsCommand :: Maybe System -> ShellCommand
checkDepsCommand sys = "if ! cabal configure >/dev/null 2>&1; then " ++ depsCommand sys ++ "; fi"
-- Install build dependencies of propellor.
@@ -53,12 +53,17 @@ checkDepsCommand sys = "if ! cabal configure >/dev/null 2>&1; then " ++ depsComm
-- So, as a second step, cabal is used to install all dependencies.
--
-- Note: May succeed and leave some deps not installed.
-depsCommand :: System -> ShellCommand
-depsCommand (System distr _) = "( " ++ intercalate " ; " (concat [osinstall, cabalinstall]) ++ " ) || true"
+depsCommand :: Maybe System -> ShellCommand
+depsCommand msys = "( " ++ intercalate " ; " (concat [osinstall, cabalinstall]) ++ " ) || true"
where
- osinstall = case distr of
- (FreeBSD _) -> map pkginstall fbsddeps
- _ -> "apt-get update" : map aptinstall debdeps
+ osinstall = case msys of
+ Just (System (FreeBSD _) _) -> map pkginstall fbsddeps
+ Just (System (Debian _) _) -> useapt
+ Just (System (Buntish _) _) -> useapt
+ -- assume a debian derived system when not specified
+ Nothing -> useapt
+
+ useapt = "apt-get update" : map aptinstall debdeps
cabalinstall =
[ "cabal update"
@@ -106,19 +111,22 @@ depsCommand (System distr _) = "( " ++ intercalate " ; " (concat [osinstall, cab
, "gmake"
]
-installGitCommand :: System -> ShellCommand
-installGitCommand (System distr _) =
- "if ! git --version >/dev/null; then " ++ intercalate " && " cmds ++ "; fi"
+installGitCommand :: Maybe System -> ShellCommand
+installGitCommand msys = case msys of
+ (Just (System (Debian _) _)) -> use apt
+ (Just (System (Buntish _) _)) -> use apt
+ (Just (System (FreeBSD _) _)) -> use
+ [ "ASSUME_ALWAYS_YES=yes pkg update"
+ , "ASSUME_ALWAYS_YES=yes pkg install git"
+ ]
+ -- assume a debian derived system when not specified
+ Nothing -> use apt
where
- cmds = case distr of
- (FreeBSD _) ->
- [ "ASSUME_ALWAYS_YES=yes pkg update"
- , "ASSUME_ALWAYS_YES=yes pkg install git"
- ]
- _ ->
- [ "apt-get update"
- , "DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends --no-upgrade -y install git"
- ]
+ use cmds = "if ! git --version >/dev/null; then " ++ intercalate " && " cmds ++ "; fi"
+ apt =
+ [ "apt-get update"
+ , "DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends --no-upgrade -y install git"
+ ]
buildPropellor :: IO ()
buildPropellor = unlessM (actionMessage "Propellor build" build) $
diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs
index 2c57f57d..5f103b8a 100644
--- a/src/Propellor/Spin.hs
+++ b/src/Propellor/Spin.hs
@@ -79,12 +79,10 @@ spin' mprivdata relay target hst = do
Just r -> pure r
Nothing -> getSshTarget target hst
- let (InfoVal o) = (getInfo $ hostInfo hst) :: InfoVal System
-
-- Install, or update the remote propellor.
updateServer target relay hst
- (proc "ssh" $ cacheparams ++ [sshtarget, shellWrap (probecmd o)])
- (proc "ssh" $ cacheparams ++ [sshtarget, shellWrap (updatecmd (Just o))])
+ (proc "ssh" $ cacheparams ++ [sshtarget, shellWrap probecmd])
+ (proc "ssh" $ cacheparams ++ [sshtarget, shellWrap updatecmd])
=<< getprivdata
-- And now we can run it.
@@ -92,21 +90,24 @@ spin' mprivdata relay target hst = do
error "remote propellor failed"
where
hn = fromMaybe target relay
+ sys = case getInfo (hostInfo hst) of
+ InfoVal o -> Just o
+ NoInfoVal -> Nothing
relaying = relay == Just target
viarelay = isJust relay && not relaying
- probecmd sys = intercalate " ; "
+ probecmd = intercalate " ; "
["if [ ! -d " ++ localdir ++ "/.git ]"
, "then (" ++ intercalate " && "
[ installGitCommand sys
, "echo " ++ toMarked statusMarker (show NeedGitClone)
] ++ ") || echo " ++ toMarked statusMarker (show NeedPrecompiled)
- , "else " ++ (updatecmd (Just sys))
+ , "else " ++ updatecmd
, "fi"
]
- updatecmd sys = intercalate " && "
+ updatecmd = intercalate " && "
[ "cd " ++ localdir
, bootstrapPropellorCommand sys
, if viarelay