summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/DebianMirror.hs
diff options
context:
space:
mode:
authorFélix Sipma2015-09-11 11:08:43 +0200
committerJoey Hess2015-09-11 11:24:30 -0400
commit815673962625221ded45d98177f19970d66dd525 (patch)
tree5d1562bbe8442ce93b3fd14aecaf9c36f1dc3217 /src/Propellor/Property/DebianMirror.hs
parent8c6e1c2cec1f69b43b63a4e4f8974b3e1948bf1d (diff)
add DebianMirror property.
Signed-off-by: Félix Sipma <felix.sipma@no-log.org>
Diffstat (limited to 'src/Propellor/Property/DebianMirror.hs')
-rw-r--r--src/Propellor/Property/DebianMirror.hs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Propellor/Property/DebianMirror.hs b/src/Propellor/Property/DebianMirror.hs
new file mode 100644
index 00000000..271b386e
--- /dev/null
+++ b/src/Propellor/Property/DebianMirror.hs
@@ -0,0 +1,54 @@
+module Propellor.Property.DebianMirror
+ ( DebianPriority(..)
+ , showPriority
+ , mirror
+ ) 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 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 :: FilePath -> [DebianSuite] -> [Architecture] -> [Apt.Section] -> Bool -> [DebianPriority] -> Cron.Times -> Property NoInfo
+mirror dir suites archs sections source priorities crontimes = propertyList
+ ("Debian mirror " ++ dir)
+ [ Apt.installed ["debmirror"]
+ , File.dirExists dir
+ , check (not . and <$> mapM suitemirrored suites) $ cmdProperty "debmirror" args
+ `describe` "debmirror setup"
+ , Cron.niceJob ("debmirror_" ++ dir) crontimes (User "root") "/" $
+ 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", "ftp.fr.debian.org"
+ , "--method", "http"
+ , "--keyring", "/usr/share/keyrings/debian-archive-keyring.gpg"
+ , dir
+ ]