diff --git a/README.md b/README.md index 5d63d6857..0e55b7808 100644 --- a/README.md +++ b/README.md @@ -232,11 +232,9 @@ In principle you can change other things too, but this is generally frowned upon This repository contains a convenience script for adding a revision to CHaP: ``` -$ ./scripts/add-revision.sh _repo PACKAGE_NAME PACKAGE_VERSION +$ ./scripts/add-revision.sh PACKAGE_NAME PACKAGE_VERSION ``` -`_repo` needs to point to a [built package repository](#how-to-get-the-built-cabal-package-repository). -It will add a new revision and copy the _current_ cabal file in as the revised cabal file. You can then edit that file and commit the result. ### How to add a patched versions of a Hackage package diff --git a/scripts/add-revision.sh b/scripts/add-revision.sh index 1dcdbfdec..4393372a3 100755 --- a/scripts/add-revision.sh +++ b/scripts/add-revision.sh @@ -5,7 +5,7 @@ set -o pipefail SCRIPT_DIR=$(dirname "$(which "$0")") function usage { - echo "Usage $(basename "$0") BUILT_REPO PKG_NAME PKG_VERSION" + echo "Usage $(basename "$0") PKG_NAME PKG_VERSION" echo " Adds a new revision with the existing cabal file for that package" echo " version. Requires a built repository. Does not commit." exit @@ -28,15 +28,18 @@ done shift $((OPTIND - 1)) -BUILT_REPO=$1 -PKG_NAME=$2 -PKG_VERSION=$3 +PKG_NAME=$1 +PKG_VERSION=$2 -if ! shift 3; then +if ! shift 2; then usage exit 1 fi +BUILT_REPO=$(mktemp -d) +mkdir -p $BUILT_REPO/index +curl -L https://input-output-hk.github.io/cardano-haskell-packages/01-index.tar.gz | tar -C $BUILT_REPO/index -xz + META_DIR="_sources/$PKG_NAME/$PKG_VERSION" META_FILE="$META_DIR/meta.toml" REVISIONS_DIR="$META_DIR/revisions" @@ -63,10 +66,11 @@ else LATEST_REVISION=$(echo "$CURRENT_REVISIONS" | sort | tail -n1) LATEST_REVISION_NUMBER=$(basename "$LATEST_REVISION" | cut -f 1 -d '.') NEW_REVISION_NUMBER=$((LATEST_REVISION_NUMBER+1)) + CURRENT_CABAL_FILE="$REVISIONS_DIR/$LATEST_REVISION_NUMBER.cabal" fi NEW_CABAL_FILE="$REVISIONS_DIR/$NEW_REVISION_NUMBER.cabal" -echo "Moving $CURRENT_CABAL_FILE to $NEW_CABAL_FILE" +echo "Copying $CURRENT_CABAL_FILE to $NEW_CABAL_FILE" mkdir -p "$REVISIONS_DIR" cp "$CURRENT_CABAL_FILE" "$NEW_CABAL_FILE" diff --git a/scripts/current-timestamp.sh b/scripts/current-timestamp.sh index a6325b2ea..1a08909f5 100755 --- a/scripts/current-timestamp.sh +++ b/scripts/current-timestamp.sh @@ -1,8 +1,3 @@ #!/usr/bin/env bash -# Use gnu-tar and gnu-date regardless of whether the OS is Linux -# or BSD-based. The correct command will be assigned to TAR and DATE -# variables. -source "$(dirname "$(which "$0")")/use-gnu-tar.sh" - -"$DATE" --utc +%Y-%m-%dT%H:%M:%SZ +date -u +%Y-%m-%dT%H:%M:%SZ diff --git a/scripts/use-gnu-tar.sh b/scripts/use-gnu-tar.sh index 3d769e7ce..fe4161eee 100755 --- a/scripts/use-gnu-tar.sh +++ b/scripts/use-gnu-tar.sh @@ -1,12 +1,8 @@ #!/usr/bin/env bash -export DATE="date" export TAR="tar" if [[ "$(uname -s)" == "Darwin" ]]; then - if [[ "$(which date)" == "/bin/date" ]]; then - export DATE="gdate" - fi if [[ "$(which tar)" == "/usr/bin/tar" ]]; then export TAR="gtar" fi