5ROOT=$(cd $(dirname $0) ; pwd)
10# For nightly-YYYY-MM-DD, tag should be nightly
11# For lts-X.Y, tag should be ltsX
12SHORTNAME=$(echo $TARGET | cut -d- -f 1)
13if [ $SHORTNAME = "lts" ]
15 TAG=$(echo $TARGET | sed 's@^lts-\([0-9]*\)\.[0-9]*@lts\1@')
16 WORKDIR=$ROOT/work/$(echo $TARGET | sed 's@^lts-\([0-9]*\)\.[0-9]*@lts-\1@')
19 WORKDIR=$ROOT/work/$TAG
22#IMAGE=commercialhaskell/stackage:$TAG
23IMAGE=ghcr.io/commercialhaskell/stackage/build:$TAG
25PANTRY_DIR=$ROOT/work/stack/pantry
26STACK_DIR=$ROOT/work/stack
27DOT_STACKAGE_DIR=$ROOT/work/dot-stackage
28# ssh key is used for committing snapshots (and their constraints) to Github
39GITCONFIG=$ROOT/work/gitconfig
42 email = michael+stackage-build@fpcomplete.com
43 name = Stackage Build host
46HACKAGE_CREDS=$ROOT/work/hackage-creds
48function require_400_file {
51 echo File not found: "$1"
58require_400_file "$SSH_DIR/id_rsa"
59require_400_file "$HACKAGE_CREDS"
61mkdir -p $ROOT/work/bin
62BINDIR=$(cd $ROOT/work/bin ; pwd)
65rm -f curator stack *.bz2
67curl -L "https://github.com/commercialhaskell/curator/releases/download/commit-1ef870178f6a0544fe5a3fd23a83fc075aabd695/curator.bz2" | bunzip2 > curator
69echo -n "curator version: "
70docker run --rm -v $(pwd)/curator:/exe $IMAGE /exe --version
72curl -L https://github.com/commercialhaskell/stack/releases/download/v2.7.3/stack-2.7.3-linux-x86_64-bin > stack
74echo -n "stack version: "
75docker run --rm -v $(pwd)/stack:/exe $IMAGE /exe --version
78# We share pantry directory between snapshots while the other content in .stack
79# is stored separately (because e.g. Ubuntu releases between LTS and nightly
80# could differ). Also the order of binds is important.
81ARGS_COMMON="--rm -v $WORKDIR:$HOME/work -w $HOME/work -v $BINDIR/curator:/usr/bin/curator:ro -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -v $BINDIR/stack:/usr/bin/stack:ro -v $STACK_DIR:$HOME/.stack -v $PANTRY_DIR:$HOME/.stack/pantry"
82ARGS_PREBUILD="$ARGS_COMMON -u $USERID -e HOME=$HOME -v $DOT_STACKAGE_DIR:$HOME/.stackage"
83ARGS_BUILD="$ARGS_COMMON"
84# instance-data is an undocumented feature of S3 used by amazonka,
85# see https://github.com/brendanhay/amazonka/issues/271
86ARGS_UPLOAD="$ARGS_COMMON -u $USERID -e HOME=$HOME -v $HACKAGE_CREDS:/hackage-creds:ro -v $DOT_STACKAGE_DIR:$HOME/.stackage -v $SSH_DIR:$HOME/.ssh:ro -v $GITCONFIG:$HOME/.gitconfig:ro -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY -v $DOT_STACKAGE_DIR:/dot-stackage"
88# Make sure we actually need this snapshot. We only check this for LTS releases
89# since, for nightlies, we'd like to run builds even if they are unnecessary to
90# get early warning information of upcoming failures. (See the duplicate check
91# below for why this is safe.)
92if [ $SHORTNAME = "lts" ]
94 docker run $ARGS_UPLOAD $IMAGE /bin/bash -c "exec curator check-target-available --target $TARGET"
98# Determine the new build plan unless NOPLAN is set
100# * Update the package index (unless LTS)
102if [ "${NOPLAN:-}x" = "1x" ]
104 docker run $ARGS_PREBUILD $IMAGE /bin/bash -c "curator snapshot-incomplete --target $TARGET && curator snapshot"
105elif [ "${NOPLAN:-}x" = "2x" ]
107 docker run $ARGS_PREBUILD $IMAGE curator snapshot
108elif [ $SHORTNAME = "lts" ]
110 docker run $ARGS_PREBUILD $IMAGE /bin/bash -c "curator constraints --target $TARGET && curator snapshot-incomplete --target $TARGET && curator snapshot"
112 docker run $ARGS_PREBUILD $IMAGE /bin/bash -c "curator update && curator constraints --target $TARGET && curator snapshot-incomplete --target $TARGET && curator snapshot"
116# Do the rest of the pre-build actions:
118# * Check that the snapshot is valid
119# * Fetch and unpack all needed tarballs (the build step does not have write access to the tarball directory)
120docker run $ARGS_PREBUILD $IMAGE /bin/bash -c 'GHCVER=$(sed -n "s/^ghc-version: \(.*\)/\1/p" constraints.yaml) && stack setup ghc-$GHCVER --verbosity=error && stack exec --resolver=ghc-$GHCVER curator check-snapshot && curator unpack'
127# Now do the actual build. We need to first set the owner of the home directory
128# correctly, so we run the command as root, change owner, and then use sudo to
129# switch back to the current user
130docker run $ARGS_BUILD $IMAGE nice -n 15 /bin/bash -c "chown $USER $HOME && exec sudo -E -u $USER env \"HOME=$HOME\" \"PATH=\$PATH\" curator build --jobs $JOBS" 2>&1 | tee "$SHORTNAME-build.log"
132# Make sure we actually need this snapshot. We used to perform this check
133# exclusively before building. Now we perform it after as well for the case of
134# nightly, where we don't perform this check beforehand. This is also slightly
135# safer, in case someone else already uploaded a specific snapshot while we
137docker run $ARGS_UPLOAD $IMAGE /bin/bash -c "exec curator check-target-available --target $TARGET"
139# Successful build, so we need to:
141# * Upload the docs to S3
142# * Upload the new snapshot .yaml file to the appropriate Github repo, also upload its constraints
143docker run $ARGS_UPLOAD $IMAGE /bin/bash -c "curator upload-docs --target $TARGET && curator upload-github --target $TARGET"
145# fixed in https://github.com/commercialhaskell/curator/pull/24
146docker run $ARGS_UPLOAD $IMAGE /bin/bash -c "exec curator hackage-distro --target $TARGET"
148# Build and push docker image fpco/stack-build & fpco/stack-build-small for current release
150if [ $SHORTNAME = "lts" ]
152 $ROOT/dockerfiles/build.sh $TARGET
153 $ROOT/dockerfiles/build.sh --push $TARGET
154 $ROOT/dockerfiles/build.sh --push --small $TARGET
157echo -n "Completed at "
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list