root/juggler/trunk/release/scripts/make-ver.sh

Revision 20974, 4.1 kB (checked in by patrick, 1 year ago)

Copyright update.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/bin/sh
2
3 # ************** <auto-copyright.pl BEGIN do not edit this line> **************
4 #
5 # VR Juggler is (C) Copyright 1998-2008 by Iowa State University
6 #
7 # Original Authors:
8 #   Allen Bierbaum, Christopher Just,
9 #   Patrick Hartling, Kevin Meinert,
10 #   Carolina Cruz-Neira, Albert Baker
11 #
12 # This library is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU Library General Public
14 # License as published by the Free Software Foundation; either
15 # version 2 of the License, or (at your option) any later version.
16 #
17 # This library is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 # Library General Public License for more details.
21 #
22 # You should have received a copy of the GNU Library General Public
23 # License along with this library; if not, write to the
24 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 # Boston, MA 02111-1307, USA.
26 #
27 # *************** <auto-copyright.pl END do not edit this line> ***************
28
29 branch=''
30 date='-1'
31 ver_file='-1'
32 input='-1'
33 output='-1'
34 name='-1'
35 subsystem='-1'
36 version='-1'
37
38 while [ $# -gt 0 ]; do
39     case $1 in
40         -b)
41             branch="$2"
42             shift
43             shift
44             ;;
45         -d)
46             date="$2"
47             shift
48             shift
49             ;;
50         -f)
51             ver_file="$2"
52             shift
53             shift
54             ;;
55         -i)
56             input="$2"
57             shift
58             shift
59             ;;
60         -n)
61             name="$2"
62             shift
63             shift
64             ;;
65         -o)
66             output="$2"
67             shift
68             shift
69             ;;
70         -s)
71             subsystem="$2"
72             shift
73             shift
74             ;;
75         -v)
76             version="$2"
77             shift
78             shift
79             ;;
80         *)
81             echo "WARNING: Unknown argument '$1'"
82             shift
83             ;;
84     esac
85 done
86
87 if [ "x$date" = "x-1" -o "x$input" = "x-1" -o "x$output" = "x-1" ]; then
88     echo "Usage: $0"
89     echo "       [-b branch] -d <date> -i <input file> -o <output file>"
90     echo "       [-s <subsystem> -f <VERSION file> | -v <version> ]"
91     echo "       [-n <name>]"
92     exit 1
93 fi
94
95 if [ "x$ver_file" = "x-1" -a "x$version" = "x-1" ]; then
96     echo "Must give a version number or a VERSION file!"
97     exit 1
98 fi
99
100 # If a version number was given, use it.
101 if [ "x$version" != "x-1" ]; then
102     ver_num="$version"
103 # Otherwise, read the version number from the top of $ver_file.
104 else
105     if [ ! -r "$ver_file" ]; then
106         echo "ERROR: Could not read $ver_file"
107         exit 1
108     fi
109
110     ver_line=`head -1 $ver_file`
111     ver_num=`echo $ver_line |  sed -e 's/^\(.*\) @.*/\1/'`
112 fi
113
114 # If a canonical name was given, include it.
115 if [ "x$name" != "x-1" ]; then
116     string="v$ver_num '$name' ($subsystem) $branch $date"
117 else
118     string="v$ver_num ($subsystem) $branch $date"
119 fi
120
121 # Make sure we can read from $input.
122 if [ ! -r "$input" ]; then
123     echo "ERROR: Could not read $input"
124     exit 1
125 fi
126
127 # Extract the major, minor, and patch numbers and reconstruct them as a single
128 # integer.
129 major=`echo $ver_num | sed -e 's/^\([0-9][0-9]*\)\..*/\1/'`
130 minor=`echo $ver_num | sed -e 's/^.*\.\([0-9][0-9]*\)\..*$/\1/'`
131 patch=`echo $ver_num | sed -e 's/^.*\.\([0-9][0-9]*\)-.*$/\1/'`
132 number=`printf "%03d%03d%03d\n" $major $minor $patch | sed -e 's/^[0]*\([^0].*\)$/\1/'`
133
134 # Create the temporary ouptut file.
135 cat $input | sed -e "s|@VER_STRING@|\"$string\"|"       \
136                  -e "s/@VER_NUMBER@/$number/"           \
137                  -e "s/@MAJOR_VER_NUMBER@/$major/"      \
138                  -e "s/@MINOR_VER_NUMBER@/$minor/"      \
139                  -e "s/@PATCH_VER_NUMBER@/$patch/"      \
140            > ${output}.temp
141
142 # If the output file already exists, compare it with the temporary version.
143 # If the two are the same, there is no need to overwrite $output.
144 if [ -r "$output" ]; then
145     if cmp -s "$output" "${output}.temp" 2>/dev/null ; then
146         echo "$output is unchanged"
147         rm -f "${output}.temp"
148     else
149         mv -f "${output}.temp" "$output"
150     fi
151 else
152     mv -f "${output}.temp" "$output"
153 fi
154
155 exit 0
Note: See TracBrowser for help on using the browser.