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