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