diff --git a/check-lts b/check-lts index e23566cc9..a36921589 100755 --- a/check-lts +++ b/check-lts @@ -2,11 +2,18 @@ # Convenience script for checking constraints locally +set -euxo pipefail + cd `dirname $0` -export GHCVER=$(sed -n "s/^ghc-version: \"\(.*\)\"/\1/p" "lts-build-constraints.yaml") +MAJOR=$1 +MINOR=$2 +LTS="lts-$MAJOR.$MINOR" + +echo "$MAJOR $MINOR $LTS" + +export GHCVER=$(sed -n "s/^ghc-version: \"\(.*\)\"/\1/p" "lts-$MAJOR-build-constraints.yaml") -LTS="lts-$@" curator update && curator constraints --target=$LTS && curator snapshot-incomplete --target=$LTS && diff --git a/etc/lts-constraints/src/Main.hs b/etc/lts-constraints/src/Main.hs index d58bb1c18..51cb9b320 100644 --- a/etc/lts-constraints/src/Main.hs +++ b/etc/lts-constraints/src/Main.hs @@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS -Wno-name-shadowing #-} module Main (main) where @@ -11,6 +12,8 @@ import RIO.Map (Map) import System.IO (openFile, IOMode (..), hFlush, hClose) import qualified Data.Text as T import qualified Data.Text.IO as T +import Safe (at) +import System.Environment (getArgs) import BuildConstraints (parsePackageDecl, handlePackage) import Snapshot (snapshotMap, loadSnapshot) @@ -19,8 +22,8 @@ import Types (PackageName, Version) src :: String src = "../../build-constraints.yaml" -target :: String -target = "../../lts-build-constraints.yaml" +target :: Int -> String +target major = "../../lts-" <> show major <> "-build-constraints.yaml" data State = LookingForLibBounds @@ -29,14 +32,18 @@ data State main :: IO () main = do - map <- snapshotMap <$> loadSnapshot "../../../stackage-snapshots/lts/22/0.yaml" - output <- openFile target WriteMode + args :: [String] <- getArgs + print args + let major :: Int = read . (`at` 0) $ args + map <- snapshotMap <$> loadSnapshot ("../../../stackage-snapshots/lts/" <> show major <> "/0.yaml") + output <- openFile (target major) WriteMode let putLine = liftIO . T.hPutStrLn output lines <- T.lines <$> T.readFile src void $ flip runStateT LookingForLibBounds $ do forM_ lines $ putLine <=< processLine map hFlush output hClose output + putStrLn $ "Done. Wrote to " <> (target major) processLine :: MonadState State m => Map PackageName Version -> Text -> m Text processLine map line = do diff --git a/lts-build-constraints.yaml b/lts-22-build-constraints.yaml old mode 100755 new mode 100644 similarity index 100% rename from lts-build-constraints.yaml rename to lts-22-build-constraints.yaml