Skip to content

Commit 3822c74

Browse files
committed
Improve scripts/add-revions.sh
The need to pass a `BUILT_REPO` arg is very confusing and it is small enough to just DL the latest to a temp dir. This change also only uses the `BUILT_REPO` if there is no existing revision. If there is a revision it copies the `.cabal` file from there (in case it is not in the BUILT_REPO yet). Also uses `date -u` instead of `date --utc` so that we don't have to install `gdate` on macOS to make it work.
1 parent 2a4ba30 commit 3822c74

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

scripts/add-revision.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -o pipefail
55
SCRIPT_DIR=$(dirname "$(which "$0")")
66

77
function usage {
8-
echo "Usage $(basename "$0") BUILT_REPO PKG_NAME PKG_VERSION"
8+
echo "Usage $(basename "$0") PKG_NAME PKG_VERSION"
99
echo " Adds a new revision with the existing cabal file for that package"
1010
echo " version. Requires a built repository. Does not commit."
1111
exit
@@ -28,15 +28,18 @@ done
2828

2929
shift $((OPTIND - 1))
3030

31-
BUILT_REPO=$1
32-
PKG_NAME=$2
33-
PKG_VERSION=$3
31+
PKG_NAME=$1
32+
PKG_VERSION=$2
3433

35-
if ! shift 3; then
34+
if ! shift 2; then
3635
usage
3736
exit 1
3837
fi
3938

39+
BUILT_REPO=$(mktemp -d)
40+
mkdir -p $BUILT_REPO/index
41+
curl -L https://input-output-hk.github.io/cardano-haskell-packages/01-index.tar.gz | tar -C $BUILT_REPO/index -xz
42+
4043
META_DIR="_sources/$PKG_NAME/$PKG_VERSION"
4144
META_FILE="$META_DIR/meta.toml"
4245
REVISIONS_DIR="$META_DIR/revisions"
@@ -63,10 +66,11 @@ else
6366
LATEST_REVISION=$(echo "$CURRENT_REVISIONS" | sort | tail -n1)
6467
LATEST_REVISION_NUMBER=$(basename "$LATEST_REVISION" | cut -f 1 -d '.')
6568
NEW_REVISION_NUMBER=$((LATEST_REVISION_NUMBER+1))
69+
CURRENT_CABAL_FILE="$REVISIONS_DIR/$LATEST_REVISION_NUMBER.cabal"
6670
fi
6771

6872
NEW_CABAL_FILE="$REVISIONS_DIR/$NEW_REVISION_NUMBER.cabal"
69-
echo "Moving $CURRENT_CABAL_FILE to $NEW_CABAL_FILE"
73+
echo "Copying $CURRENT_CABAL_FILE to $NEW_CABAL_FILE"
7074

7175
mkdir -p "$REVISIONS_DIR"
7276
cp "$CURRENT_CABAL_FILE" "$NEW_CABAL_FILE"

scripts/current-timestamp.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
#!/usr/bin/env bash
22

3-
# Use gnu-tar and gnu-date regardless of whether the OS is Linux
4-
# or BSD-based. The correct command will be assigned to TAR and DATE
5-
# variables.
6-
source "$(dirname "$(which "$0")")/use-gnu-tar.sh"
7-
8-
"$DATE" --utc +%Y-%m-%dT%H:%M:%SZ
3+
date -u +%Y-%m-%dT%H:%M:%SZ

scripts/use-gnu-tar.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#!/usr/bin/env bash
22

3-
export DATE="date"
43
export TAR="tar"
54

65
if [[ "$(uname -s)" == "Darwin" ]]; then
7-
if [[ "$(which date)" == "/bin/date" ]]; then
8-
export DATE="gdate"
9-
fi
106
if [[ "$(which tar)" == "/usr/bin/tar" ]]; then
117
export TAR="gtar"
128
fi

0 commit comments

Comments
 (0)