From 21fb8638acb2174223566cfccde2af3393f36537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Thu, 2 Jun 2016 20:15:59 +0200 Subject: [PATCH] hackage-metadata: update the scripts --- scripts/download-metadata.sh | 5 ++++- scripts/upload-metadata.hs | 12 ++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/download-metadata.sh b/scripts/download-metadata.sh index 358f4e0..3ea9903 100755 --- a/scripts/download-metadata.sh +++ b/scripts/download-metadata.sh @@ -18,11 +18,14 @@ PACKAGE=$1 OUTDIR=$2 versions="$(wget -O - https://hackage.haskell.org/package/"$PACKAGE"/preferred.json | jq '."normal-version"[]' -r)" +#versions="$(wget -O - https://hackage.haskell.org/package/"$PACKAGE"/preferred.json | jq '."deprecated-version"[]' -r)" + + mkdir -p "$OUTDIR" for v in $versions; do - wget https://hackage.haskell.org/package/"$PACKAGE-$v"/"$PACKAGE".cabal -O "$OUTDIR/${PACKAGE}-${v}.cabal" + wget https://hackage.haskell.org/package/"$PACKAGE-$v"/"$PACKAGE".cabal -O "$OUTDIR/${PACKAGE}-${v}.cabal" & done diff --git a/scripts/upload-metadata.hs b/scripts/upload-metadata.hs index 84a89bf..3eb1290 100755 --- a/scripts/upload-metadata.hs +++ b/scripts/upload-metadata.hs @@ -31,6 +31,9 @@ hidden_prompt "Password" pw versions="$(curl https://hackage.haskell.org/package/"$PACKAGE"/preferred.json | jq '."normal-version"[]' -r)" +#versions="$(curl https://hackage.haskell.org/package/"$PACKAGE"/preferred.json | jq '."deprecated-version"[]' -r)" + +echo "Versions: $versions" for v in $versions; do rev=$(cat $OUTDIR/$PACKAGE-$v.cabal | grep -i "^x-revision:" | tr -s '[:blank:]*' '\t' | cut -f 2) @@ -39,16 +42,21 @@ for v in $versions; do rev=0 fi + echo -n "$PACKAGE v$v rev:$rev..." + content=$( ( echo "X-Revision: $((rev + 1))"; cat $OUTDIR/$PACKAGE-$v.cabal | sed '/^X-Revision:/Id' ) ) - resp=$(curl --form-string "cabalfile=$content" -F "publish=Publish new revision" https://hackage.haskell.org/package/"${PACKAGE}-${v}"/"${PACKAGE}.cabal"/edit -u "$user:$pw") + resp=$(curl -s --form-string "cabalfile=$content" -F "publish=Publish new revision" https://hackage.haskell.org/package/"${PACKAGE}-${v}"/"${PACKAGE}.cabal"/edit -u "$user:$pw") changes=$(printf '%s\n' "$resp" | sed -n '/Changes in this revision/,/<\/ul>/p' | w3m -dump -T text/html) errors=$(printf '%s\n' "$resp" | sed -n '/Errors/,/<\/form>/p') - notpublished=$(printf '%s\n' "$resp" | grep "Cannot publish new revision") + if printf '%s\n' "$resp" | grep -q "Cannot publish new revision"; then + notpublished=1 + fi + printf 'Changes:\n%s\n' "$changes" if [ -z "$changes" -o -n "$notpublished" ]; then if printf '%s\n' "$errors" | grep -q "No changes"; then continue;