@@ -18,11 +18,11 @@ import Distribution.Version (thisVersion)
18import Stackage.Types
18import Stackage.Types
19import System.Directory (doesDirectoryExist,
19import System.Directory (doesDirectoryExist,
20 removeDirectoryRecursive)
20 removeDirectoryRecursive)
21−import System.Directory (getAppUserDataDirectory)
21+import System.Directory (getAppUserDataDirectory
22−import System.Directory (canonicalizePath,
22+ ,canonicalizePath,
23− createDirectoryIfMissing)
23+ createDirectoryIfMissing, doesFileExist)
24import System.Environment (getEnvironment)
24import System.Environment (getEnvironment)
25−import System.FilePath ((</>))
25+import System.FilePath ((</>), (<.>))
27-- | Allow only packages with permissive licenses.
27-- | Allow only packages with permissive licenses.
28allowPermissive :: [String] -- ^ list of explicitly allowed packages
28allowPermissive :: [String] -- ^ list of explicitly allowed packages
@@ -148,3 +148,16 @@ fixBuildSettings settings' = do
148 createDirectoryIfMissing True root'
148 createDirectoryIfMissing True root'
149 root <- canonicalizePath root'
149 root <- canonicalizePath root'
150 return settings' { sandboxRoot = root }
150 return settings' { sandboxRoot = root }
152+-- | Check if a tarball exists in the tarball directory and, if so, use that
153+-- instead of the given name.
154+replaceTarball :: BuildSettings
157+replaceTarball bs pkgname = do
158+ exists <- doesFileExist fp
160+ then canonicalizePath fp
163+ fp = tarballDir bs </> pkgname <.> "tar.gz"