Skip to content

Commit afdb58c

Browse files
committed
Add scripts/check-cabal-plan.sh
Checks whether a cabal build plan is using the latest packages from CHaP
1 parent 638342b commit afdb58c

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

scripts/check-cabal-plan.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Usage: check-plan [PLAN.JSON]
6+
#
7+
# Check whether a cabal build plan is using the latest packages from CHaP
8+
#
9+
# The CHaP index is fetched using `curl`; the `cardano-haskell-packages` git repo isn't used
10+
11+
PLAN=${1-dist-newstyle/cache/plan.json}
12+
13+
PLAN_VERSIONS=$(mktemp)
14+
CHAP_VERSIONS=$(mktemp)
15+
16+
trap 'rm -f "$PLAN_VERSIONS" "$CHAP_VERSIONS"' EXIT
17+
18+
if tar --version | grep -q 'GNU tar'
19+
then
20+
tar () { command tar --wildcards "$@"; }
21+
fi
22+
23+
with-header()
24+
{
25+
if read -r LINE
26+
then
27+
echo "$1"
28+
echo "$LINE"
29+
cat
30+
fi
31+
}
32+
33+
jq -r '
34+
."install-plan"[]
35+
| select(."pkg-src".repo.uri // "" | match("^https://chap.intersectmbo.org"; "i"))
36+
| "\(."pkg-name")/\(."pkg-version")"
37+
' "$PLAN" |
38+
LANG=C sort -t/ -k1,1 -u -o "$PLAN_VERSIONS"
39+
40+
curl -sSL https://chap.intersectmbo.org/01-index.tar.gz |
41+
tar -tz \*.cabal |
42+
cut -d/ -f1-2 |
43+
LANG=C sort -t/ -k1,1 -k2,2Vr |
44+
LANG=C sort -t/ -k1,1 -u -o "$CHAP_VERSIONS"
45+
46+
LANG=C join -t/ -j1 "$PLAN_VERSIONS" "$CHAP_VERSIONS" |
47+
awk -F/ '$2 != $3 {print}' |
48+
with-header "Package/Plan/CHaP" |
49+
column -t -s/

0 commit comments

Comments
 (0)