diff options
author | Christian Wieninger <cwieninger (at) gmx (dot) de> | 2008-01-25 23:39:31 +0100 |
---|---|---|
committer | Christian Wieninger <cwieninger (at) gmx (dot) de> | 2008-01-25 23:39:31 +0100 |
commit | 49e60374753e249d6da4c31156a91f5c45012ff8 (patch) | |
tree | e4dbe7e8bf7d960d03783b63d3778fd653338391 /buildutil | |
parent | 81db819a3d93b57dd77ad7ee2c654a607abd99c9 (diff) | |
parent | 8042f07834aa3a324b6d077984531c123253b4ba (diff) | |
download | vdr-plugin-live-49e60374753e249d6da4c31156a91f5c45012ff8.tar.gz vdr-plugin-live-49e60374753e249d6da4c31156a91f5c45012ff8.tar.bz2 |
Merge commit 'tadi/master'
Diffstat (limited to 'buildutil')
-rwxr-xr-x | buildutil/version-util | 125 | ||||
-rw-r--r-- | buildutil/version-util.awk | 48 |
2 files changed, 173 insertions, 0 deletions
diff --git a/buildutil/version-util b/buildutil/version-util new file mode 100755 index 0000000..fa4b127 --- /dev/null +++ b/buildutil/version-util @@ -0,0 +1,125 @@ +#!/bin/sh +# ----------------------------------------------------------------------------- +# Shell script to determine the last commit version of the project It +# checks for CVS and .git repositories. The output is a string that +# can be used in a define at compile time to automatically mark +# repository versions. For CVS repositories the string contains the +# date and time of the commit that lead to the current version of +# files. For git repositories the output contains the git-id of the +# current tree. An indication if localy modified files exist is +# added currently only for CVS. +# ----------------------------------------------------------------------------- + +[ $# -lt 1 ] && echo "USAGE: version-util [-F] <versionfile>" && exit 1 + +VERS_FILE=$1 +FORCE_EMPTY=0 + +[ "$VERS_FILE" == "-F" -a $# -lt 2 ] && echo "USAGE: version-util [-F] <versionfile>" && exit 1 + +if [ $# -gt 1 ]; then + VERS_FILE=$2 + FORCE_EMPTY=1 +fi + + +SCRIPT_PATH=`dirname $0` + +# echo "file: ${VERS_FILE}, force = $FORCE_EMPTY" +# exit 0 + +function createVers () +{ +cat <<EOF +/* ATTENTION: this file is automatically generated and will be overwritten! + * Manual changes will get lost! + */ +#ifndef GEN_VERSION_SUFFIX_H +#define GEN_VERSION_SUFFIX_H +#define VERSION_SUFFIX "$1" +#endif +EOF +} + +function fileVersions() +{ + for file in `find . -wholename '*CVS/Entries' -print` + do + sed -e's/\//|/g' -e's/|/\//' $file \ + | grep --label=$file -H '^/' \ + | sed -e's/\/CVS\/Entries://' -e's/\.\///' + done +} + +function cvsLog() +{ + echo "= == ===marker=== == =" + cvs log -b -N 2> /dev/null +} + +function cvsData() +{ + fileVersions + cvsLog +} + +function cvsVers () +{ + d=`cvsData \ + | awk -f ${SCRIPT_PATH}/version-util.awk \ + | sort -u \ + | tail -1 \ + | tr -d ' \-:'` + m=`cvs status 2> /dev/null \ + | grep 'Status: Locally Modified' > /dev/null && echo "_MOD"` + echo "_cvs_${d}${m}" +} + +function gitVers () +{ + b=`git branch \ + | grep '^*' \ + | sed -e's/^* //'` + h=`git show --pretty=format:"%h_%ci" HEAD \ + | head -1 \ + | tr -d ' \-:'` + echo "_git_${b}_${h}" +} + +function emptyVers () +{ + echo "" +} + +function checkVers () +{ + s=`$1` + if [ ! -e ${VERS_FILE} ]; then + echo "$VERS_FILE does not exist! creating a new one." + createVers $s > ${VERS_FILE} + else + v=`grep '^#define VERSION_SUFFIX' ${VERS_FILE} \ + | awk '{print $3}'` + if [ "$v" != "\"$s\"" ]; then + echo "$VERS_FILE is being recreated!" + createVers $s > ${VERS_FILE} + fi + fi +} + +if [ $FORCE_EMPTY -eq 1 ]; then + checkVers emptyVers + exit 0 +fi + +if [ -d CVS ]; then + checkVers cvsVers + exit 0 +fi + +if [ -d .git ]; then + checkVers gitVers + exit 0 +fi + +checkVers emptyVers diff --git a/buildutil/version-util.awk b/buildutil/version-util.awk new file mode 100644 index 0000000..0ed59c5 --- /dev/null +++ b/buildutil/version-util.awk @@ -0,0 +1,48 @@ +BEGIN { + FS="|"; + init_revisions = 1; + rev_trigger = 0; + date_trigger = 0; +} + +/= == ===marker=== == =/ { + init_revisions = 0; + FS=";"; + next; +} + +init_revisions == 1 { + # print "XXX " $1, $2; + file_revs[$1] = $2; + next; +} + +/^Working file:/ { + rev_trigger = 0; + if (match($0, "^Working file: (.*)$", f) > 0) { + if (f[1] in file_revs) { + revision = "revision " file_revs[f[1]]; + rev_trigger = 1; + } + } + # print "FFF " f[1], revision, rev_trigger; + next; +} + +rev_trigger == 1 && /^revision/ { + if (match($0, revision) > 0) { + # print "FOUND " revision, $0; + rev_trigger = 0; + date_trigger = 1; + } + next; +} + +date_trigger == 1 { + if (match($1, "date: (.*)", d) > 0) { + print d[1]; + } + date_trigger = 0; +} + +{ next; } |