1#! /bin/sh 2 3# showusage is set to 1 on any command-line syntax error 4showusage=0 5# are we playing by stable or dev rules? 6repo= 7# test is set to 1 if -t/--test is given to prevent modifications 8test=0 9 10case "$#" in 11 1) repo=$1 12 ;; 13 2) repo=$2 14 case $1 in 15 -t|--test) 16 test=1 17 ;; 18 *) 19 showusage=1 20 ;; 21 esac 22 ;; 23 *) showusage=1 24 ;; 25esac 26 27case "$repo" in 28 dev|stable) 29 ;; 30 '') 31 showusage=1 32 ;; 33 *) echo "Unexpected repo type: <$repo>!" 34 showusage=1 35 ;; 36esac 37 38case "$showusage" in 39 1) echo "Usage: $0 [-t] <stable|dev>" 40 echo "No changes are made to packageinfo.sh if -t is given." 41 exit 1 42 ;; 43esac 44 45 46set -e 47 48. ./packageinfo.sh 49 50case "$repotype" in 51 $repo) 52 ;; 53 *) echo "You indicated repo type <$repo> but packageinfo.sh" 54 echo "indicates <$repotype>." 55 exit 1 56 ;; 57esac 58 59ver_repo_mismatch=1 60 61case "$minor" in 62 1|3|5|7|9) 63 case "$repo" in 64 dev) 65 ver_repo_mismatch=0 66 ;; 67 stable) 68 ;; 69 esac 70 ;; 71 0|2|4|6|8) 72 case "$repo" in 73 dev) 74 ;; 75 stable) 76 ver_repo_mismatch=0 77 ;; 78 esac 79 ;; 80esac 81 82case "$ver_repo_mismatch" in 83 1) echo "Minor version <$minor> mismatches repotype <$repo>." 84 exit 1 85 ;; 86esac 87 88# Do we want to bump the point? 89bp=1 90# Do we want to bump the beta point? 91bbp=0 92# Do we want to change the RC point? (n=no, z=empty rcpoint and zero 93# betapoint, i=incr) 94crcp=n 95# Do we want to change the prerelease value? 96setpr=0 97 98# for stable: 99# if we are not in a beta or RC state, enter beta unless point is NEW. 100# if we are in a beta state: 101# - bump the beta point 102# else if we are in an RC state: 103# - if rcpoint is GO: 104# - - set rcpoint= (empty) 105# - - set prerelease= (empty) 106# - - set betapoint=0 107# - else 108# - - if rcpoint==(empty) 109# - - - (bump-point) and set rcpoint to 0 (and fall thru, so -RC1 is first) 110# - - bump the RC point 111 112# for dev, we only want to bump-point and possibly clear prerelease, 113# but we do not modify rcpoint nor betapoint. 114 115case "$repo" in 116 dev) 117 case "$point" in 118 [Nn][Ee][Ww]) 119 crcp=z 120 ;; 121 *) 122 # crcp=n 123 ;; 124 esac 125 # bp=1 126 ;; 127 stable) 128 case "$prerelease" in 129 '') 130 case "$betapoint::$rcpoint::$point" in 131 *::*::NEW) 132 # new minor release (no p) 133 crcp=z 134 # bp=1 135 ;; 136 0::::*) 137 # start of first beta cycle for the next point release 138 setpr=1 139 newpr=beta 140 # bp=1 141 bbp=1 142 ;; 143 0::[Gg][Oo]::*) 144 # skip all -beta and -RC prereleases to the next point. 145 crcp=z 146 setpr=1 147 newpr= 148 # bp=1 149 # bbp=0 150 ;; 151 *) echo "betapoint is <$betapoint>, rcpoint is <$rcpoint>" 152 echo "betapoint must be 0 and rcpoint must be empty to start the" 153 echo "beta cycle." 154 exit 1 155 ;; 156 esac 157 ;; 158 beta) 159 case "$betapoint::$rcpoint" in 160 [1-9]*::*) 161 bp=0 162 bbp=1 163 ;; 164 0::) echo "betapoint is 0, rcpoint emtpy, and prerelease is beta." 165 echo "You probably intended prerelease= (that is, empty). It" 166 echo "will then be changed to beta by this script, starting the" 167 echo "first beta for the next point release." 168 exit 1 169 ;; 170 *) 171 bp=0 172 bbp=1 173 ;; 174 esac 175 case "$rcpoint" in 176 [Gg][Oo]) 177 echo "prerelease is beta, rcpoint is GO, disallowed." 178 echo "rcpoint GO is allowed only when prerelease is RC or empty." 179 exit 1 180 ;; 181 esac 182 ;; 183 rc|RC) 184 case "$rcpoint" in 185 '') 186 case "$betapoint" in 187 0) # bp=1 188 ;; 189 *) bp=0 190 ;; 191 esac 192 crcp=i 193 ;; 194 [1-9]*) 195 bp=0 196 crcp=i 197 ;; 198 [Gg][Oo]) 199 bp=0 200 crcp=z 201 setpr=1 202 newpr= 203 ;; 204 *) echo "Unexpected value for 'rcpoint' <$rcpoint>!" 205 exit 1 206 ;; 207 esac 208 ;; 209 *) 210 echo "prerelease <$prerelease> unexpected" 211 exit 1 212 ;; 213 esac 214 ;; 215 *) echo "impossible: repo <$repo>!" 216 exit 1 217 ;; 218esac 219 220case "$repo::$bp::$point" in 221 *::0::*) 222 newpoint=$point 223 ;; 224 dev::1::0) 225 newpoint=`expr $point + 1` 226 ;; 227 *::1::[1-9]*) 228 newpoint=`expr $point + 1` 229 ;; 230 dev::1::) 231 newpoint=0 232 ;; 233 stable::1::) 234 newpoint=1 235 ;; 236 *::1::[Nn][Ee][Ww]) 237 newpoint= 238 ;; 239 *) echo "Unexpected value for 'point' <$point>! (repo::bp::point is $repo::$bp::$point)" 240 exit 1 241 ;; 242esac 243 244case "$bbp::$betapoint" in 245 0::*) 246 newbetapoint=$betapoint 247 ;; 248 1::[0-9]*) 249 newbetapoint=`expr $betapoint + 1` 250 ;; 251 *) echo "Unexpected value for 'betapoint' <$betapoint>!" 252 exit 1 253 ;; 254esac 255 256case "$crcp::$rcpoint" in 257 n::*) 258 newrcpoint=$rcpoint 259 ;; 260 i::) 261 newrcpoint=1 262 ;; 263 i::[0-9]*) 264 newrcpoint=`expr $rcpoint + 1` 265 ;; 266 z::*) 267 newrcpoint= 268 newbetapoint=0 269 ;; 270 *) echo "Unexpected value for 'crcp::rcpoint' <$crcp::$rcpoint>!" 271 exit 1 272 ;; 273esac 274 275case "$setpr" in 276 0) 277 newpr=$prerelease 278esac 279 280# display results 281printf "prerelease $prerelease" 282case "$newpr" in 283 $prerelease) 284 printf "\n" 285 ;; 286 *) printf " -> $newpr\n" 287 ;; 288esac 289printf "point $point" 290case "$newpoint" in 291 $point) 292 printf "\n" 293 ;; 294 *) printf " -> $newpoint\n" 295 ;; 296esac 297printf "betapoint $betapoint" 298case "$newbetapoint" in 299 $betapoint) 300 printf "\n" 301 ;; 302 *) printf " -> $newbetapoint\n" 303 ;; 304esac 305printf "rcpoint $rcpoint" 306case "$newrcpoint" in 307 $rcpoint) 308 printf "\n" 309 ;; 310 *) printf " -> $newrcpoint\n" 311 ;; 312esac 313 314printf "Previous version: " 315scripts/build/VersionName 316 317# apply packageinfo.sh changes 318 319sed -e "s/^point=.*/point=$newpoint/" \ 320 -e "s/^betapoint=.*/betapoint=$newbetapoint/" \ 321 -e "s/^rcpoint=.*/rcpoint=$newrcpoint/" \ 322 -e "s/^prerelease=.*/prerelease=$newpr/" \ 323 < packageinfo.sh \ 324 > packageinfo.sh+ 325 326case "$test" in 327 0) 328 mv packageinfo.sh+ packageinfo.sh 329 printf "Updated version: " 330 scripts/build/VersionName 331 ;; 332 *) 333 printf "Next version would be: " 334 scripts/build/VersionName -p ./packageinfo.sh+ 335 rm packageinfo.sh+ 336 ;; 337esac 338