Generate platform version comparision page
authorJoachim Breitner <mail@joachim-breitner.de>
Sat, 9 Oct 2010 10:33:53 +0000 (10:33 +0000)
committerJoachim Breitner <mail@joachim-breitner.de>
Sat, 9 Oct 2010 10:33:53 +0000 (10:33 +0000)
Main.hs
PlatformOutput.hs [new file with mode: 0644]
Types.hs
runhpvt.sh

diff --git a/Main.hs b/Main.hs
index 43d8442..b2a5052 100644 (file)
--- a/Main.hs
+++ b/Main.hs
@@ -2,15 +2,22 @@ import Data.Maybe
 import Data.List
 import qualified Data.Map as M
 import System.Time
+import Control.Applicative ((<$>))
+
+import Distribution.PackageDescription.Parse
+import Distribution.PackageDescription.Configuration
+import Distribution.Verbosity
 
 import Hackage as H
 import Debian as D
 
 import HTMLOutput
 import CabalDebianMap
+import PlatformOutput
 import Types
 import Utils
 
+
 main = do 
        putStrLn "Haskell Package Version Tracker"
 
@@ -23,6 +30,10 @@ main = do
        debian_squeeze <- D.readFile "Sources.squeeze" "squeeze" hackage
        putStrLn $ "Read " ++ show (M.size debian_squeeze) ++ " packages from Debian (Squeeze)"
 
+        platform_2010_1_0_0 <- flattenPackageDescription <$> readPackageDescription normal "haskell-platform-2010.1.0.0.cabal"
+        platform_2010_2_0_0 <- flattenPackageDescription <$> readPackageDescription normal "haskell-platform-2010.2.0.0.cabal"
+        platform_darcs <- flattenPackageDescription <$> readPackageDescription normal "haskell-platform-darcs.cabal"
+        putStrLn $ "Read platform package descriptions"
        
        let combined = stopCombine $ startCombine (,,)
                                      `mapCombine` hackage
@@ -33,6 +44,14 @@ main = do
        time <- getClockTime
        writeFile "output.html" $ outputHTML combined time
        writeFile "cabalDebianMap.txt" $ outputCabalDebianMap combined
+        writeFile "platform.html" $ outputPlatform time hackage [
+                (platform_2010_1_0_0, [
+                    ("Squeeze", debian_squeeze),
+                    ("Unstable", debian_unstable)
+                ])
+                , (platform_2010_2_0_0, [])
+                -- , (platform_darcs, [])
+            ]
 
 
 
diff --git a/PlatformOutput.hs b/PlatformOutput.hs
new file mode 100644 (file)
index 0000000..feaa6d2
--- /dev/null
@@ -0,0 +1,84 @@
+module PlatformOutput (outputPlatform) where
+
+import Text.XHtml hiding (version)
+import qualified Data.Map as M
+import qualified Data.Set as S
+import Data.Maybe
+import System.Time
+
+import Distribution.Package hiding (PackageName)
+import Distribution.PackageDescription
+import Distribution.Text
+import Distribution.Version (VersionRange(ThisVersion))
+import Data.Version (showVersion)
+
+import Types
+
+outputPlatform :: (Show t) => t -> 
+ DistroInfo ->
+ [ (PackageDescription,[(String, M.Map PackageName Version)]) ] ->
+ String
+outputPlatform time hackage datas = showHtml $ page time << mkTable hackage datas
+
+myTitle = "Haskell Platform Version Tracker"
+
+page time content = thehtml << (header << thetitle << myTitle +++
+                          body << (
+                               h1 << myTitle +++
+                               p << ("Last update: " +++ show time) +++
+                               content +++
+                               footer))
+
+mkTable hackage datas = table << (
+               tr << (
+                    th << "Package name" +++
+                    concatHtml (map (\(p,dists) ->
+                        th << (display (pkgName (package p)) +++ br +++
+                               display (pkgVersion (package p))) +++
+                        concatHtml (map (\(name,_) ->
+                            th << name
+                        ) dists) +++
+                        th << " "
+                    ) datas) +++
+                    th << "Hackage"
+                ) +++
+               (concatHtml $ map row $ S.toList pkgs)
+               )
+  where buildDependsMap pd = M.fromList (map fromDep deps)
+          where fromDep (Dependency pkg (ThisVersion ver)) = (fromCabal pkg,ver)
+                fromDep d = error $ "Unexpected dependency format " ++ display d
+                deps = buildDepends pd ++ buildTools bi
+                bi = libBuildInfo (fromJust (library pd))
+        maps = map (\(p,dists) -> (buildDependsMap p,dists)) datas
+        pkgs = S.unions (map (M.keysSet . fst) maps)
+        
+
+        row pkg = tr << (
+                      td << show pkg +++
+                      concatHtml (map (\(pm,dists) ->
+                        case M.lookup pkg pm of
+                            Just ver -> 
+                                td << showVersion ver +++
+                                concatHtml (map (\(_,dm) -> case M.lookup pkg dm of
+                                    Just dver -> mkCell dver
+                                    Nothing -> none
+                                ) dists) +++
+                                emptyCell
+                            Nothing ->
+                                emptyCell +++
+                                concatHtml (map (const emptyCell) dists) +++
+                                emptyCell
+                      ) maps) +++
+                      case M.lookup pkg hackage of
+                        Just hver -> mkCell hver
+                        Nothing -> none
+                  )
+        mkCell (Version v u) = td << hotlink u << v
+       none = td << "–"
+        emptyCell = td << noHtml
+
+footer = p << ("This is created by " +++
+              hotlink "http://darcs.nomeata.de/hpvt/" << "hptv" +++
+              ", written by " +++
+              hotlink "mailto:mail@joachim-breitner.de" << "Joachim Breitner" +++
+              ". At the moment it is updated automatically every night.")
index 01b2216..22d1a34 100644 (file)
--- a/Types.hs
+++ b/Types.hs
@@ -1,9 +1,9 @@
-module Types (PackageName, DistroInfo, fromHackage, fromDebian, Version(..)) where
+module Types (PackageName, DistroInfo, fromHackage, fromDebian, fromCabal, Version(..)) where
 
 import Data.Char
 import qualified Data.Map as M
 
-
+import qualified Distribution.Package as D
 
 type DistroInfo = M.Map PackageName Version
 
@@ -26,3 +26,4 @@ instance Show PackageName where
 
 fromHackage = PN
 fromDebian = PN
+fromCabal (D.PackageName n) = PN n
index 108443f..40e690e 100644 (file)
@@ -12,4 +12,5 @@ wget -q http://hackage.haskell.org/platform/2010.2.0.0/haskell-platform.cabal -O
 
 ./hpvt >/dev/null
 mv output.html public_html/hackagevsdebian.html
+mv platform.html public_html/platform.html
 mv cabalDebianMap.txt public_html/cabalDebianMap.txt