1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#!/bin/bash
port=swi-prolog
portprefix=/opt/local
branch=master
done=false
while [ $done = false ]; do
case "$1" in
--branch=*) branch=$(echo $1 | sed 's/^[^=]*=//')
shift
;;
*) done=true
;;
esac
done
if [ -x $portprefix/bin/gsed ]; then
sed=$portprefix/bin/gsed
else
sed=sed
fi
portgit=$HOME/src/macports-ports/
portfile=lang/$port/Portfile
version=$(cat VERSION)
file=../swipl-$version.tar.gz
if [ ! -r $file ]; then
echo "ERROR: Could not find distfile $file"
exit 1
fi
size=$(wc -c < $file | xargs)
sha256=$(openssl sha256 < $file | cut -d ' ' -f 2)
rmd160=$(openssl rmd160 -provider legacy < $file | cut -d ' ' -f 2)
if [ -d $portprefix/var/macports/distfiles ]; then
cp $file $portprefix/var/macports/distfiles/swi-prolog || exit 1
fi
echo "version: $version"
echo "size: $size"
echo "sha256: $sha256"
echo "rmd160: $rmd160"
cbranch=$(git -C $portgit rev-parse --abbrev-ref HEAD)
if [ ! $branch = master -a $cbranch = $branch ]; then
echo "Keeping branch $branch"
else
git -C $portgit checkout $branch
if [ $branch = master ]; then
echo "Pulling $branch"
git -C $portgit pull
fi
git -C $portgit branch -D $version >/dev/null 2>&1 || true
git -C $portgit checkout -b $version
fi
$sed -i \
-e "s/^\(version\s*\)[0-9].*/\1$version/" \
-e "s/^\(revision\s*\)[0-9].*/\10/" \
-e "s/^\(checksums\s*rmd160\s*\)[0-9a-f].*/\1$rmd160 \\\\/" \
-e "s/^\(\s*sha256\s*\)[0-9a-f].*/\1$sha256 \\\\/" \
-e "s/^\(\s*size\s*\)[0-9a-f].*/\1$size/" \
$portgit/$portfile
git -C $portgit commit $portfile -m "$port: Updated to version $version"
|