summaryrefslogtreecommitdiff
path: root/Property
diff options
context:
space:
mode:
authorJoey Hess2014-03-30 01:44:36 -0400
committerJoey Hess2014-03-30 01:44:36 -0400
commit1e045b67b9cb8bf60019f0c72279e2be438db72d (patch)
tree2c44e6efdcef8ae5fe3181edf3ce63811ec51856 /Property
parent13431d874cbaa333150e3f3cbf14b4f72062d94a (diff)
unattended updates
Diffstat (limited to 'Property')
-rw-r--r--Property/Apt.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/Property/Apt.hs b/Property/Apt.hs
index c326170c..9db8a6a3 100644
--- a/Property/Apt.hs
+++ b/Property/Apt.hs
@@ -3,6 +3,8 @@ module Property.Apt where
import Data.Maybe
import Control.Applicative
import Data.List
+import System.IO
+import Control.Monad
import Property
import Utility.SafeCommand
@@ -93,3 +95,23 @@ isInstalled ps = catMaybes . map parse . lines
autoRemove :: Property
autoRemove = runApt [Param "-y", Param "autoremove"]
+
+unattendedUpgrades :: Bool -> Property
+unattendedUpgrades enabled = installed ["unattended-upgrades"]
+ `onChange` reConfigure "unattended-upgrades"
+ [("unattended-upgrades/enable_auto_updates"
+ , "boolean"
+ , if enabled then "true" else "false")]
+
+{- Preseeds debconf values and reconfigures the package so it takes
+ - effect. -}
+reConfigure :: Package -> [(String, String, String)] -> Property
+reConfigure package vals = reconfigure `requires` setselections
+ where
+ setselections = IOProperty "preseed" $ makeChange $
+ withHandle StdinHandle createProcessSuccess
+ (proc "debconf-set-selections" []) $ \h -> do
+ forM_ vals $ \(template, tmpltype, value) ->
+ hPutStrLn h $ unwords [package, template, tmpltype, value]
+ hClose h
+ reconfigure = cmdProperty "dpkg-reconfigure" [Param "-fnone", Param package]