From 9161ecaac25d71f90f68ec1f3affc773ab53c76a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 2 Apr 2014 00:31:07 -0400 Subject: more robust apt --- Propellor/Property/Apt.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Propellor/Property/Apt.hs') 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 -- cgit v1.2.3