diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-09-13 12:49:08 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-09-13 12:49:08 -0400 |
| commit | 0f9f05ae9e65182daa9bfc98a9932e2e1382e9b5 (patch) | |
| tree | b50b56d366fe2e7f2b6c8ddb30746970253d5aff /src/Propellor/Property/DebianMirror.hs | |
| parent | 7c5bfb7d77bf64557b7b98c9ae358048b64e8329 (diff) | |
| parent | 2af70d4ac7ff25a3e596de195abe40db46c74074 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/DebianMirror.hs')
| -rw-r--r-- | src/Propellor/Property/DebianMirror.hs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/Propellor/Property/DebianMirror.hs b/src/Propellor/Property/DebianMirror.hs new file mode 100644 index 00000000..cd98b6ff --- /dev/null +++ b/src/Propellor/Property/DebianMirror.hs @@ -0,0 +1,61 @@ +module Propellor.Property.DebianMirror + ( DebianPriority(..) + , showPriority + , mirror + , mirrorCdn + ) where + +import Propellor +import qualified Propellor.Property.File as File +import qualified Propellor.Property.Apt as Apt +import qualified Propellor.Property.Cron as Cron +import qualified Propellor.Property.User as User + +import Data.List + + +data DebianPriority = Essential | Required | Important | Standard | Optional | Extra + deriving (Show, Eq) + +showPriority :: DebianPriority -> String +showPriority Essential = "essential" +showPriority Required = "required" +showPriority Important = "important" +showPriority Standard = "standard" +showPriority Optional = "optional" +showPriority Extra = "extra" + +mirror :: Apt.Url -> FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> Bool -> [DebianPriority] -> Cron.Times -> Property NoInfo +mirror url dir suites archs sections source priorities crontimes = propertyList + ("Debian mirror " ++ dir) + [ Apt.installed ["debmirror"] + , User.accountFor (User "debmirror") + , File.dirExists dir + , File.ownerGroup dir (User "debmirror") (Group "debmirror") + , check (not . and <$> mapM suitemirrored suites) $ cmdProperty "debmirror" args + `describe` "debmirror setup" + , Cron.niceJob ("debmirror_" ++ dir) crontimes (User "debmirror") "/" $ + unwords ("/usr/bin/debmirror" : args) + ] + where + suitemirrored suite = doesDirectoryExist $ dir </> "dists" </> Apt.showSuite suite + architecturearg = intercalate "," + suitearg = intercalate "," $ map Apt.showSuite suites + priorityRegex pp = "(" ++ intercalate "|" (map showPriority pp) ++ ")" + args = + [ "--dist" , suitearg + , "--arch", architecturearg archs + , "--section", intercalate "," sections + , "--limit-priority", "\"" ++ priorityRegex priorities ++ "\"" + ] + ++ + (if source then [] else ["--nosource"]) + ++ + [ "--host", url + , "--method", "http" + , "--keyring", "/usr/share/keyrings/debian-archive-keyring.gpg" + , dir + ] + +mirrorCdn :: FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> Bool -> [DebianPriority] -> Cron.Times -> Property NoInfo +mirrorCdn = mirror "http://httpredir.debian.org/debian" |
