Run apt-cache policy with LANG=C.

This commit is contained in:
Joey Hess 2014-12-01 11:59:23 -04:00
parent 1906500030
commit c9d09afafa
Failed to extract signature
2 changed files with 5 additions and 2 deletions

1
debian/changelog vendored
View File

@ -21,6 +21,7 @@ propellor (1.1.0) UNRELEASED; urgency=medium
This is more robust. This is more robust.
* propellor.debug can be set in the git config to enable more persistent * propellor.debug can be set in the git config to enable more persistent
debugging output. debugging output.
* Run apt-cache policy with LANG=C.
-- Joey Hess <joeyh@debian.org> Sat, 22 Nov 2014 00:12:35 -0400 -- Joey Hess <joeyh@debian.org> Sat, 22 Nov 2014 00:12:35 -0400

View File

@ -193,13 +193,15 @@ isInstalled p = (== [True]) <$> isInstalled' [p]
-- even vary. If apt does not know about a package at all, it will not -- even vary. If apt does not know about a package at all, it will not
-- be included in the result list. -- be included in the result list.
isInstalled' :: [Package] -> IO [Bool] isInstalled' :: [Package] -> IO [Bool]
isInstalled' ps = catMaybes . map parse . lines isInstalled' ps = catMaybes . map parse . lines <$> policy
<$> readProcess "apt-cache" ("policy":ps)
where where
parse l parse l
| "Installed: (none)" `isInfixOf` l = Just False | "Installed: (none)" `isInfixOf` l = Just False
| "Installed: " `isInfixOf` l = Just True | "Installed: " `isInfixOf` l = Just True
| otherwise = Nothing | otherwise = Nothing
policy = do
environ <- addEntry "LANG" "C" <$> getEnvironment
readProcessEnv "apt-cache" ("policy":ps) (Just environ)
autoRemove :: Property autoRemove :: Property
autoRemove = runApt ["-y", "autoremove"] autoRemove = runApt ["-y", "autoremove"]