X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/01386fc8db473eac03c5aaaa53f3790cde319a76..bbe59354d97fa30184f6a95cf1f31ce447d0fa29:/.ext/cfd/build/auto-version diff --git a/.ext/cfd/build/auto-version b/.ext/cfd/build/auto-version new file mode 100755 index 00000000..2b37944b --- /dev/null +++ b/.ext/cfd/build/auto-version @@ -0,0 +1,99 @@ +#! /bin/sh +### -*-sh-*- +### +### Make autoconf-like substitutions in files +### +### (c) 2008 Mark Wooding +### + +###----- Licensing notice --------------------------------------------------- +### +### This file is part of the Common Files Distribution (`common'). +### +### `Common' is free software; you can redistribute it and/or modify +### it under the terms of the GNU General Public License as published by +### the Free Software Foundation; either version 2 of the License, or +### (at your option) any later version. +### +### `Common' is distributed in the hope that it will be useful, +### but WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with `common'; if not, write to the Free Software Foundation, +### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +set -e + +###-------------------------------------------------------------------------- +### Parse command line arguments. + +while [ $# -gt 0 ]; do + case $1 in + -h | --h | --he | --hel | --help) + cat <&2 + exit 1 + ;; + *) + break + ;; + esac + shift +done + +if [ $# -ne 0 ]; then + echo >&2 "Usage: auto-version" + exit 1 +fi + +###-------------------------------------------------------------------------- +### Main program. + +## If this is a Git checkout then Git should be able to identify the version. +## If there's also a Debian version, and that ends in a `~', then prefix the +## Git version with this. Note that `pkg-config' is not very good, and, in +## particular, doesn't support the convention that `~' sorts before anything +## else, even the empty string, despite claiming to implement the RPM +## version-comparison algorithm which specifies this behaviour, so one must +## be careful when choosing `~' prefixes. +if [ -e .git ] && version=$(git describe --abbrev=4 --dirty=+ 2>/dev/null); then + debver=$(sed -n '/^.*(\(.*\)).*$/ { s::\1:p; q; }' debian/changelog) + case $debver in *~) version=$debver$version ;; esac + echo "$version" + exit 0 +fi + +## If this was unpacked from a source distribution, the RELEASE file should +## say what the version was. +if [ -f RELEASE ]; then + cat RELEASE + exit 0 +fi + +## If we're Debianized, then the Debian changelog ought to know. +if [ -f debian/changelog ]; then + sed -n '/^.*(\(.*\)).*$/ { s::\1:p; q; }' debian/changelog + exit 0 +fi + +## Otherwise we're screwed. +echo UNKNOWN +exit 0 + +###----- That's all, folks --------------------------------------------------