Permalink
Browse files

clean up tarball preparation

remove Build.hs - it did all its work by shelling out anyway, so just move that stuff into prepare.sh
remove GenInports.hs - not used
clean up of prepare.sh
extract core.packages from .cabal file, rather than have to hand prepare it
  • Loading branch information...
mzero committed Oct 16, 2012
1 parent 25ad02d commit 160711da5628797e0ae34c61356d3f78e402d12a
Showing with 31 additions and 234 deletions.
  1. +2 −1 NOTES-2012.4.0.0
  2. +0 −2 RELEASE
  3. +7 −0 haskell-platform.cabal
  4. +0 −159 src/generic/Build.hs
  5. +0 −64 src/generic/GenImports.hs
  6. +22 −8 src/generic/prepare.sh
View
@@ -28,7 +28,8 @@
TODO
----
-[] update vector and primitive versions
+[x] update vector and primitive versions
+[x] remove Build.hs - it did all its work by shelling out anyway!
[] main .cabal file should not have versions commented out
[] this will require a separate list of packages that need
to be part of the source release
View
@@ -41,7 +41,6 @@ T0
| xargs grep -i version: | grep -v -i cabal-version
[] update haskell-platform.cabal
- [] update src/generic/tarball/packages/core.packages
* External libraries to latest stable version
* set up to build macos, and run
@@ -61,7 +60,6 @@ T0
* check and follow up on changes to visible packages.
* check unix package builds
- * tarball/packages/core.packages has to be updated from .cabal file
* update configure.ac with version number
* update required GHC version
* bump version number in .cabal file
View
@@ -31,6 +31,7 @@ library
-- Core libraries: provided by every ghc installation
-- We don't include "non-API" packages here.
+ -- begin core packages
-- array ==0.4.0.0,
-- base ==4.5.1.0,
-- bytestring ==0.9.2.1,
@@ -50,10 +51,12 @@ library
-- template-haskell ==2.7.0.0,
-- time ==1.4,
-- unix ==2.5.1.1,
+ -- end core packages
-- Win32 ==2.2.2.0,
-- Libraries in addition to what GHC provides:
-- Note: newer versions of cgi need monad-catchio.
+ -- begin platform packages
async ==2.0.1.3,
cgi ==3001.1.7.4,
fgl ==5.4.2.4,
@@ -91,6 +94,10 @@ library
cabal-install ==0.14.0,
alex ==3.0.2,
happy ==1.18.10
+ -- end platform packages
-- hscolour ==1.19 -- ???
-- haddock ==2.11.0 -- need to use the one shipped with ghc
+-- N.B.: The begin/end comment annocations are used to build the source
+-- installer: Packages that are part of the core are checked at build time.
+-- Source of packages that are part of the platform are included in the tarball.
View
@@ -1,159 +0,0 @@
-{-
--- Given a .cabal file with the platform specification, generate a tree in
--- hackage format, with a 00-index.tgz file, so that cabal-install will be
--- able to treat the local tree as a db.
--}
-
-import Data.List hiding (intercalate)
-import System.Directory
-import Control.Monad
-import System.IO
-import System.FilePath
-import qualified Data.ByteString.Lazy as BS
-import qualified Data.ByteString.Lazy.Char8 as BS.Char8
-import qualified Control.Exception as C
-import System.IO.Error (isDoesNotExistError)
-import Data.Monoid
-import Data.Maybe
-import System.Environment
-
--- cabal-install
--- import qualified Tar as Tar
--- import Types
-
-import Distribution.Package ( PackageIdentifier(..), Package(..) , Dependency(Dependency) )
-import Distribution.PackageDescription.Parse
-import Distribution.Version
-import Distribution.Simple.Utils
-import Distribution.Simple.PackageIndex
-import Distribution.PackageDescription.Configuration
-import Distribution.PackageDescription hiding (packageDescription)
-import Distribution.Verbosity
-import Distribution.Text ( display, simpleParse )
-import qualified Distribution.Simple.PackageIndex as PackageIndex
-import System.Cmd
-import System.FilePath
-
--- import Network.Curl.Download.Lazy
-
-main = do
- [cabalpath,outdir] <- getArgs
-
- pwd <- getCurrentDirectory
- setCurrentDirectory outdir
-
- let cabal = pwd </> cabalpath
-
-
- cabalsrc <- readPackageDescription normal cabal
- let final = flattenPackageDescription cabalsrc
- dependencies = buildDepends final ++
- concatMap buildTools (allBuildInfo final)
-
- -- relies on the fact that meta cabal package is a simple list of
- -- dependencies and versions. nothing suss.
- --
- let urls =
- [ (d, display name ++ "-" ++ display vers)
- | d@(Dependency name (ThisVersion vers)) <- dependencies ]
-
- forM_ urls $ \(dep@(Dependency name vers), package) -> do
- system $ "cabal unpack " ++ package
-
-
- --
- -- Too sleepy. Future: solve this via the cabal library
- --
- let cmd = "cabal install --dry-run --reinstall " ++ (
- intercalate " " [ package
- | (_, package) <- urls
- ] ) ++ " > platform.packages.raw"
- --writeFile "platform.packages.cmd" cmd
- system cmd
- src <- readFile "platform.packages.raw"
-
- let programs = drop 2 $ lines src
- writeFile "platform.packages" (unlines programs)
-
- removeFile "platform.packages.raw"
- setCurrentDirectory pwd
-
-------------------------------------------------------------------------
-
-{-
- e <- openLazyURI url
- case e of
- Left err -> error $ "Unable to download " ++ show url ++ ": " ++ show err
- Right s -> do createDirectory name
- createDirectory (name </> display vers)
- BS.writeFile (name </> display vers </>
- (name ++ "-" ++ display vers ++ ".tar.gz")) s
--}
-
-{-
- home <- getHomeDirectory
- let index = home </> ".cabal/packages/hackage.haskell.org"
- x <- readRepoIndex index
- print x
--}
-
-
--- lookupDependency :: Package pkg => PackageIndex pkg -> Dependency
-
- -- -> [pkg]
-
-------------------------------------------------------------------------
--- Stolen from cabal-install
-
-{-
--- | Read a repository index from disk, from the local file specified by
--- the 'Repo'.
---
-readRepoIndex :: FilePath -> IO (PackageIndex AvailablePackage)
-readRepoIndex path =
- handleNotFound $ do
- let indexFile = repoLocalDir path </> "00-index.tar"
- pkgs <- either fail return . parseRepoIndex =<< BS.readFile indexFile
- C.evaluate (PackageIndex.fromList pkgs)
-
- where
- -- | Parse a repository index file from a 'ByteString'.
- --
- -- All the 'AvailablePackage's are marked as having come from the given 'Repo'.
- --
- parseRepoIndex :: BS.ByteString -> Either String [AvailablePackage]
- parseRepoIndex = either Left (Right . catMaybes . map extractPkg)
- . check [] . Tar.read
-
- check _ (Tar.Fail err) = Left err
- check ok Tar.Done = Right ok
- check ok (Tar.Next e es) = check (e:ok) es
-
- extractPkg :: Tar.Entry -> Maybe AvailablePackage
- extractPkg entry
- | takeExtension fileName == ".cabal"
- = case splitDirectories (normalise fileName) of
- [pkgname,vers,_] -> case simpleParse vers of
- Just ver -> Just AvailablePackage {
- packageInfoId = PackageIdentifier ({-PackageName-} pkgname) ver,
- packageDescription = descr,
- packageSource = RepoTarballPackage path
- }
- _ -> Nothing
- where
- parsed = parsePackageDescription . fromUTF8 . BS.Char8.unpack
- . Tar.fileContent $ entry
- descr = case parsed of
- ParseOk _ d -> d
- _ -> error $ "Couldn't read cabal file "
- ++ show fileName
- _ -> Nothing
- | otherwise = Nothing
- where
- fileName = Tar.fileName entry
-
- handleNotFound action = catch action $ \e -> if isDoesNotExistError e
- then return mempty
- else ioError e
-
--}
View
@@ -1,64 +0,0 @@
-{-
--- Given a .cabal file with the platform specification, generate a tree in
--- hackage format, with a 00-index.tgz file, so that cabal-install will be
--- able to treat the local tree as a db.
--}
-
-import Data.List hiding (intercalate)
-import System.Directory
-import Control.Monad
-import System.IO
-import System.FilePath
-import qualified Data.ByteString.Lazy as BS
-import qualified Data.ByteString.Lazy.Char8 as BS.Char8
-import qualified Control.Exception as C
-import System.IO.Error (isDoesNotExistError)
-import Data.Monoid
-import Data.Maybe
-import System.Environment
-
--- cabal-install
--- import qualified Tar as Tar
--- import Types
-
-import Distribution.Package ( PackageIdentifier(..), Package(..) , Dependency(Dependency) )
-import Distribution.PackageDescription.Parse
-import Distribution.Version
-import Distribution.Simple.Utils
-import Distribution.Simple.PackageIndex
-import Distribution.PackageDescription.Configuration
-import Distribution.PackageDescription hiding (packageDescription)
-import Distribution.Verbosity
-import Distribution.Text ( display, simpleParse )
-import qualified Distribution.Simple.PackageIndex as PackageIndex
-import System.Cmd
-import System.FilePath
-
--- import Network.Curl.Download.Lazy
-
-main = do
- [cabalpath] <- getArgs
- pwd <- getCurrentDirectory
-
- let cabal = pwd </> cabalpath
-
- cabalsrc <- readPackageDescription normal cabal
- let final = flattenPackageDescription cabalsrc
- dependencies = buildDepends final ++
- concatMap buildTools (allBuildInfo final)
-
- -- relies on the fact that meta cabal package is a simple list of
- -- dependencies and versions. nothing suss.
- --
- let urls =
- [ (d, display name ++ "/" ++ display vers)
- | d@(Dependency name (ThisVersion vers)) <- dependencies ]
-
- forM_ urls $ \(dep@(Dependency name vers), package) -> do
- system $ "lscabal " ++
- "http://hackage.haskell.org/packages/archive/" ++ package ++ "/" ++ display name ++ ".cabal"
-
--- http://hackage.haskell.org/packages/archive/suffixarray/0.0.1/suffixarray.cabal
-
- setCurrentDirectory pwd
-
View
@@ -1,8 +1,9 @@
#!/bin/sh
TOP=../..
+HP_CABAL=${TOP}/haskell-platform.cabal
-PLATFORM_VERSION=$(grep '^version:' ${TOP}/haskell-platform.cabal | sed -e 's/version://' -e 's/ //g')
+PLATFORM_VERSION=$(grep '^version:' ${HP_CABAL} | sed -e 's/version://' -e 's/ //g')
IMAGE_DIR="haskell-platform-${PLATFORM_VERSION}"
die () {
@@ -12,6 +13,12 @@ die () {
exit 2
}
+packageIDs () {
+ sed -n -e "/begin $1/,/end $1/p" "${HP_CABAL}" \
+ | grep '==' \
+ | sed -e 's/^[ -]*\([^ ]*\) *==\([0-9.]*\).*/\1-\2/'
+}
+
which cabal > /dev/null 2>&1 || die "The prepare script needs the cabal program"
echo "Preparing a tarball for ${IMAGE_DIR}"
@@ -21,17 +28,24 @@ mkdir "${IMAGE_DIR}/"
mkdir "${IMAGE_DIR}/packages"
mkdir "${IMAGE_DIR}/scripts"
-ghc --make Build.hs
-./Build ../../haskell-platform.cabal "${IMAGE_DIR}/packages" \
- || die "Build.hs failed"
+SRC_PKGS=$(packageIDs platform)
+for pkg in ${SRC_PKGS}
+do
+ (cd "${IMAGE_DIR}/packages" && cabal unpack $pkg)
+done
+
+cabal install --dry-run --reinstall ${SRC_PKGS} \
+ | tail +3 > "${IMAGE_DIR}/packages/platform.packages"
+
PLATFORM_PACKAGE_ID="haskell-platform-${PLATFORM_VERSION}"
echo ${PLATFORM_PACKAGE_ID} >> "${IMAGE_DIR}/packages/platform.packages"
-mkdir "${IMAGE_DIR}/packages/${PLATFORM_PACKAGE_ID}"
-cp "${TOP}/haskell-platform.cabal" "${TOP}/Setup.hs" "${TOP}/LICENSE" \
- "${IMAGE_DIR}/packages/${PLATFORM_PACKAGE_ID}"
+HP_PKG_DIR="${IMAGE_DIR}/packages/${PLATFORM_PACKAGE_ID}"
+mkdir "${HP_PKG_DIR}"
+cp "${HP_CABAL}" "${TOP}/Setup.hs" "${TOP}/LICENSE" "${HP_PKG_DIR}"
+
+packageIDs core > "${IMAGE_DIR}/packages/core.packages"
-cp tarball/packages/core.packages "${IMAGE_DIR}/packages/"
cp tarball/scripts/*.sh "${IMAGE_DIR}/scripts/"
cp tarball/scripts/config.* "${IMAGE_DIR}/scripts/"
cp tarball/configure.ac tarball/aclocal.m4 tarball/Makefile "${IMAGE_DIR}/"

0 comments on commit 160711d

Please sign in to comment.