Home | History | Annotate | Line # | Download | only in build
UpdatePoint revision 1.1.1.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  christos 	case "$betapoint::$rcpoint::$point" in
    131  1.1  christos 	 *::*::NEW)
    132  1.1  christos 	    # new minor release (no p)
    133  1.1  christos 	    crcp=z
    134  1.1  christos 	    # bp=1
    135  1.1  christos 	    ;;
    136  1.1  christos 	 0::::*)
    137  1.1  christos 	    # start of first beta cycle for the next point release
    138  1.1  christos 	    setpr=1
    139  1.1  christos 	    newpr=beta
    140  1.1  christos 	    # bp=1
    141  1.1  christos 	    bbp=1
    142  1.1  christos 	    ;;
    143  1.1  christos 	 0::[Gg][Oo]::*)
    144  1.1  christos 	    # skip all -beta and -RC prereleases to the next point.
    145  1.1  christos 	    crcp=z
    146  1.1  christos 	    setpr=1
    147  1.1  christos 	    newpr=
    148  1.1  christos 	    # bp=1
    149  1.1  christos 	    # bbp=0
    150  1.1  christos 	    ;;
    151  1.1  christos 	 *) echo "betapoint is <$betapoint>, rcpoint is <$rcpoint>"
    152  1.1  christos 	    echo "betapoint must be 0 and rcpoint must be empty to start the"
    153  1.1  christos 	    echo "beta cycle."
    154  1.1  christos 	    exit 1
    155  1.1  christos 	    ;;
    156  1.1  christos 	esac
    157  1.1  christos 	;;
    158  1.1  christos      beta)
    159  1.1  christos 	case "$betapoint::$rcpoint" in
    160  1.1  christos 	 [1-9]*::*)
    161  1.1  christos 	    bp=0
    162  1.1  christos 	    bbp=1
    163  1.1  christos 	    ;;
    164  1.1  christos 	 0::) echo "betapoint is 0, rcpoint emtpy, and prerelease is beta."
    165  1.1  christos 	    echo "You probably intended prerelease=  (that is, empty).  It"
    166  1.1  christos 	    echo "will then be changed to beta by this script, starting the"
    167  1.1  christos 	    echo "first beta for the next point release."
    168  1.1  christos 	    exit 1
    169  1.1  christos 	    ;;
    170  1.1  christos 	 *)
    171  1.1  christos 	    bp=0
    172  1.1  christos 	    bbp=1
    173  1.1  christos 	    ;;
    174  1.1  christos 	esac
    175  1.1  christos 	case "$rcpoint" in
    176  1.1  christos 	 [Gg][Oo])
    177  1.1  christos 	    echo "prerelease is beta, rcpoint is GO, disallowed."
    178  1.1  christos 	    echo "rcpoint GO is allowed only when prerelease is RC or empty."
    179  1.1  christos 	    exit 1
    180  1.1  christos 	    ;;
    181  1.1  christos 	esac
    182  1.1  christos 	;;
    183  1.1  christos      rc|RC)
    184  1.1  christos 	case "$rcpoint" in
    185  1.1  christos 	 '')
    186  1.1  christos 	    case "$betapoint" in
    187  1.1  christos 	     0) # bp=1
    188  1.1  christos 		;;
    189  1.1  christos 	     *) bp=0
    190  1.1  christos 		;;
    191  1.1  christos 	    esac
    192  1.1  christos 	    crcp=i
    193  1.1  christos 	    ;;
    194  1.1  christos 	 [1-9]*)
    195  1.1  christos 	    bp=0
    196  1.1  christos 	    crcp=i
    197  1.1  christos 	    ;;
    198  1.1  christos 	 [Gg][Oo])
    199  1.1  christos 	    bp=0
    200  1.1  christos 	    crcp=z
    201  1.1  christos 	    setpr=1
    202  1.1  christos 	    newpr=
    203  1.1  christos 	    ;;
    204  1.1  christos 	 *) echo "Unexpected value for 'rcpoint' <$rcpoint>!"
    205  1.1  christos 	    exit 1
    206  1.1  christos 	    ;;
    207  1.1  christos 	esac
    208  1.1  christos 	;;
    209  1.1  christos      *)
    210  1.1  christos 	echo "prerelease <$prerelease> unexpected"
    211  1.1  christos 	exit 1
    212  1.1  christos 	;;
    213  1.1  christos     esac
    214  1.1  christos     ;;
    215  1.1  christos  *) echo "impossible: repo <$repo>!"
    216  1.1  christos     exit 1
    217  1.1  christos     ;;
    218  1.1  christos esac
    219  1.1  christos 
    220  1.1  christos case "$bp::$point" in
    221  1.1  christos  0::*)
    222  1.1  christos     newpoint=$point
    223  1.1  christos     ;;
    224  1.1  christos  1::[1-9]*)
    225  1.1  christos     newpoint=`expr $point + 1`
    226  1.1  christos     ;;
    227  1.1  christos  1::)
    228  1.1  christos     newpoint=1
    229  1.1  christos     ;;
    230  1.1  christos  1::[Nn][Ee][Ww])
    231  1.1  christos     newpoint=
    232  1.1  christos     ;;
    233  1.1  christos  *) echo "Unexpected value for 'point' <$point>!"
    234  1.1  christos     exit 1
    235  1.1  christos     ;;
    236  1.1  christos esac
    237  1.1  christos 
    238  1.1  christos case "$bbp::$betapoint" in
    239  1.1  christos  0::*)
    240  1.1  christos     newbetapoint=$betapoint
    241  1.1  christos     ;;
    242  1.1  christos  1::[0-9]*)
    243  1.1  christos     newbetapoint=`expr $betapoint + 1`
    244  1.1  christos     ;;
    245  1.1  christos  *) echo "Unexpected value for 'betapoint' <$betapoint>!"
    246  1.1  christos     exit 1
    247  1.1  christos     ;;
    248  1.1  christos esac
    249  1.1  christos 
    250  1.1  christos case "$crcp::$rcpoint" in
    251  1.1  christos  n::*)
    252  1.1  christos     newrcpoint=$rcpoint
    253  1.1  christos     ;;
    254  1.1  christos  i::)
    255  1.1  christos     newrcpoint=1
    256  1.1  christos     ;;
    257  1.1  christos  i::[0-9]*)
    258  1.1  christos     newrcpoint=`expr $rcpoint + 1`
    259  1.1  christos     ;;
    260  1.1  christos  z::*)
    261  1.1  christos     newrcpoint=
    262  1.1  christos     newbetapoint=0
    263  1.1  christos     ;;
    264  1.1  christos  *) echo "Unexpected value for 'crcp::rcpoint' <$crcp::$rcpoint>!"
    265  1.1  christos     exit 1
    266  1.1  christos     ;;
    267  1.1  christos esac
    268  1.1  christos 
    269  1.1  christos case "$setpr" in
    270  1.1  christos  0)
    271  1.1  christos     newpr=$prerelease
    272  1.1  christos esac
    273  1.1  christos 
    274  1.1  christos # display results
    275  1.1  christos printf "prerelease		$prerelease"
    276  1.1  christos case "$newpr" in
    277  1.1  christos  $prerelease)
    278  1.1  christos     printf "\n"
    279  1.1  christos     ;;
    280  1.1  christos  *) printf " -> $newpr\n"
    281  1.1  christos     ;;
    282  1.1  christos esac
    283  1.1  christos printf "point			$point"
    284  1.1  christos case "$newpoint" in
    285  1.1  christos  $point)
    286  1.1  christos     printf "\n"
    287  1.1  christos     ;;
    288  1.1  christos  *) printf " -> $newpoint\n"
    289  1.1  christos     ;;
    290  1.1  christos esac
    291  1.1  christos printf "betapoint		$betapoint"
    292  1.1  christos case "$newbetapoint" in
    293  1.1  christos  $betapoint)
    294  1.1  christos     printf "\n"
    295  1.1  christos     ;;
    296  1.1  christos  *) printf " -> $newbetapoint\n"
    297  1.1  christos     ;;
    298  1.1  christos esac
    299  1.1  christos printf "rcpoint			$rcpoint"
    300  1.1  christos case "$newrcpoint" in
    301  1.1  christos  $rcpoint)
    302  1.1  christos     printf "\n"
    303  1.1  christos     ;;
    304  1.1  christos  *) printf " -> $newrcpoint\n"
    305  1.1  christos     ;;
    306  1.1  christos esac
    307  1.1  christos 
    308  1.1  christos printf "Previous version: "
    309  1.1  christos scripts/build/VersionName
    310  1.1  christos 
    311  1.1  christos # apply packageinfo.sh changes
    312  1.1  christos 
    313  1.1  christos sed -e "s/^point=.*/point=$newpoint/"			\
    314  1.1  christos     -e "s/^betapoint=.*/betapoint=$newbetapoint/"	\
    315  1.1  christos     -e "s/^rcpoint=.*/rcpoint=$newrcpoint/"		\
    316  1.1  christos     -e "s/^prerelease=.*/prerelease=$newpr/"		\
    317  1.1  christos 	< packageinfo.sh					\
    318  1.1  christos 	> packageinfo.sh+
    319  1.1  christos 
    320  1.1  christos case "$test" in
    321  1.1  christos  0)
    322  1.1  christos     mv packageinfo.sh+ packageinfo.sh
    323  1.1  christos     printf "Updated version: "
    324  1.1  christos     scripts/build/VersionName
    325  1.1  christos     ;;
    326  1.1  christos  *)
    327  1.1  christos     printf "Next version would be: "
    328  1.1  christos     scripts/build/VersionName -p ./packageinfo.sh+
    329  1.1  christos     rm packageinfo.sh+
    330  1.1  christos     ;;
    331  1.1  christos esac
    332