Add some scripts to automate common commands (printing config flags, bumping versions, tagging)

This commit is contained in:
Laurence Withers 2007-02-19 20:29:33 +00:00
parent b210e6a1b1
commit c720b7263a
2 changed files with 134 additions and 0 deletions

8
scripts/config-printflags.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
for pkg in $@
do
varname="$(echo "${pkg}" | tr a-z A-Z)"
echo '[ -z "${'${varname}'_CFLAGS}" ] && '${varname}'_CFLAGS=$('${pkg}'-config --cflags)"'
echo '[ -z "${'${varname}'_LIBS}" ] && '${varname}'_LIBS=$('${pkg}'-config --cflags)"'
done

126
scripts/version.sh Executable file
View File

@ -0,0 +1,126 @@
#!/bin/sh
if [ $# -eq 0 ]
then
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 " libminor LIB - as minor but for soversion"
echo " libmicro LIB - as micro but for soversion"
echo " tag - tag version"
echo " push - do a git-push with --tags"
exit 1
fi
edit_versions() {
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}"
git-commit -m "Bump version" "${file}"
}
bump_major() {
source version
edit_versions "version" "VERMAJOR" "$[${VERMAJOR} + 1]" "VERMINOR" "0" "VERMICRO" "0"
}
bump_minor() {
source version
edit_versions "version" "VERMINOR" "$[${VERMINOR} + 1]" "VERMICRO" "0"
}
bump_micro() {
source version
edit_versions "version" "VERMICRO" "$[${VERMICRO} + 1]"
}
bump_somajor() {
source src/$1/soversion
edit_versions "src/$1/soversion" "SOMAJOR" "$[${SOMAJOR} + 1]" "SOMINOR" "0" "SOMICRO" "0"
}
bump_sominor() {
source src/$1/soversion
edit_versions "src/$1/soversion" "SOMINOR" "$[${SOMINOR} + 1]" "SOMICRO" "0"
}
bump_somicro() {
source src/$1/soversion
edit_versions "src/$1/soversion" "SOMICRO" "$[${SOMICRO} + 1]"
}
do_tag() {
source version
git-tag "${VERMAJOR}.${VERMINOR}.${VERMICRO}"
}
do_push() {
git-push
git-push --tags
}
set -ex
while [ $# -ne 0 ]
do
case $1 in
major)
bump_major
;;
minor)
bump_minor
;;
micro)
bump_micro
;;
libmajor)
bump_somajor $2
shift
;;
libminor)
bump_sominor $2
shift
;;
libmicro)
bump_somicro $2
shift
;;
tag)
do_tag
;;
push)
do_push
;;
*)
echo "Unrecognised command: $1"
exit 1
;;
esac
shift
done
true