From 4357d6117453e1a0759a6482f4006fa042110a6c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Mar 2014 22:14:14 -0400 Subject: propellor spin --- Property/Apt.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Property/Apt.hs') diff --git a/Property/Apt.hs b/Property/Apt.hs index 5c0a32c3..b89fb30b 100644 --- a/Property/Apt.hs +++ b/Property/Apt.hs @@ -76,22 +76,25 @@ installed ps = check (isInstallable ps) go go = runApt $ [Param "-y", Param "install"] ++ map Param ps removed :: [Package] -> Property -removed ps = check (or <$> isInstalled ps) go +removed ps = check (or <$> isInstalled' ps) go `describe` (unwords $ "apt removed":ps) where go = runApt $ [Param "-y", Param "remove"] ++ map Param ps isInstallable :: [Package] -> IO Bool isInstallable ps = do - l <- isInstalled ps + l <- isInstalled' ps return $ any (== False) l && not (null l) +isInstalled :: Package -> IO Bool +isInstalled p = (== [True]) <$> isInstalled' [p] + {- Note that the order of the returned list will not always - correspond to the order of the input list. The number of items may - even vary. If apt does not know about a package at all, it will not - be included in the result list. -} -isInstalled :: [Package] -> IO [Bool] -isInstalled ps = catMaybes . map parse . lines +isInstalled' :: [Package] -> IO [Bool] +isInstalled' ps = catMaybes . map parse . lines <$> readProcess "apt-cache" ("policy":ps) where parse l -- cgit v1.2.3