Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ready to download everything

  • Loading branch information...
commit 46158afaf134e3f8be2ad1a5412a199fce7cbb85 1 parent 583c0bb
@phischu authored
Showing with 22 additions and 8 deletions.
  1. +22 −8 Master.hs
View
30 Master.hs
@@ -6,8 +6,11 @@ import Development.Shake.FilePath
import Development.Shake.Classes
import qualified System.Directory as IO
+import qualified Data.Map as M
+import Distribution.Text
+
+import Distribution.Hackage.DB (readHackage')
-import Paths
newtype Package = Package (Name,Version) deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
type Name = String
@@ -16,6 +19,7 @@ type Version = String
newtype ExtractedPackage = ExtractedPackage Package deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
newtype PackageArchive = PackageArchive Package deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
newtype PackageList = PackageList [Package] deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
+newtype GetPackageList = GetPackageList () deriving (Show,Typeable,Eq,Hashable,Binary,NFData)
instance Rule ExtractedPackage () where
storedValue (ExtractedPackage (Package (name,version))) = do
@@ -27,8 +31,8 @@ instance Rule PackageArchive () where
exists <- IO.doesFileExist (archiveDirectory package)
if exists then return (Just ()) else return Nothing
-instance Rule () PackageList where
- storedValue () = return Nothing
+instance Rule GetPackageList PackageList where
+ storedValue (GetPackageList ()) = return Nothing
extractedDirectory :: FilePath
extractedDirectory = "Packages/"
@@ -40,13 +44,17 @@ packageUrl :: Package -> String
packageUrl (Package (name,version)) = concat ["hackage.haskell.org/packages/archive/",name,"/",version,"/",name,"-",version,".tar.gz"]
main :: IO ()
-main = shake shakeOptions {shakeThreads = 4} $ do
+main = shakeArgs shakeOptions {shakeThreads = 10} $ do
action (do
- PackageList packages <- apply1 ()
+ PackageList packages <- apply1 (GetPackageList ())
apply (map ExtractedPackage packages) :: Action [()])
- rule (\() -> Just (return (PackageList [Package ("aeson-lens","0.1.0.2")])))
+ rule (\(GetPackageList ()) -> Just (do
+ need ["00-index.tar"]
+ hackage <- liftIO (readHackage' "00-index.tar")
+ let packages = [Package (name,show (disp version))| name <- M.keys hackage, version <- M.keys (hackage M.! name)]
+ return (PackageList (every 1 packages))))
rule (\(ExtractedPackage package) -> Just $ do
liftIO (IO.createDirectoryIfMissing True extractedDirectory)
@@ -55,12 +63,18 @@ main = shake shakeOptions {shakeThreads = 4} $ do
rule (\(PackageArchive package) -> Just $ do
liftIO (IO.createDirectoryIfMissing True (takeDirectory (archiveDirectory package)))
- system' "wget" ["-O",archiveDirectory package,packageUrl package])
+ system' "wget" ["-nv","-O",archiveDirectory package,packageUrl package])
- return ()
+ "00-index.tar" *> (\out -> do
+ system' "wget" ["-nv","hackage.haskell.org/packages/archive/00-index.tar.gz"]
+ system' "gunzip" ["-f","00-index.tar.gz"])
+ return ()
+every :: Int -> [a] -> [a]
+every nth [] = []
+every nth xs = head xs : every nth (drop nth xs)
Please sign in to comment.
Something went wrong with that request. Please try again.