Skip to content

Commit 421318b

Browse files
committed
Cleanup
1 parent 4a59147 commit 421318b

7 files changed

Lines changed: 45 additions & 39 deletions

File tree

common/copy_ghcup.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env sh
2+
3+
ghcup_img="$1"
4+
builder_cntr="$2"
5+
6+
ghcup_cntr=$(buildah from --signature-policy=./policy.json "${ghcup_img}")
7+
ghcup_mnt=$(buildah mount "${ghcup_cntr}")
8+
builder_mnt=$(buildah mount "${builder_cntr}")
9+
10+
cp "${ghcup_mnt}/usr/bin/ghcup" "${builder_mnt}/usr/bin/ghcup"
11+
12+
# Clean up intermediate container.
13+
buildah rm "${ghcup_cntr}"

common/copy_ghcup_bin_dir.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env sh
2+
3+
ghcup_img="$1"
4+
builder_cntr="$2"
5+
6+
ghcup_cntr=$(buildah from --signature-policy=./policy.json "${ghcup_img}")
7+
ghcup_mnt=$(buildah mount "${ghcup_cntr}")
8+
builder_mnt=$(buildah mount "${builder_cntr}")
9+
10+
cp -r "${ghcup_mnt}/root/.ghcup" "${builder_mnt}/root/.ghcup"
11+
12+
# Clean up intermediate container.
13+
buildah rm "${ghcup_cntr}"

common/validate_checksum.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env sh
2+
set -eu
3+
4+
file_path="$1"
5+
expected_checksum="$2"
6+
7+
if ! echo "${expected_checksum} ${file_path}" | sha256sum -c -; then
8+
echo "${file_path} checksum failed" >&2
9+
echo "expected '${expected_checksum}', but got '$( sha256sum "${file_path}" )'" >&2
10+
exit 1
11+
fi;

ghc/builder.sh

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ while getopts "a:c:g:i:n:h" opt; do
5454
image="${OPTARG}"
5555
};;
5656
n ) {
57-
if [ "${OPTARG}" = "gmp" ] || [ "${OPTARG}" = "simple" ]; then
58-
numeric="${OPTARG}"
59-
else
57+
if [ "${OPTARG}" = "gmp" ] || [ "${OPTARG}" = "simple" ]; then
58+
numeric="${OPTARG}"
59+
else
6060
echo "Invalid NUMERIC argument (i.e. '-n')." >&2
6161
echo "Expected either 'gmp' or 'simple', got '${OPTARG}'" >&2
6262
exit 1
63-
fi;
63+
fi;
6464
};;
6565
h ) {
6666
echo "${usage}"
@@ -87,12 +87,6 @@ image="${image}-${numeric}"
8787
################################################################################
8888

8989
# Create the container that will be used to compile GHC from source.
90-
#
91-
# NOTE: Alternatively: `buildah commit --rm` (at the end of the script) removes
92-
# the working container.
93-
#
94-
# XXX: Reusing the container by name if it exists seems like not the best idea
95-
# but it's convenient for development.
9690
buildah \
9791
--signature-policy=./policy.json \
9892
--name "${container}" \
@@ -102,9 +96,7 @@ buildah \
10296
# Copy `ghcup` from another container.
10397
################################################################################
10498

105-
# XXX: Maybe the `"ghcup"` image name should be fully qualified (i.e.
106-
# "localhost/ghcup" for an image built locally)...?
107-
buildah unshare ./ghc/copy_ghcup.sh "ghcup" "${container}"
99+
buildah unshare ./common/copy_ghcup.sh "ghcup" "${container}"
108100

109101
################################################################################
110102
# Dependencies.

ghc/copy_ghcup.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

ghcup/builder.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ if [ "$#" -ne 0 ]; then
5858
fi
5959

6060
################################################################################
61-
# Container and basic dependencies.
61+
# Container.
6262
################################################################################
6363

64+
# Create the container that will be used to download `ghcup`.
6465
buildah \
6566
--signature-policy=./policy.json \
6667
--name "${container}" \
@@ -93,7 +94,7 @@ buildah run "${container}" \
9394

9495
# Copy the checksum validation script into the container...
9596
buildah copy --chmod 111 "${container}" \
96-
./ghcup/validate_checksum.sh \
97+
./common/validate_checksum.sh \
9798
/tmp/validate_checksum.sh
9899

99100
# ...and verify that the expected and actual actual `ghcup` checksums match.

ghcup/validate_checksum.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)