From f2ebd068739026718f11749e2c9d50002b13777e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Apr 2014 12:19:32 -0400 Subject: [PATCH 1/6] propellor spin From fc7b3893d1af13f5577cc1070318f077405d4acb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Apr 2014 12:20:42 -0400 Subject: [PATCH 2/6] clean up gpg droppings --- Propellor/CmdLine.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index ed762e7..6d7f862 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -116,7 +116,8 @@ updateFirst cmdline next = do modifyFileMode privDataDir (removeModes otherGroupModes) s <- readProcessEnv "git" ["log", "-n", "1", "--format=%G?", originbranch] (Just [("GNUPGHOME", privDataDir)]) - nukeFile $ privDataDir "trustring.gpg" + nukeFile $ privDataDir "trustdb.gpg" + nukeFile $ privDataDir "pubring.gpg" nukeFile $ privDataDir "gpg.conf" if s == "U\n" || s == "G\n" then do From a8eecbca216b3c3947fd1c5da715abda6a5147f9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Apr 2014 12:21:44 -0400 Subject: [PATCH 3/6] propellor spin From 492e4c68c8ac6aa4963245120880dea5edfbc9e6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Apr 2014 12:26:27 -0400 Subject: [PATCH 4/6] better template --- Propellor/CmdLine.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index 6d7f862..3de7106 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -197,7 +197,7 @@ spin host = do sendGitClone :: HostName -> String -> IO () sendGitClone host url = void $ actionMessage ("Pushing git repository to " ++ host) $ - withTmpFile "propellor.git." $ \tmp _ -> allM id + withTmpFile "propellor.git" $ \tmp _ -> allM id -- TODO: ssh connection caching, or better push method -- with less connections. [ boolSystem "git" [Param "bundle", Param "create", File tmp, Param "HEAD"] From 8573c39d486ef12f772dd08847bff3ba989dcbec Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Apr 2014 12:33:36 -0400 Subject: [PATCH 5/6] fix bootstrapping from a different branch than master --- Propellor/CmdLine.hs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index 3de7106..e4838f9 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -94,11 +94,14 @@ buildFirst cmdline next = do where getmtime = catchMaybeIO $ getModificationTime "propellor" +getCurrentBranch :: IO String +getCurrentBranch = takeWhile (/= '\n') + <$> readProcess "git" ["symbolic-ref", "--short", "HEAD"] + updateFirst :: CmdLine -> IO () -> IO () updateFirst cmdline next = do - branchref <- takeWhile (/= '\n') - <$> readProcess "git" ["symbolic-ref", "HEAD"] - let originbranch = "origin" takeFileName branchref + branchref <- getCurrentBranch + let originbranch = "origin" branchref void $ actionMessage "Git fetch" $ boolSystem "git" [Param "fetch"] @@ -144,9 +147,10 @@ spin host = do url <- getUrl void $ gitCommit [Param "--allow-empty", Param "-a", Param "-m", Param "propellor spin"] void $ boolSystem "git" [Param "push"] - go url =<< gpgDecrypt (privDataFile host) + branch <- getCurrentBranch + go url branch =<< gpgDecrypt (privDataFile host) where - go url privdata = withBothHandles createProcessSuccess (proc "ssh" [user, bootstrapcmd]) $ \(toh, fromh) -> do + go url branch privdata = withBothHandles createProcessSuccess (proc "ssh" [user, bootstrapcmd branch]) $ \(toh, fromh) -> do let finish = do senddata toh (privDataFile host) privDataMarker privdata hClose toh @@ -166,7 +170,7 @@ spin host = do user = "root@"++host - bootstrapcmd = shellWrap $ intercalate " ; " + bootstrapcmd branch = shellWrap $ intercalate " ; " [ "if [ ! -d " ++ localdir ++ " ]" , "then " ++ intercalate " && " [ "apt-get -y install git" @@ -174,6 +178,8 @@ spin host = do ] , "else " ++ intercalate " && " [ "cd " ++ localdir + , "git checkout -b " ++ branch + , "git branch --set-upstream-to=origin/" ++ branch ++ " " ++ branch , "if ! test -x ./propellor; then make build; fi" , "./propellor --boot " ++ host ] From 9c3ab7505957ee83c2d59fcc8a934bca326b615b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 3 Apr 2014 12:35:27 -0400 Subject: [PATCH 6/6] fix --- Propellor/CmdLine.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs index e4838f9..8ed21cb 100644 --- a/Propellor/CmdLine.hs +++ b/Propellor/CmdLine.hs @@ -166,7 +166,7 @@ spin host = do hClose toh hClose fromh sendGitClone host url - go url privdata + go url branch privdata user = "root@"++host