diff options
| author | Joey Hess <joey@kitenet.net> | 2014-03-30 23:37:54 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-03-30 23:37:54 -0400 |
| commit | 380c1b0fd6c25dec3c924b82f1d721aa91a001da (patch) | |
| tree | 7d5b73309b73f13ac2be3f911318fe6a126264ff /Propellor/Property/GitHome.hs | |
| parent | 02a7bf5f0e2de1d0dea71781ed0c1ae3a50e6425 (diff) | |
prepare for hackage
Diffstat (limited to 'Propellor/Property/GitHome.hs')
| -rw-r--r-- | Propellor/Property/GitHome.hs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Propellor/Property/GitHome.hs b/Propellor/Property/GitHome.hs new file mode 100644 index 00000000..400586e2 --- /dev/null +++ b/Propellor/Property/GitHome.hs @@ -0,0 +1,30 @@ +module Propellor.Property.GitHome where + +import Propellor.Common +import qualified Propellor.Property.Apt as Apt +import Propellor.Property.User + +{- | Clones Joey Hess's git home directory, and runs its fixups script. -} +installedFor :: UserName -> Property +installedFor user = check (not <$> hasGitDir user) $ + Property ("githome " ++ user) (go =<< homedir user) + `requires` Apt.installed ["git", "myrepos"] + where + go Nothing = noChange + go (Just home) = do + let tmpdir = home </> "githome" + ok <- boolSystem "git" [Param "clone", Param url, Param tmpdir] + <&&> (and <$> moveout tmpdir home) + <&&> (catchBoolIO $ removeDirectory tmpdir >> return True) + <&&> boolSystem "su" [Param "-c", Param "cd; rm -rf .aptitude/ .bashrc .profile; mr checkout; bin/fixups", Param user] + return $ if ok then MadeChange else FailedChange + moveout tmpdir home = do + fs <- dirContents tmpdir + forM fs $ \f -> boolSystem "mv" [File f, File home] + url = "git://git.kitenet.net/joey/home" + +hasGitDir :: UserName -> IO Bool +hasGitDir user = go =<< homedir user + where + go Nothing = return False + go (Just home) = doesDirectoryExist (home </> ".git") |
