Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
Fix for nightly (closes #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Jul 15, 2016
1 parent 105716c commit e23122c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
@@ -1,3 +1,7 @@
## 0.14.1.1

* Fix for latest nightly snapshot [#21](https://github.com/fpco/stackage-curator/issues/21)

## 0.14.1

* configure-args
Expand Down
7 changes: 5 additions & 2 deletions Stackage/CompleteBuild.hs
Expand Up @@ -33,7 +33,7 @@ import Stackage.BuildConstraints
import Stackage.BuildPlan
import Stackage.CheckBuildPlan
import Stackage.PerformBuild
import Stackage.Prelude hiding (threadDelay, getNumCapabilities)
import Stackage.Prelude hiding (threadDelay, getNumCapabilities, Concurrently (..), withAsync)
import Stackage.ServerBundle
import Stackage.UpdateBuildPlan
import Stackage.Upload
Expand Down Expand Up @@ -272,7 +272,7 @@ hackageDistro
hackageDistro planFile target = do
man <- newManager tlsManagerSettings
plan <- decodeFileEither planFile >>= either throwM return
ecreds <- tryIO $ readFile "/hackage-creds"
ecreds <- tryIO' $ readFile "/hackage-creds"
case map encodeUtf8 $ words $ decodeUtf8 $ either (const "") id ecreds of
[username, password] -> do
putStrLn $ "Uploading as Hackage distro: " ++ distroName
Expand Down Expand Up @@ -524,3 +524,6 @@ parMapM_ cnt f xs0 = do
-- | Check if the given target is already used in the Github repos
checkTargetAvailable :: Target -> IO ()
checkTargetAvailable = void . checkoutRepo

tryIO' :: IO a -> IO (Either IOException a)
tryIO' = try
7 changes: 5 additions & 2 deletions Stackage/GhcPkg.hs
Expand Up @@ -88,13 +88,16 @@ unregisterPackage log' onUnregister docDir flags ident@(PackageIdentifier name _
(CT.decodeUtf8
$= CT.lines
$= CL.mapMaybe parseLibraryDir
$= CL.mapM_ (void . tryIO . removeTree . FP.decodeString))
$= CL.mapM_ (void . tryIO' . removeTree . FP.decodeString))

void (readProcessWithExitCode
"ghc-pkg"
("unregister": flags ++ ["--force", unpack $ display name])
"")

void $ tryIO $ removeTree $ FP.decodeString $ docDir </> unpack (display ident)
void $ tryIO' $ removeTree $ FP.decodeString $ docDir </> unpack (display ident)
where
parseLibraryDir = fmap unpack . stripPrefix "library-dirs: "

tryIO' :: IO a -> IO (Either IOException a)
tryIO' = try
5 changes: 4 additions & 1 deletion Stackage/PackageIndex.hs
Expand Up @@ -194,7 +194,7 @@ ucfParse :: MonadIO m
-> UnparsedCabalFile
-> m SimplifiedPackageDescription
ucfParse root (UnparsedCabalFile name version fp lbs _entry) = liftIO $ do
eres <- tryIO $ fmap Store.decode $ readFile cache
eres <- tryIO' $ fmap Store.decode $ readFile cache
case eres of
Right (Right (Store.Tagged x)) -> return x
_ -> do
Expand All @@ -203,6 +203,9 @@ ucfParse root (UnparsedCabalFile name version fp lbs _entry) = liftIO $ do
writeFile cache $ Store.encode $ Store.Tagged x
return x
where
tryIO' :: IO a -> IO (Either IOException a)
tryIO' = try

-- location of the binary cache
cache = root </> "cache" </> (unpack $ decodeUtf8 $ B16.encode $ SHA256.hashlazy lbs)

Expand Down
18 changes: 12 additions & 6 deletions Stackage/PerformBuild.hs
Expand Up @@ -219,7 +219,7 @@ performBuild' pb@PerformBuild {..} = withBuildDir $ \builddir -> do
haddockFiles <- getHaddockFiles pb >>= newTVarIO
haddockDeps <- newTVarIO mempty

forM_ packageMap $ \pi -> void $ async $ singleBuild pb registeredPackages
forM_ packageMap $ \pi -> void $ Control.Concurrent.Async.async $ singleBuild pb registeredPackages
SingleBuild
{ sbSem = sem
, sbErrsVar = errsVar
Expand Down Expand Up @@ -554,7 +554,7 @@ singleBuild pb@PerformBuild {..} registeredPackages SingleBuild {..} = do
(childDir </> "dist" </> "doc" </> "html" </> unpack name)
(pbDocDir pb </> unpack namever)

enewPath <- tryIO
enewPath <- tryIO'
$ canonicalizePath
$ fromString
$ pbDocDir pb
Expand Down Expand Up @@ -684,7 +684,7 @@ maximumTestSuiteTime = 10 * 60 * 1000 * 1000 -- ten minutes
renameOrCopy :: FilePath -> FilePath -> IO ()
renameOrCopy src dest =
rename (fromString src) (fromString dest)
`catchIO` \_ -> copyDir src dest
`catchIO'` \_ -> copyDir src dest

copyBuiltInHaddocks :: FilePath -> IO ()
copyBuiltInHaddocks docdir = do
Expand Down Expand Up @@ -745,7 +745,7 @@ failureBS = "failure"

getPreviousResult :: PerformBuild -> ResultType -> PackageIdentifier -> IO PrevResult
getPreviousResult w x y = withPRPath w x y $ \fp -> do
eres <- tryIO $ readFile fp
eres <- tryIO' $ readFile fp
return $ case eres of
Right bs
| bs == successBS -> PRSuccess
Expand All @@ -761,7 +761,7 @@ deletePreviousResults :: PerformBuild -> PackageIdentifier -> IO ()
deletePreviousResults pb name =
forM_ [minBound..maxBound] $ \rt ->
withPRPath pb rt name $ \fp ->
void $ tryIO $ removeFile $ fromString fp
void $ tryIO' $ removeFile $ fromString fp

-- | Discover existing .haddock files in the docs directory
getHaddockFiles :: PerformBuild -> IO (Map Text FilePath)
Expand Down Expand Up @@ -855,7 +855,7 @@ createSetupHs dir name allowNewer = do
else return gpd'
let simple = buildType (packageDescription gpd) == Just Simple
when simple $ do
_ <- tryIO $ removeFile $ fromString setuplhs
_ <- tryIO' $ removeFile $ fromString setuplhs
writeFile setuphs $ asByteString "import Distribution.Simple\nmain = defaultMain\n"
return gpd
where
Expand All @@ -866,3 +866,9 @@ createSetupHs dir name allowNewer = do
-- | Strip all version bounds from a GenericPackageDescription
stripVersionBounds :: GenericPackageDescription -> GenericPackageDescription
stripVersionBounds = everywhere $ mkT $ \(Dependency name _) -> Dependency name anyVersion

tryIO' :: IO a -> IO (Either IOException a)
tryIO' = try

catchIO' :: IO a -> (IOException -> IO a) -> IO a
catchIO' = catch
3 changes: 1 addition & 2 deletions stackage-curator.cabal
@@ -1,5 +1,5 @@
name: stackage-curator
version: 0.14.1
version: 0.14.1.1
synopsis: Tools for curating Stackage bundles
description: Please see <http://www.stackage.org/package/stackage-curator> for a description and documentation.
homepage: https://github.com/fpco/stackage-curator
Expand Down Expand Up @@ -91,7 +91,6 @@ library
, cryptohash
, cryptohash-conduit
, resourcet
, stackage-install >= 0.1.1
, lucid
, store
, syb
Expand Down

0 comments on commit e23122c

Please sign in to comment.