From 025c7c4b8e0b7aa3ba3ff8c077c5fbef3c8fa63d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Nov 2014 21:00:14 -0400 Subject: avoid double-build in --spin It was fetching from the central repo, then building that, and then running the client-to-client git update, and the building after that. Remove the first build, as all that linking does take time. --- src/Propellor/Git.hs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/Propellor/Git.hs') diff --git a/src/Propellor/Git.hs b/src/Propellor/Git.hs index 51ed3df2..88d5c3ab 100644 --- a/src/Propellor/Git.hs +++ b/src/Propellor/Git.hs @@ -62,3 +62,25 @@ verifyOriginBranch originbranch = do nukeFile $ privDataDir "pubring.gpg" nukeFile $ privDataDir "gpg.conf" return (s == "U\n" || s == "G\n") + +-- Returns True if HEAD is changed by fetching and merging from origin. +fetchOrigin :: IO Bool +fetchOrigin = do + branchref <- getCurrentBranch + let originbranch = "origin" branchref + + void $ actionMessage "Git fetch" $ boolSystem "git" [Param "fetch"] + + oldsha <- getCurrentGitSha1 branchref + + whenM (doesFileExist keyring) $ + ifM (verifyOriginBranch originbranch) + ( do + putStrLn $ "git branch " ++ originbranch ++ " gpg signature verified; merging" + hFlush stdout + void $ boolSystem "git" [Param "merge", Param originbranch] + , warningMessage $ "git branch " ++ originbranch ++ " is not signed with a trusted gpg key; refusing to deploy it! (Running with previous configuration instead.)" + ) + + newsha <- getCurrentGitSha1 branchref + return $ oldsha /= newsha -- cgit v1.3-2-g0d8e From d130e7e628568be9593474fbe5601239c6ce8a2e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Nov 2014 21:48:48 -0400 Subject: propellor spin --- src/Propellor/Git.hs | 3 ++- src/Propellor/Message.hs | 11 +++++++---- src/Propellor/Server.hs | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/Propellor/Git.hs') diff --git a/src/Propellor/Git.hs b/src/Propellor/Git.hs index 88d5c3ab..73de1def 100644 --- a/src/Propellor/Git.hs +++ b/src/Propellor/Git.hs @@ -69,7 +69,8 @@ fetchOrigin = do branchref <- getCurrentBranch let originbranch = "origin" branchref - void $ actionMessage "Git fetch" $ boolSystem "git" [Param "fetch"] + void $ actionMessage "Pull from central git repository" $ + boolSystem "git" [Param "fetch"] oldsha <- getCurrentGitSha1 branchref diff --git a/src/Propellor/Message.hs b/src/Propellor/Message.hs index a5d4d2ca..244913ea 100644 --- a/src/Propellor/Message.hs +++ b/src/Propellor/Message.hs @@ -15,16 +15,19 @@ import Control.Applicative import Propellor.Types import Utility.Monad import Utility.Env +import Utility.FileSystemEncoding data MessageHandle = ConsoleMessageHandle | TextMessageHandle mkMessageHandle :: IO MessageHandle -mkMessageHandle = ifM (hIsTerminalDevice stdout <||> (isJust <$> getEnv "PROPELLOR_CONSOLE")) - ( return ConsoleMessageHandle - , return TextMessageHandle - ) +mkMessageHandle = do + fileEncoding stdout + ifM (hIsTerminalDevice stdout <||> (isJust <$> getEnv "PROPELLOR_CONSOLE")) + ( return ConsoleMessageHandle + , return TextMessageHandle + ) forceConsole :: IO () forceConsole = void $ setEnv "PROPELLOR_CONSOLE" "1" True diff --git a/src/Propellor/Server.hs b/src/Propellor/Server.hs index 182cc2b5..513a81f4 100644 --- a/src/Propellor/Server.hs +++ b/src/Propellor/Server.hs @@ -20,7 +20,7 @@ import Utility.FileMode import Utility.SafeCommand -- Update the privdata, repo url, and git repo over the ssh --- connection, talking the the user's local propellor instance which is +-- connection, talking to the user's local propellor instance which is -- running the updateServer update :: IO () update = do -- cgit v1.3-2-g0d8e