1
0
forked from bip/bip
bip/scripts/bip-release
2013-10-19 13:34:15 +02:00

72 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
set -e
if [ ! -d src ] ; then
echo "Please run me in bip sources root." >&2
exit 1
fi
release="$1"
: ${MAKEOPTS:=-j -l4}
set_version() {
local release
release="${1}"
sed -i -e '/^AC_INIT/s/\(, \[\)[^]]*/\1'${release}'/' configure.ac
}
get_version() {
grep -e '^AC_INIT' configure.ac | cut -d [ -f 3 | cut -d ] -f 1
}
make_distcheck() {
# prepare sources
autoreconf -i -Wall
# Create makefile, use all possible options
./configure --enable-oidentd
# run distcheck
if ! make ${MAKEOPTS} distcheck; then
echo "'make distcheck' fails, please try again." >&2
return 1
else
true
fi
}
git log > ChangeLog
if [ -n "$release" ]; then
set_version "${release}"
make_distcheck || exit 1
git commit -a -m "Update version and ChangeLog for bip-${release} release."
git tag -s release-$release
set_version "${release}-git"
git commit -a -m "Add -git to version string."
echo "See bip-${release}.tar.gz"
else
make_distcheck || exit 1
tarname=bip-$(get_version)
prefix=bip-$(date +%Y%m%d)
rm -rf "${tarname}" "${prefix}"
tar -xzf "${tarname}".tar.gz
rm -rf "${tarname}".tar.gz
mv "${tarname}" "${prefix}"
tar -czf "${prefix}".tar.gz "${prefix}"
rm -rf "${prefix}"
# Revert the ChangeLog.
git checkout HEAD -- ChangeLog
echo "See ${prefix}.tar.gz"
fi
# cleanup
git clean -d -i -e "bip-*.tar.gz"