2009-04-06 15:13:06 +01:00
|
|
|
#!/bin/bash
|
2007-10-14 11:31:40 +01:00
|
|
|
# lw-build-system/scripts/version.sh
|
|
|
|
#
|
2009-01-03 22:55:04 +00:00
|
|
|
# (c)2009, Laurence Withers <l@lwithers.me.uk>.
|
2007-10-14 11:31:40 +01:00
|
|
|
# Released under the GNU GPLv3. See file COPYING or
|
|
|
|
# http://www.gnu.org/copyleft/gpl.html for details.
|
|
|
|
#
|
|
|
|
# Script to automate bumping of version or soversion files, and pushing
|
|
|
|
# changes (and tags) to the origin repository.
|
|
|
|
#
|
2007-02-19 20:29:33 +00:00
|
|
|
|
|
|
|
if [ $# -eq 0 ]
|
|
|
|
then
|
2007-10-14 11:31:40 +01:00
|
|
|
echo "Usage: $0 COMMANDS"
|
|
|
|
echo ""
|
|
|
|
echo " major - bump major version, reset minor and micro"
|
|
|
|
echo " minor - bump minor version, reset micro"
|
|
|
|
echo " micro - bump micro version"
|
|
|
|
echo " libmajor LIB - as major but for soversion"
|
|
|
|
echo " libmicro LIB - as micro but for soversion"
|
|
|
|
echo " tag - tag version"
|
2008-08-18 19:42:22 +01:00
|
|
|
echo " push - do a git push with --tags"
|
2007-10-14 11:31:40 +01:00
|
|
|
|
|
|
|
exit 1
|
2007-02-19 20:29:33 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
edit_versions() {
|
2007-10-14 11:31:40 +01:00
|
|
|
file="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
SEDCMD=""
|
|
|
|
while [ $# -ne 0 ]
|
|
|
|
do
|
|
|
|
var="$1"
|
|
|
|
shift
|
|
|
|
value="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
SEDCMD="${SEDCMD} -e s,^${var}=.*$,${var}=${value},"
|
|
|
|
done
|
|
|
|
sed ${SEDCMD} -i "${file}"
|
2008-08-18 19:42:22 +01:00
|
|
|
git commit -m "Bump version" "${file}"
|
2007-02-19 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bump_major() {
|
2009-04-06 15:13:06 +01:00
|
|
|
source "./version"
|
2007-10-14 11:31:40 +01:00
|
|
|
edit_versions "version" "VERMAJOR" "$[${VERMAJOR} + 1]" "VERMINOR" "0" "VERMICRO" "0"
|
2007-02-19 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bump_minor() {
|
2009-04-06 15:13:06 +01:00
|
|
|
source "./version"
|
2007-10-14 11:31:40 +01:00
|
|
|
edit_versions "version" "VERMINOR" "$[${VERMINOR} + 1]" "VERMICRO" "0"
|
2007-02-19 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bump_micro() {
|
2009-04-06 15:13:06 +01:00
|
|
|
source "./version"
|
2007-10-14 11:31:40 +01:00
|
|
|
edit_versions "version" "VERMICRO" "$[${VERMICRO} + 1]"
|
2007-02-19 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bump_somajor() {
|
2009-04-06 15:13:06 +01:00
|
|
|
source "./src/$1/soversion"
|
2007-10-14 11:31:40 +01:00
|
|
|
edit_versions "src/$1/soversion" "SOMAJOR" "$[${SOMAJOR} + 1]" "SOMINOR" "0" "SOMICRO" "0"
|
2007-02-19 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bump_somicro() {
|
2009-04-06 15:13:06 +01:00
|
|
|
source "./src/$1/soversion"
|
2007-10-14 11:31:40 +01:00
|
|
|
edit_versions "src/$1/soversion" "SOMICRO" "$[${SOMICRO} + 1]"
|
2007-02-19 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_tag() {
|
2009-04-06 15:13:06 +01:00
|
|
|
source "./version"
|
2008-08-18 19:42:22 +01:00
|
|
|
git tag "${VERMAJOR}.${VERMINOR}.${VERMICRO}"
|
2007-02-19 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
do_push() {
|
2008-08-18 19:42:22 +01:00
|
|
|
git push
|
|
|
|
git push --tags
|
2007-02-19 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
while [ $# -ne 0 ]
|
|
|
|
do
|
2007-10-14 11:31:40 +01:00
|
|
|
case $1 in
|
|
|
|
major)
|
|
|
|
bump_major
|
|
|
|
;;
|
|
|
|
|
|
|
|
minor)
|
|
|
|
bump_minor
|
|
|
|
;;
|
|
|
|
|
|
|
|
micro)
|
|
|
|
bump_micro
|
|
|
|
;;
|
|
|
|
|
|
|
|
libmajor)
|
|
|
|
bump_somajor $2
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
libmicro)
|
|
|
|
bump_somicro $2
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
|
|
|
|
tag)
|
|
|
|
do_tag
|
|
|
|
;;
|
|
|
|
|
|
|
|
push)
|
|
|
|
do_push
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Unrecognised command: $1"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
shift
|
2007-02-19 20:29:33 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
true
|
2007-10-14 11:31:40 +01:00
|
|
|
|
|
|
|
# vim:ts=4:sw=4:expandtab
|