archlinux 0.2.1 → 0.2.2
raw patch · 3 files changed
+48/−28 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Distribution.ArchLinux.Report: myReadProcess :: FilePath -> [String] -> String -> IO (Either (ExitCode, String, String) String)
+ Distribution.ArchLinux.Report: loadPackageIndex :: IO (Map String Version)
Files
- Distribution/ArchLinux/Report.hs +43/−25
- archlinux.cabal +3/−2
- scripts/arch-report.hs +2/−1
Distribution/ArchLinux/Report.hs view
@@ -1,7 +1,9 @@ {-# LANGUAGE FlexibleInstances #-} -- | Construct reports about a set of packages in AUR ---module Distribution.ArchLinux.Report where+module Distribution.ArchLinux.Report (+ report , loadPackageIndex+ ) where import Distribution.ArchLinux.AUR import Distribution.ArchLinux.PkgBuild@@ -34,6 +36,7 @@ import Control.Parallel.Strategies import Distribution.Version+import qualified Data.Map as M instance NFData (IO a) where rnf x = () @@ -41,7 +44,8 @@ instance NFData AURInfo where rnf x = x `seq` () instance NFData AnnotatedPkgBuild where rnf x = x `seq` () --- Parallel work queue+-- Parallel work queue, similar to forM+-- parM tests f = do let n = numCapabilities chan <- newChan@@ -74,16 +78,20 @@ loop --- | Take as input a list of package names, return a pandoc object--- reporting on interesting facts about the packages.+-- | Take as input a list of package names, return an html page+-- with interesting facts about the state of the packages. -- report :: [String] -> IO String report xs = do+ -- load current index.+ putStr "Loading package index ... " >> hFlush stdout+ index <- loadPackageIndex+ putStrLn "Done."+ -- collect sets of results res_ <- parM (nub xs) $ \p -> do handle (\s -> return (p, Nothing, (Left (show s), Left []))) $ do k <- package p- k `seq` return () -- if there is a hackage path, lookup version. -- cabal info xmonad -v0@@ -91,25 +99,14 @@ (Right aur, _) | not (null (packageURL aur)) -> do let name = takeFileName (packageURL aur) -- haskell package name- v <- myReadProcess "cabal" ["info","-v0",name] []- return $! case v of- Left _ -> Nothing- Right s -> let v = reverse- . takeWhile (not . isSpace )- . reverse- . (\k -> case find ("Latest version available" `isInfixOf`) k of- Nothing -> []- Just n -> n )- $ lines s-- in simpleParse v+ return $! M.lookup name index _ -> return Nothing - return (p, vers, k)+ vers `seq` k `seq` return $! (p, vers, k) time <- getClockTime - let results = sortBy (\(n,x,_) (m,y,_) -> x `seq` y `seq` n `compare` m) res_+ let results = sortBy (\(n,x,_) (m,y,_) -> n `compare` m) res_ return. showHtml $ (header $@@ -190,6 +187,7 @@ ] -- Found everything+ -- TODO parallelise this and remove redundancies Right pkg -> [ td . toHtml $ hotlink@@ -241,11 +239,6 @@ ) ) -- {-- (Right (AURInfo {packageID = 17480, packageName = "haskell-json", packageVersion = Right (Version {versionBranch = [0,4,3], versionTags = []},"1"), packageCategory = 10, packageDesc = "Support for serialising Haskell to and from JSON", packageLocation = 2, packageURL = "http://hackage.haskell.org/cgi-bin/hackage-scripts/package/json", packagePath = "/packages/haskell-json/haskell-json.tar.gz", packageLicense = "custom:BSD3", packageVotes = 16, packageOutOfDate = False}),Right (AnnotatedPkgBuild {pkgBuiltWith = Just (Version {versionBranch = [0,5,3], versionTags = []}), pkgHeader = "# Contributor: Arch Haskell Team <arch-haskell@haskell.org>", pkgBody = PkgBuild {arch_pkgname = "haskell-json", arch_pkgver = Version {versionBranch = [0,4,3], versionTags = []}, arch_pkgrel = 1, arch_pkgdesc = "\"Support for serialising Haskell to and from JSON\"", arch_arch = ArchList [Arch_X86,Arch_X86_64], arch_url = "\"http://hackage.haskell.org/cgi-bin/hackage-scripts/package/json\"", arch_license = ArchList [BSD3], arch_makedepends = ArchList [], arch_depends = ArchList [], arch_source = ArchList [], arch_md5sum = ArchList [], arch_build = [], arch_install = Nothing, arch_options = ArchList []}}))- -}- categoryTag x = thediv x ! [identifier "Category" ] bad x = thediv x ! [identifier "Bad" ] good x = thediv x ! [identifier "Best" ]@@ -253,7 +246,6 @@ ------------------------------------------------------------------------- -- -- Strict process reading --@@ -288,4 +280,30 @@ where handler (C.ExitException e) = Left (e,"","") handler e = Left (ExitFailure 1, show e, "")++------------------------------------------------------------------------+--+-- | Load a table of packag names associated with their latest versions+--+loadPackageIndex :: IO (M.Map String Version)+loadPackageIndex = do+ v <- myReadProcess "cabal" ["list", "--simple-output"] []+ case v of+ Left err -> error (show err)+ Right idx -> do++ let table :: M.Map String Version+ table = M.fromList -- last value is used. cabal prints in version order.+ [ (name, vers)+ | pkg <- lines idx+ , let (name, _:vers_) = break isSpace pkg+ , let vers = fromJust (simpleParse vers_)+ ]++ return $! table++ -- Data.Map String Version+ --++
archlinux.cabal view
@@ -1,5 +1,5 @@ name: archlinux-version: 0.2.1+version: 0.2.2 license: BSD3 license-file: LICENSE author: Don Stewart <dons@galois.com>@@ -17,7 +17,8 @@ . > search "xmonad" .- Check status of a list of packages against AUR and Hackage:+ Generate an html page of interesting facts about + packages in AUR and Hackage. . > report ["xmonad"] .
scripts/arch-report.hs view
@@ -5,5 +5,6 @@ main = do s <- lines `fmap` readFile "arch-haskell-packages.txt"- writeFile "/tmp/x.html" =<< report s+ writeFile "/tmp/arch-haskell-status.html.html" =<< report s+ putStrLn "Now: scp /tmp/arch-haskell-status.html.html galois.com:www/"