packages feed

archlinux 0.2 → 0.2.1

raw patch · 4 files changed

+103/−13 lines, 4 filesdep +old-timedep +paralleldep +strict-concurrencyPVP ok

version bump matches the API change (PVP)

Dependencies added: old-time, parallel, strict-concurrency

API changes (from Hackage documentation)

+ Distribution.ArchLinux.Report: instance NFData (IO a)
+ Distribution.ArchLinux.Report: instance NFData AURInfo
+ Distribution.ArchLinux.Report: instance NFData AnnotatedPkgBuild
+ Distribution.ArchLinux.Report: instance NFData Version

Files

Distribution/ArchLinux/Report.hs view
@@ -1,4 +1,4 @@-+{-# LANGUAGE FlexibleInstances #-} -- | Construct reports about a set of packages in AUR -- module Distribution.ArchLinux.Report where@@ -22,21 +22,68 @@ import System.Environment import System.Exit import System.FilePath-import Control.Concurrent+import Control.Concurrent (forkIO)+import Control.Concurrent.Chan.Strict+import Control.Concurrent.MVar.Strict import qualified Control.OldException as C import System.IO import System.Process+import System.Time+import GHC.Conc (numCapabilities)+import Text.Printf+import Control.Parallel.Strategies +import Distribution.Version++instance NFData (IO a) where rnf x = ()++instance NFData Version where rnf x = x `seq` ()+instance NFData AURInfo where rnf x = x `seq` ()+instance NFData AnnotatedPkgBuild where rnf x = x `seq` ()++-- Parallel work queue+parM tests f = do+    let n = numCapabilities+    chan <- newChan+    ps   <- getChanContents chan -- results+    work <- newMVar tests        -- where to take jobs from+    forM_ [1..n] $ forkIO . thread work chan    -- how many threads to fork++    -- wait on i threads to close+    -- logging them as they go+    let wait xs i acc+            | i >= n     = return acc -- done+            | otherwise = case xs of+                    Nothing     : xs -> wait xs (i+1) acc+                    Just (s,a)  : xs -> do a ; wait xs i     (s : acc)+    wait ps 0 []++  where+    -- thread :: MVar [Test] -> Chan (Maybe String) -> Int -> IO ()+    thread work chan me = loop+      where+        loop = do+            job <- modifyMVar work $ \jobs -> return $ case jobs of+                        []     -> ([], Nothing)+                        (j:js) -> (js, Just j)+            case job of+                Nothing   -> writeChan chan Nothing -- done+                Just name -> do+                    v <- f name+                    writeChan chan . Just $ (v, printf "%d: %-25s\n" me name)+                    loop++ -- | Take as input a list of package names, return a pandoc object -- reporting on interesting facts about the packages. -- report :: [String] -> IO String report xs = do     -- collect sets of results-    res_ <- forM xs $ \p -> do+    res_ <- parM (nub xs) $ \p -> do         handle (\s -> return (p, Nothing, (Left (show s), Left []))) $ do-            putStrLn $ "Retrieving " ++ p             k <- package p+            k `seq` return ()              -- if there is a hackage path, lookup version.             --  cabal info xmonad -v0@@ -60,8 +107,10 @@              return (p, vers, k) -    let results = sortBy (\(n,_,_) (m,_,_) -> n `compare` m) res_+    time <- getClockTime +    let results = sortBy (\(n,x,_) (m,y,_) -> x `seq` y `seq` n `compare` m) res_+     return. showHtml $         (header $             (thetitle (toHtml "Arch Haskell Package Report")) +++@@ -72,7 +121,12 @@         (body $             center ((h2 (toHtml "Arch Haskell Package Status")))             +++-+            (table $+                (tr (td (toHtml $ "Results from " ++ show time)))+                ++++                (tr (td (toHtml $ "Found  " ++ show (length results) ++ " packages" )))+            )+            +++             (scores . table $                 tr (concatHtml                       [ td . categoryTag . toHtml $ "Package"@@ -117,13 +171,16 @@                           , td  $                                case vers of+                                   Nothing | packageLocation aur == 3 -> toHtml ""                                    Nothing -> bad (toHtml "-")                                    Just v  -> case packageVersion aur of                                      Left s  -> toHtml (display v)                                      Right (v',_) | v == v' -> toHtml (display v)                                                  | otherwise -> bad (toHtml (display v)) -                          , td $ bad (toHtml "PKGBUILD not found")+                          , td $ if packageLocation aur /= 3+                                    then bad (toHtml "PKGBUILD not found")+                                    else toHtml ""                            , td  $ if packageVotes aur > 10                                      then good $ toHtml $ show $ packageVotes aur@@ -152,6 +209,7 @@                            , td  $                               case vers of+                                   Nothing | packageLocation aur == 3 -> toHtml ""                                    Nothing -> bad (toHtml "-")                                    Just v  -> case packageVersion aur of                                      Left s  -> toHtml (display v)
archlinux.cabal view
@@ -1,5 +1,5 @@ name:           archlinux-version:        0.2+version:        0.2.1 license:        BSD3 license-file:   LICENSE author:         Don Stewart <dons@galois.com>@@ -17,7 +17,13 @@                 .                 > search "xmonad"                 .+                Check status of a list of packages against AUR and Hackage:+                .+                > report ["xmonad"]+                .                 See also the cabal2arch tool <http://hackage.haskell.org/package/cabal2arch>+                for conversion between Hackage and AUR.+ build-type:     Simple stability:      experimental cabal-version:  >= 1.2.3@@ -33,7 +39,10 @@                     filepath,                     xhtml,                     process,-                    directory+                    directory,+                    parallel,+                    strict-concurrency,+                    old-time      exposed-modules:         Distribution.ArchLinux.AUR
scripts/arch-haskell-packages.txt view
@@ -1,3 +1,13 @@+xmonad+haskell-utf8-string+haskell-x11+gtk2hs+haskell-http+haskell-x11-xft+haskell-zlib+alex+pandoc+darcs addlicenseinfo agda-executable armada@@ -17,7 +27,7 @@ cabal2spec cabalgraph cap-change-monger+haskell-change-monger cheatsheet clevercss clustertools@@ -37,7 +47,6 @@ distract djinn doctest-drift ehaskell elerea-examples emping@@ -46,7 +55,6 @@ fallingblocks feed-cli flippi-flow2dot flower foo fquery@@ -1192,7 +1200,6 @@ minesweeper mkbndl mkcabal-modsplit mohws monadius mp3decoder@@ -1269,3 +1276,16 @@ yi zmachine ztail+haskell-data-object+haskell-yaml+haskell-rwlock+haskell-dbf+haskell-shapefile+haskell-file-embed+hums+haskell-monoids+hommage-ds+yst+haskell-binpack+haskell-pop3-client+haskell-xdg-basedir
scripts/arch-report.hs view
@@ -1,5 +1,8 @@ import Distribution.ArchLinux.Report +-- $ time ./arch-report +RTS -N4+-- compiled with -threaded.+ main = do     s <- lines `fmap` readFile "arch-haskell-packages.txt"     writeFile "/tmp/x.html" =<< report s