Debian Codegraph @

localversion

raw symbols SCIP
1 #!/bin/sh
2 #
3 # libhugetlbfs - Easy use of Linux hugepages
4 # Copyright (C) 2006 Andy Whitcroft, IBM Corporation
5 #
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public License
8 # as published by the Free Software Foundation; either version 2.1 of
9 # the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
20 if [ "$#" -lt 1 ]; then
21 echo "Usage: localversion <version file> <source> ..." 1>&2
22 exit 1
23 fi
24 file="$1"
25
26 if [ -f "$file" ]; then
27 read current_version <"$file"
28 fi
29 version="$current_version"
30
31 modified=0
32
33 # GIT: check for a git tree.
34 mod=`git diff-index HEAD 2>/dev/null`
35 if [ "$?" -eq 0 ]; then
36 # This is a GIT repo, see if it was modified.
37 if [ "$mod" != "" ]; then
38 modified=1
39 else
40 # Subtle, if we are in a git archive and the repository
41 # is clean then update the time on the version file
42 # thus ensuring it will be correct in any tarball.
43 touch "$file"
44 fi
45
46 # Try and get a real "tag relative" version name for it.
47 version=`git describe --tags HEAD 2>&1`
48 if [ "$?" -ne 0 ]; then
49 # ok, desperation just take the commit id.
50 version=`git log | awk '{ print $2; exit }'`
51 version="commit<$version>"
52 fi
53
54 else
55 if [ ! -f "$file" ]; then
56 echo 1>&2 "$0: ERROR: unversioned tarball"
57 echo "#error UNVERSIONED tarball" >"$file.h"
58 exit 1
59 fi
60
61 # No version control, use the modification times
62 # of the source.
63 for s in "$@"
64 do
65 if [ "$s" -nt "$file" ]; then
66 modified=1
67 fi
68 done
69 fi
70
71 if [ "$current_version" != "$version" ]; then
72 echo "version update: $version"
73 echo "$version" >"$file"
74 fi
75
76 # Update the c-define for this version, take the modification
77 # flags into account.
78 version_modified="$version"
79 [ "$modified" -eq 1 ] && version_modified="$version_modified (modified)"
80
81 if [ -f "$file.h" ]; then
82 read d1 current_version_modified <"$file.h"
83 fi
84 if [ "$current_version_modified" != "$version_modified" ]; then
85 echo "version string: $version_modified"
86 echo "// $version_modified" >"$file.h"
87 echo "#define VERSION \"$version_modified\"" >>"$file.h"
88 fi
89
90 exit 0