haskell-updater 1.1.1.0 → 1.1.2.0
raw patch · 3 files changed
+87/−63 lines, 3 files
Files
- Distribution/Gentoo/GHC.hs +73/−53
- Main.hs +13/−9
- haskell-updater.cabal +1/−1
Distribution/Gentoo/GHC.hs view
@@ -15,6 +15,7 @@ , libFronts , oldGhcPkgs , brokenPkgs+ , allInstalledPackages ) where import Distribution.Gentoo.Util@@ -107,6 +108,63 @@ tryMaybe :: (a -> Maybe b) -> a -> Either a b tryMaybe f a = maybe (Left a) Right $ f a ++type ConfMap = Map PackageIdentifier FilePath++-- Attempt to match the provided broken package to one of the+-- installed packages.+matchConf :: ConfMap -> PackageIdentifier -> Either PackageIdentifier FilePath+matchConf = tryMaybe . flip Map.lookup++-- Read in all Gentoo .conf files from the current GHC version and+-- create a Map+readConf :: IO ConfMap+readConf = ghcLibDir >>= confFiles >>= foldM addConf Map.empty++-- Add this .conf file to the Map+addConf :: ConfMap -> FilePath -> IO ConfMap+addConf cmp conf = do cnts <- readFile conf+ case (reads cnts) of+ [] -> return cmp+ -- ebuilds that have CABAL_CORE_LIB_GHC_PV set+ -- for this version of GHC will have a .conf+ -- file containing just []+ [([],_)] -> return cmp+ rd -> do let nm = cfNm rd+ return $ Map.insert nm conf cmp+ where+ -- It's not InstalledPackageInfo, as it can't read the modules+ cfNm :: [([InstalledPackageInfo_ String], String)] -> PackageIdentifier+ cfNm = packageId . head . fst . head++checkPkgs :: String -> String -> ([PackageIdentifier], [FilePath])+ -> IO [Package]+checkPkgs msg typ (pns,cnfs)+ = do putStrLn $ "Searching for " ++ msg ++ "."+ -- (pns, cnfs) <- brokenConfs+ unless (null pns)+ $ unknownPackages pns+ (nI, pkgs) <- liftM partitionEithers $ mapM hasFile' cnfs+ unless (null nI)+ $ unknownFiles nI+ let pkgs' = notGHC pkgs+ pkgListPrint typ pkgs'+ return pkgs+ where+ hasFile' f = do mp <- hasFile f+ return $ maybe (Left f) Right mp++ unknownPackages ps+ = do putStrLn "\nThe following packages don't seem \+ \to have been installed by your package manager:"+ printList display ps++ unknownFiles fs+ = do putStrLn "\nThe following files are those corresponding \+ \to packages installed by your package manager\n\+ \which can't be matched up to the packages that own them."+ printList id fs+ -- ----------------------------------------------------------------------------- -- Finding packages installed with other versions of GHC@@ -164,34 +222,12 @@ -- Finding broken packages in this install of GHC. brokenPkgs :: IO [Package]-brokenPkgs = do putStrLn "Searching for Haskell libraries with broken dependencies."- (pns, cnfs) <- brokenConfs- unless (null pns)- $ unknownPackages pns- (nI, pkgs) <- liftM partitionEithers $ mapM hasFile' cnfs- unless (null nI)- $ unknownFiles nI- let pkgs' = notGHC pkgs- pkgListPrint "broken" pkgs'- return pkgs- where- hasFile' f = do mp <- hasFile f- return $ maybe (Left f) Right mp-- unknownPackages ps- = do putStrLn "\nThe following packages don't seem \- \to have been installed by your package manager:"- printList display ps-- unknownFiles fs- = do putStrLn "\nThe following files are those corresponding \- \to packages installed by your package manager\n\- \which can't be matched up to the packages that own them."- printList id fs+brokenPkgs = brokenConfs >>=+ checkPkgs "Haskell libraries with broken dependencies" "broken" -- .conf files from broken packages of this GHC version brokenConfs :: IO ([PackageIdentifier], [FilePath])-brokenConfs = do brkn <- getBroken -- getBroken+brokenConfs = do brkn <- getBroken -- Check if we actually have to go look up files and -- do IO. if null brkn@@ -200,35 +236,19 @@ return $ partitionEithers $ map (matchConf cnfs) brkn -type ConfMap = Map PackageIdentifier FilePath---- Attempt to match the provided broken package to one of the--- installed packages.-matchConf :: ConfMap -> PackageIdentifier -> Either PackageIdentifier FilePath-matchConf = tryMaybe . flip Map.lookup---- Read in all Gentoo .conf files from the current GHC version and--- create a Map-readConf :: IO ConfMap-readConf = ghcLibDir >>= confFiles >>= foldM addConf Map.empty---- Add this .conf file to the Map-addConf :: ConfMap -> FilePath -> IO ConfMap-addConf cmp conf = do cnts <- readFile conf- case (reads cnts) of- [] -> return cmp- -- ebuilds that have CABAL_CORE_LIB_GHC_PV set- -- for this version of GHC will have a .conf- -- file containing just []- [([],_)] -> return cmp- rd -> do let nm = cfNm rd- return $ Map.insert nm conf cmp- where- -- It's not InstalledPackageInfo, as it can't read the modules- cfNm :: [([InstalledPackageInfo_ String], String)] -> PackageIdentifier- cfNm = packageId . head . fst . head- -- Return the closure of all packages affected by breakage getBroken :: IO [PackageIdentifier] getBroken = liftM (mapMaybe simpleParse . words) $ ghcPkgRawOut ["check", "--simple-output"]++-- -----------------------------------------------------------------------------++allInstalledPackages :: IO [Package]+allInstalledPackages = do putStrLn "Finding all libraries installed with the \+ \current version of GHC."+ libDir <- ghcLibDir+ let libDir' = BS.pack libDir+ pkgs <- liftM notGHC+ $ pkgsHaveContent $ hasDirMatching (==libDir')+ pkgListPrint "installed" pkgs+ return pkgs
Main.hs view
@@ -13,9 +13,10 @@ import Distribution.Gentoo.GHC import Distribution.Gentoo.Packages import Distribution.Gentoo.PkgManager+import Distribution.Gentoo.Util import Data.Either(partitionEithers)-import Data.List(foldl1')+import Data.List(foldl1', nub) import Data.Version(showVersion) import qualified Data.Set as Set import Data.Set(Set)@@ -72,18 +73,17 @@ data BuildTarget = GhcUpgrade | DepCheck+ | AllInstalled deriving (Eq, Ord, Show, Read) -getPackages :: BuildTarget -> IO [Package]-getPackages GhcUpgrade = oldGhcPkgs-getPackages DepCheck = brokenPkgs--getPackages' :: BuildTarget -> IO (Set Package)-getPackages' = liftM Set.fromList . getPackages+getPackages :: BuildTarget -> IO [Package]+getPackages GhcUpgrade = oldGhcPkgs+getPackages DepCheck = brokenPkgs+getPackages AllInstalled = allInstalledPackages allGetPackages :: Set BuildTarget -> IO [Package]-allGetPackages = liftM (Set.toList . Set.unions)- . mapM getPackages'+allGetPackages = liftM nub+ . concatMapM getPackages . Set.toList -- -----------------------------------------------------------------------------@@ -124,6 +124,7 @@ | CustomPMFlag String | Check | Upgrade+ | RebuildAll | Pretend | NoDeep deriving (Eq, Ord, Show, Read)@@ -165,6 +166,7 @@ flagToAction VersionFlag = Right Version flagToAction Check = Right . Build $ Set.singleton DepCheck flagToAction Upgrade = Right . Build $ Set.singleton GhcUpgrade+flagToAction RebuildAll = Right . Build $ Set.singleton AllInstalled flagToAction f = Left f flagToPM :: Flag -> Either Flag PkgManager@@ -178,6 +180,8 @@ "Check dependencies of Haskell packages." , Option ['u'] ["upgrade"] (NoArg Upgrade) "Rebuild Haskell packages after a GHC upgrade."+ , Option [] ["all"] (NoArg RebuildAll)+ "Rebuild all Haskell libraries built with current GHC." , Option ['P'] ["package-manager"] (ReqArg PM "PM") $ "Use package manager PM, where PM can be one of:\n" ++ pmList ++ defPM
haskell-updater.cabal view
@@ -1,6 +1,6 @@ Name: haskell-updater Homepage: http://haskell.org/haskellwiki/Gentoo#haskell-updater-Version: 1.1.1.0+Version: 1.1.2.0 Synopsis: Rebuild Haskell dependencies in Gentoo Description: haskell-updater rebuilds Haskell packages on Gentoo after a GHC upgrade or a dependency upgrade.