summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess2014-04-02 00:31:07 -0400
committerJoey Hess2014-04-02 00:31:07 -0400
commit9161ecaac25d71f90f68ec1f3affc773ab53c76a (patch)
tree66da15342dd3dc6069e99c45a9d578bba70ad996
parent3a4a3ea409c0051e5f72315bf03ac862bc88c7d1 (diff)
more robust apt
-rw-r--r--Propellor/Property/Apt.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/Propellor/Property/Apt.hs b/Propellor/Property/Apt.hs
index 9f0168ac..92e23b7e 100644
--- a/Propellor/Property/Apt.hs
+++ b/Propellor/Property/Apt.hs
@@ -78,7 +78,7 @@ upgrade = runApt ["-y", "dist-upgrade"]
type Package = String
installed :: [Package] -> Property
-installed ps = check (isInstallable ps) go
+installed ps = robustly $ check (isInstallable ps) go
`describe` (unwords $ "apt installed":ps)
where
go = runApt $ ["-y", "install"] ++ ps
@@ -90,11 +90,20 @@ removed ps = check (or <$> isInstalled' ps) go
go = runApt $ ["-y", "remove"] ++ ps
buildDep :: [Package] -> Property
-buildDep ps = check (isInstallable ps) go
+buildDep ps = robustly go
`describe` (unwords $ "apt build-dep":ps)
where
go = runApt $ ["-y", "build-dep"] ++ ps
+{- Package installation may fail becuse the archive has changed.
+ - Run an update in that case and retry. -}
+robustly :: Property -> Property
+robustly p = Property (propertyDesc p) $ do
+ r <- ensureProperty p
+ if r == FailedChange
+ then ensureProperty $ p `requires` update
+ else return r
+
isInstallable :: [Package] -> IO Bool
isInstallable ps = do
l <- isInstalled' ps