diff options
| author | Joey Hess <joey@kitenet.net> | 2014-03-30 22:14:14 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-03-30 22:14:14 -0400 |
| commit | 4357d6117453e1a0759a6482f4006fa042110a6c (patch) | |
| tree | d1c011a5244f20cec99e3cad384de9ba4d177add /Property/Apt.hs | |
| parent | 25a12dd8f0e05165c5b7bed2b0e7b62d75b59e5c (diff) | |
propellor spin
Diffstat (limited to 'Property/Apt.hs')
| -rw-r--r-- | Property/Apt.hs | 11 |
1 files changed, 7 insertions, 4 deletions
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 |
