Skip to content

Commit

Permalink
Version LTS file
Browse files Browse the repository at this point in the history
  • Loading branch information
bergmark committed Dec 22, 2023
1 parent 96f5874 commit f242352
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
11 changes: 9 additions & 2 deletions check-lts
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
15 changes: 11 additions & 4 deletions etc/lts-constraints/src/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS -Wno-name-shadowing #-}
module Main (main) where

Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down
File renamed without changes.

0 comments on commit f242352

Please sign in to comment.