diff options
| author | Joey Hess <joey@kitenet.net> | 2014-11-22 00:22:19 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-11-22 00:22:19 -0400 |
| commit | f62d2fb18389947ce11021ba80b2aee52c6d03c2 (patch) | |
| tree | feb9eec5ca3ddc4cb1e4689711dd048912e1c6a4 /src/Propellor/Server.hs | |
| parent | d5cf4db6e1ae1c8bb5235ab274e787130bb24041 (diff) | |
propellor --spin can now deploy propellor to hosts that do not have git, ghc, or apt-get. This is accomplished by uploading a fairly portable precompiled tarball of propellor.
Diffstat (limited to 'src/Propellor/Server.hs')
| -rw-r--r-- | src/Propellor/Server.hs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Propellor/Server.hs b/src/Propellor/Server.hs index 513a81f4..786d1211 100644 --- a/src/Propellor/Server.hs +++ b/src/Propellor/Server.hs @@ -16,6 +16,7 @@ import Propellor.Protocol import Propellor.PrivData.Paths import Propellor.Git import Propellor.Ssh +import qualified Propellor.Shim as Shim import Utility.FileMode import Utility.SafeCommand @@ -69,6 +70,11 @@ updateServer hn hst connect = connect go hClose fromh sendGitClone hn updateServer hn hst connect + (Just NeedPrecompiled) -> do + hClose toh + hClose fromh + sendPrecompiled hn + updateServer hn hst connect Nothing -> return () sendRepoUrl :: Handle -> IO () @@ -113,6 +119,32 @@ sendGitClone hn = void $ actionMessage ("Clone git repository to " ++ hn) $ do , "rm -f " ++ remotebundle ] +-- Send a tarball containing the precompiled propellor, and libraries. +-- This should be reasonably portable, as long as the remote host has the +-- same architecture as the build host. +sendPrecompiled :: HostName -> IO () +sendPrecompiled hn = void $ actionMessage ("Uploading locally compiled propellor as a last resort " ++ hn) $ do + cacheparams <- sshCachingParams hn + withTmpDir "propellor" $ \tmpdir -> + bracket getWorkingDirectory changeWorkingDirectory $ \_ -> do + changeWorkingDirectory tmpdir + let shimdir = "propellor" + let me = localdir </> "propellor" + void $ Shim.setup me shimdir + withTmpFile "propellor.tar" $ \tarball -> allM id + [ boolSystem "strip" [File me] + , boolSystem "tar" [Param "cf", File tmp, File shimdir] + , boolSystem "scp" $ cacheparams ++ [File tarball, Param ("root@"++hn++":"++remotetarball) + , boolSystem "ssh" $ cacheparams ++ [Param ("root@"++hn), Param unpackcmd] + ] + where + remotetarball = "/usr/local/propellor.tar" + unpackcmd = shellSwap $ intercalate " && " + [ "cd " ++ takeDirectory remotetarball + , "tar xf " ++ remotetarball + , "rm -f " ++ remotetarball + ] + -- Shim for git push over the propellor ssh channel. -- Reads from stdin and sends it to hout; -- reads from hin and sends it to stdout. |
