Browse Source

Allow a directory of replacement tarballs

fpco
Michael Snoyman 9 years ago
parent
commit
574ba0ba04
  1. 6
      Stackage/Build.hs
  2. 3
      Stackage/Test.hs
  3. 2
      Stackage/Types.hs
  4. 21
      Stackage/Util.hs

6
Stackage/Build.hs

@ -25,6 +25,7 @@ defaultBuildSettings version = BuildSettings
, extraArgs = const ["-fnetwork23"]
, testWorkerThreads = 4
, buildDocs = True
, tarballDir = "patching/tarballs"
}
build :: BuildSettings -> BuildPlan -> IO ()
@ -72,6 +73,7 @@ build settings' bp = do
putStrLn "Beginning Stackage build"
ph <- withBinaryFile "build.log" WriteMode $ \handle -> do
packageList <- mapM (replaceTarball settings) $ bpPackageList bp
let args = addCabalArgs settings BSBuild
$ "install"
: ("--cabal-lib-version=" ++ libVersion)
@ -79,9 +81,7 @@ build settings' bp = do
: "--max-backjumps=-1"
: "--reorder-goals"
: "-j"
: concat
[ bpPackageList bp
]
: packageList
hPutStrLn handle ("cabal " ++ unwords (map (\s -> "'" ++ s ++ "'") args))
runCabal args handle
ec <- waitForProcess ph

3
Stackage/Test.hs

@ -97,7 +97,8 @@ runTestSuite settings testdir (packageName, SelectedPackageInfo {..}) = do
runGhcPackagePath = runGen True
passed <- handle (\TestException -> return False) $ do
getHandle WriteMode $ run "cabal" ["unpack", package] testdir
package' <- replaceTarball settings package
getHandle WriteMode $ run "cabal" ["unpack", package'] testdir
getHandle AppendMode $ run "cabal" (addCabalArgs settings BSTest ["configure", "--enable-tests"]) dir
when spiHasTests $ do
getHandle AppendMode $ run "cabal" ["build"] dir

2
Stackage/Types.hs

@ -132,6 +132,8 @@ data BuildSettings = BuildSettings
-- ^ How many threads to spawn for running test suites.
, buildDocs :: Bool
-- ^ Build docs as part of the test procedure.
, tarballDir :: FilePath
-- ^ Directory containing replacement tarballs.
}
-- | A wrapper around a @Map@ providing a better @Monoid@ instance.

21
Stackage/Util.hs

@ -18,11 +18,11 @@ import Distribution.Version (thisVersion)
import Stackage.Types
import System.Directory (doesDirectoryExist,
removeDirectoryRecursive)
import System.Directory (getAppUserDataDirectory)
import System.Directory (canonicalizePath,
createDirectoryIfMissing)
import System.Directory (getAppUserDataDirectory
,canonicalizePath,
createDirectoryIfMissing, doesFileExist)
import System.Environment (getEnvironment)
import System.FilePath ((</>))
import System.FilePath ((</>), (<.>))
-- | Allow only packages with permissive licenses.
allowPermissive :: [String] -- ^ list of explicitly allowed packages
@ -148,3 +148,16 @@ fixBuildSettings settings' = do
createDirectoryIfMissing True root'
root <- canonicalizePath root'
return settings' { sandboxRoot = root }
-- | Check if a tarball exists in the tarball directory and, if so, use that
-- instead of the given name.
replaceTarball :: BuildSettings
-> String
-> IO String
replaceTarball bs pkgname = do
exists <- doesFileExist fp
if exists
then canonicalizePath fp
else return pkgname
where
fp = tarballDir bs </> pkgname <.> "tar.gz"

Loading…
Cancel
Save