nice new tool to show version of feisty meow
[feisty_meow.git] / scripts / generator / show_version.sh
1 #!/bin/bash
2
3 # increments the build version number.
4
5 #mkdir -p "$TEMPORARIES_PILE"
6
7 #hmmm: looks like repeated reusable code below (compare with next_version)
8 export PARAMETER_FILE
9 if [ ! -z "$BUILD_PARAMETER_FILE" ]; then
10   # define our version of the build parameter file.  this should be set
11   # beforehand so we override the default parameter file for clam.
12   PARAMETER_FILE="$BUILD_PARAMETER_FILE"
13 fi
14 if [ -z "$PARAMETER_FILE" ]; then
15   # last ditch attempt to get one that will work.
16   PARAMETER_FILE="$FEISTY_MEOW_APEX/build.ini"
17 fi
18
19 #chmod u+w "$PARAMETER_FILE"
20
21 #new_buildini="$(mktemp "$TEMPORARIES_PILE/buildini.XXXXXX")"
22 ## whack the file just in case.
23 #rm -f "$new_buildini"
24 #echo -n "" >"$new_buildini"
25
26 # pick a weird separator that we hope never to see.
27 IFS='~'
28
29 found_version=""
30 skip_line=""
31
32 major_string=
33 minor_string=
34 revision_string=
35
36 #hmmm: now i know i'm having deja vu.  this loop is a big chunk of reusable code that should be abstracted from this file and from next_version
37
38 while read line_found; do
39   if [ $? != 0 ]; then break; fi
40 #echo line found is $line_found
41   if [ ! -z "$skip_line" ]; then
42     # we were told to skip this line to fix win32.
43     skip_line=""
44     continue
45   fi
46
47   # these checks don't care about whether we've seen other stuff yet.
48   if [ -z "$major_string" ]; then
49     if [ ! -z "$(echo $line_found | sed -n -e 's/^ *major *=.*$/yep/p')" ]; then
50       major_string=$(echo $line_found | sed -e 's/.*=\(.*\)$/\1/' )
51     fi
52   fi
53   if [ -z "$minor_string" ]; then
54     if [ ! -z "$(echo $line_found | sed -n -e 's/^ *minor *=.*$/yep/p')" ]; then
55       minor_string=$(echo $line_found | sed -e 's/.*=\(.*\)$/\1/' )
56     fi
57   fi
58
59   # we process the revision string line specially.
60   if [ -z "$found_version" ]; then
61         if [ "$line_found" == "#[version]" ]; then
62           # repair our special escape that makes this a valid ini file and
63           # gnu make include file.
64 #         echo -e "#\\\\\n[version]" >>"$new_buildini"
65           found_version="yes"
66       continue
67         elif [ "$line_found" == "#" ]; then
68           # retarded win32 case.
69 #         echo -e "#\\\\\n[version]" >>"$new_buildini"
70           found_version="yes"
71           skip_line="yes"
72       continue
73         fi
74   elif [ -z "$revision_string" ]; then
75     if [ ! -z "$(echo $line_found | sed -n -e 's/^ *revision *=.*$/yep/p')" ]; then
76       revision_string=$(echo $line_found | sed -e 's/.*=\(.*\)$/\1/' )
77 #echo second part is $revision_string 
78       revision_string=$(expr $revision_string + 1)
79 #      echo "revision=$revision_string" >>"$new_buildini"
80       # don't print the line normally also.
81       continue
82     fi
83   fi
84
85   # send the line with no special processing.
86 #  echo "$line_found" >>"$new_buildini"
87
88 done <"$PARAMETER_FILE"
89
90 ## if we created something with contents, let's use it.
91 #if [ -s "$new_buildini" ]; then
92 #  cp "$new_buildini" "$PARAMETER_FILE"
93 #fi
94
95 echo "Current build version is: $major_string.$minor_string.$revision_string"
96
97 # don't leave the temporary version files floating around.
98 #rm -f "$new_buildini"
99