12b15cb3dSCy Schubert#! /bin/sh 22b15cb3dSCy Schubert 32b15cb3dSCy Schubert# showusage is set to 1 on any command-line syntax error 42b15cb3dSCy Schubertshowusage=0 52b15cb3dSCy Schubert# are we playing by stable or dev rules? 62b15cb3dSCy Schubertrepo= 72b15cb3dSCy Schubert# test is set to 1 if -t/--test is given to prevent modifications 82b15cb3dSCy Schuberttest=0 92b15cb3dSCy Schubert 102b15cb3dSCy Schubertcase "$#" in 112b15cb3dSCy Schubert 1) repo=$1 122b15cb3dSCy Schubert ;; 132b15cb3dSCy Schubert 2) repo=$2 142b15cb3dSCy Schubert case $1 in 152b15cb3dSCy Schubert -t|--test) 162b15cb3dSCy Schubert test=1 172b15cb3dSCy Schubert ;; 182b15cb3dSCy Schubert *) 192b15cb3dSCy Schubert showusage=1 202b15cb3dSCy Schubert ;; 212b15cb3dSCy Schubert esac 222b15cb3dSCy Schubert ;; 232b15cb3dSCy Schubert *) showusage=1 242b15cb3dSCy Schubert ;; 252b15cb3dSCy Schubertesac 262b15cb3dSCy Schubert 272b15cb3dSCy Schubertcase "$repo" in 282b15cb3dSCy Schubert dev|stable) 292b15cb3dSCy Schubert ;; 302b15cb3dSCy Schubert '') 312b15cb3dSCy Schubert showusage=1 322b15cb3dSCy Schubert ;; 332b15cb3dSCy Schubert *) echo "Unexpected repo type: <$repo>!" 342b15cb3dSCy Schubert showusage=1 352b15cb3dSCy Schubert ;; 362b15cb3dSCy Schubertesac 372b15cb3dSCy Schubert 382b15cb3dSCy Schubertcase "$showusage" in 392b15cb3dSCy Schubert 1) echo "Usage: $0 [-t] <stable|dev>" 402b15cb3dSCy Schubert echo "No changes are made to packageinfo.sh if -t is given." 412b15cb3dSCy Schubert exit 1 422b15cb3dSCy Schubert ;; 432b15cb3dSCy Schubertesac 442b15cb3dSCy Schubert 452b15cb3dSCy Schubert 462b15cb3dSCy Schubertset -e 472b15cb3dSCy Schubert 482b15cb3dSCy Schubert. ./packageinfo.sh 492b15cb3dSCy Schubert 502b15cb3dSCy Schubertcase "$repotype" in 512b15cb3dSCy Schubert $repo) 522b15cb3dSCy Schubert ;; 532b15cb3dSCy Schubert *) echo "You indicated repo type <$repo> but packageinfo.sh" 542b15cb3dSCy Schubert echo "indicates <$repotype>." 552b15cb3dSCy Schubert exit 1 562b15cb3dSCy Schubert ;; 572b15cb3dSCy Schubertesac 582b15cb3dSCy Schubert 592b15cb3dSCy Schubertver_repo_mismatch=1 602b15cb3dSCy Schubert 612b15cb3dSCy Schubertcase "$minor" in 622b15cb3dSCy Schubert 1|3|5|7|9) 632b15cb3dSCy Schubert case "$repo" in 642b15cb3dSCy Schubert dev) 652b15cb3dSCy Schubert ver_repo_mismatch=0 662b15cb3dSCy Schubert ;; 672b15cb3dSCy Schubert stable) 682b15cb3dSCy Schubert ;; 692b15cb3dSCy Schubert esac 702b15cb3dSCy Schubert ;; 712b15cb3dSCy Schubert 0|2|4|6|8) 722b15cb3dSCy Schubert case "$repo" in 732b15cb3dSCy Schubert dev) 742b15cb3dSCy Schubert ;; 752b15cb3dSCy Schubert stable) 762b15cb3dSCy Schubert ver_repo_mismatch=0 772b15cb3dSCy Schubert ;; 782b15cb3dSCy Schubert esac 792b15cb3dSCy Schubert ;; 802b15cb3dSCy Schubertesac 812b15cb3dSCy Schubert 822b15cb3dSCy Schubertcase "$ver_repo_mismatch" in 832b15cb3dSCy Schubert 1) echo "Minor version <$minor> mismatches repotype <$repo>." 842b15cb3dSCy Schubert exit 1 852b15cb3dSCy Schubert ;; 862b15cb3dSCy Schubertesac 872b15cb3dSCy Schubert 882b15cb3dSCy Schubert# Do we want to bump the point? 892b15cb3dSCy Schubertbp=1 902b15cb3dSCy Schubert# Do we want to bump the beta point? 912b15cb3dSCy Schubertbbp=0 922b15cb3dSCy Schubert# Do we want to change the RC point? (n=no, z=empty rcpoint and zero 932b15cb3dSCy Schubert# betapoint, i=incr) 942b15cb3dSCy Schubertcrcp=n 952b15cb3dSCy Schubert# Do we want to change the prerelease value? 962b15cb3dSCy Schubertsetpr=0 972b15cb3dSCy Schubert 982b15cb3dSCy Schubert# for stable: 992b15cb3dSCy Schubert# if we are not in a beta or RC state, enter beta unless point is NEW. 1002b15cb3dSCy Schubert# if we are in a beta state: 1012b15cb3dSCy Schubert# - bump the beta point 1022b15cb3dSCy Schubert# else if we are in an RC state: 1032b15cb3dSCy Schubert# - if rcpoint is GO: 1042b15cb3dSCy Schubert# - - set rcpoint= (empty) 1052b15cb3dSCy Schubert# - - set prerelease= (empty) 1062b15cb3dSCy Schubert# - - set betapoint=0 1072b15cb3dSCy Schubert# - else 1082b15cb3dSCy Schubert# - - if rcpoint==(empty) 1092b15cb3dSCy Schubert# - - - (bump-point) and set rcpoint to 0 (and fall thru, so -RC1 is first) 1102b15cb3dSCy Schubert# - - bump the RC point 1112b15cb3dSCy Schubert 1122b15cb3dSCy Schubert# for dev, we only want to bump-point and possibly clear prerelease, 1132b15cb3dSCy Schubert# but we do not modify rcpoint nor betapoint. 1142b15cb3dSCy Schubert 1152b15cb3dSCy Schubertcase "$repo" in 1162b15cb3dSCy Schubert dev) 1172b15cb3dSCy Schubert case "$point" in 1182b15cb3dSCy Schubert [Nn][Ee][Ww]) 1192b15cb3dSCy Schubert crcp=z 1202b15cb3dSCy Schubert ;; 1212b15cb3dSCy Schubert *) 1222b15cb3dSCy Schubert # crcp=n 1232b15cb3dSCy Schubert ;; 1242b15cb3dSCy Schubert esac 1252b15cb3dSCy Schubert # bp=1 1262b15cb3dSCy Schubert ;; 1272b15cb3dSCy Schubert stable) 1282b15cb3dSCy Schubert case "$prerelease" in 1292b15cb3dSCy Schubert '') 130*09100258SXin LI # echo "Checking <$betapoint::$rcpoint::$point>" 1312b15cb3dSCy Schubert case "$betapoint::$rcpoint::$point" in 1322b15cb3dSCy Schubert *::*::NEW) 1332b15cb3dSCy Schubert # new minor release (no p) 1342b15cb3dSCy Schubert crcp=z 1352b15cb3dSCy Schubert # bp=1 1362b15cb3dSCy Schubert ;; 1372b15cb3dSCy Schubert 0::::*) 1382b15cb3dSCy Schubert # start of first beta cycle for the next point release 1392b15cb3dSCy Schubert setpr=1 1402b15cb3dSCy Schubert newpr=beta 1412b15cb3dSCy Schubert # bp=1 1422b15cb3dSCy Schubert bbp=1 1432b15cb3dSCy Schubert ;; 1442b15cb3dSCy Schubert 0::[Gg][Oo]::*) 1452b15cb3dSCy Schubert # skip all -beta and -RC prereleases to the next point. 1462b15cb3dSCy Schubert crcp=z 1472b15cb3dSCy Schubert setpr=1 1482b15cb3dSCy Schubert newpr= 1492b15cb3dSCy Schubert # bp=1 1502b15cb3dSCy Schubert # bbp=0 1512b15cb3dSCy Schubert ;; 152*09100258SXin LI ::[Gg][Oo]::*) 153*09100258SXin LI # echo "Good - betapoint is empty. Look in $0 and figure out what's going on here." 154*09100258SXin LI crcp=z 155*09100258SXin LI ;; 156*09100258SXin LI *::[Gg][Oo]::*) 157*09100258SXin LI echo "betapoint is NOT empty. Look in $0 and figure out what's going on here." 158*09100258SXin LI test=1 159*09100258SXin LI ;; 1602b15cb3dSCy Schubert *) echo "betapoint is <$betapoint>, rcpoint is <$rcpoint>" 1612b15cb3dSCy Schubert echo "betapoint must be 0 and rcpoint must be empty to start the" 1622b15cb3dSCy Schubert echo "beta cycle." 1632b15cb3dSCy Schubert exit 1 1642b15cb3dSCy Schubert ;; 1652b15cb3dSCy Schubert esac 1662b15cb3dSCy Schubert ;; 1672b15cb3dSCy Schubert beta) 1682b15cb3dSCy Schubert case "$betapoint::$rcpoint" in 1692b15cb3dSCy Schubert [1-9]*::*) 1702b15cb3dSCy Schubert bp=0 1712b15cb3dSCy Schubert bbp=1 1722b15cb3dSCy Schubert ;; 1732b15cb3dSCy Schubert 0::) echo "betapoint is 0, rcpoint emtpy, and prerelease is beta." 1742b15cb3dSCy Schubert echo "You probably intended prerelease= (that is, empty). It" 1752b15cb3dSCy Schubert echo "will then be changed to beta by this script, starting the" 1762b15cb3dSCy Schubert echo "first beta for the next point release." 1772b15cb3dSCy Schubert exit 1 1782b15cb3dSCy Schubert ;; 1792b15cb3dSCy Schubert *) 1802b15cb3dSCy Schubert bp=0 1812b15cb3dSCy Schubert bbp=1 1822b15cb3dSCy Schubert ;; 1832b15cb3dSCy Schubert esac 1842b15cb3dSCy Schubert case "$rcpoint" in 1852b15cb3dSCy Schubert [Gg][Oo]) 1862b15cb3dSCy Schubert echo "prerelease is beta, rcpoint is GO, disallowed." 1872b15cb3dSCy Schubert echo "rcpoint GO is allowed only when prerelease is RC or empty." 1882b15cb3dSCy Schubert exit 1 1892b15cb3dSCy Schubert ;; 1902b15cb3dSCy Schubert esac 1912b15cb3dSCy Schubert ;; 1922b15cb3dSCy Schubert rc|RC) 1932b15cb3dSCy Schubert case "$rcpoint" in 1942b15cb3dSCy Schubert '') 1952b15cb3dSCy Schubert case "$betapoint" in 1962b15cb3dSCy Schubert 0) # bp=1 1972b15cb3dSCy Schubert ;; 1982b15cb3dSCy Schubert *) bp=0 1992b15cb3dSCy Schubert ;; 2002b15cb3dSCy Schubert esac 2012b15cb3dSCy Schubert crcp=i 2022b15cb3dSCy Schubert ;; 2032b15cb3dSCy Schubert [1-9]*) 2042b15cb3dSCy Schubert bp=0 2052b15cb3dSCy Schubert crcp=i 2062b15cb3dSCy Schubert ;; 2072b15cb3dSCy Schubert [Gg][Oo]) 2082b15cb3dSCy Schubert bp=0 2092b15cb3dSCy Schubert crcp=z 2102b15cb3dSCy Schubert setpr=1 2112b15cb3dSCy Schubert newpr= 2122b15cb3dSCy Schubert ;; 2132b15cb3dSCy Schubert *) echo "Unexpected value for 'rcpoint' <$rcpoint>!" 2142b15cb3dSCy Schubert exit 1 2152b15cb3dSCy Schubert ;; 2162b15cb3dSCy Schubert esac 2172b15cb3dSCy Schubert ;; 2182b15cb3dSCy Schubert *) 2192b15cb3dSCy Schubert echo "prerelease <$prerelease> unexpected" 2202b15cb3dSCy Schubert exit 1 2212b15cb3dSCy Schubert ;; 2222b15cb3dSCy Schubert esac 2232b15cb3dSCy Schubert ;; 2242b15cb3dSCy Schubert *) echo "impossible: repo <$repo>!" 2252b15cb3dSCy Schubert exit 1 2262b15cb3dSCy Schubert ;; 2272b15cb3dSCy Schubertesac 2282b15cb3dSCy Schubert 2292b15cb3dSCy Schubertcase "$repo::$bp::$point" in 2302b15cb3dSCy Schubert *::0::*) 2312b15cb3dSCy Schubert newpoint=$point 2322b15cb3dSCy Schubert ;; 2332b15cb3dSCy Schubert dev::1::0) 2342b15cb3dSCy Schubert newpoint=`expr $point + 1` 2352b15cb3dSCy Schubert ;; 2362b15cb3dSCy Schubert *::1::[1-9]*) 2372b15cb3dSCy Schubert newpoint=`expr $point + 1` 2382b15cb3dSCy Schubert ;; 2392b15cb3dSCy Schubert dev::1::) 2402b15cb3dSCy Schubert newpoint=0 2412b15cb3dSCy Schubert ;; 2422b15cb3dSCy Schubert stable::1::) 2432b15cb3dSCy Schubert newpoint=1 2442b15cb3dSCy Schubert ;; 2452b15cb3dSCy Schubert *::1::[Nn][Ee][Ww]) 2462b15cb3dSCy Schubert newpoint= 2472b15cb3dSCy Schubert ;; 2482b15cb3dSCy Schubert *) echo "Unexpected value for 'point' <$point>! (repo::bp::point is $repo::$bp::$point)" 2492b15cb3dSCy Schubert exit 1 2502b15cb3dSCy Schubert ;; 2512b15cb3dSCy Schubertesac 2522b15cb3dSCy Schubert 2532b15cb3dSCy Schubertcase "$bbp::$betapoint" in 2542b15cb3dSCy Schubert 0::*) 2552b15cb3dSCy Schubert newbetapoint=$betapoint 2562b15cb3dSCy Schubert ;; 2572b15cb3dSCy Schubert 1::[0-9]*) 2582b15cb3dSCy Schubert newbetapoint=`expr $betapoint + 1` 2592b15cb3dSCy Schubert ;; 2602b15cb3dSCy Schubert *) echo "Unexpected value for 'betapoint' <$betapoint>!" 2612b15cb3dSCy Schubert exit 1 2622b15cb3dSCy Schubert ;; 2632b15cb3dSCy Schubertesac 2642b15cb3dSCy Schubert 2652b15cb3dSCy Schubertcase "$crcp::$rcpoint" in 2662b15cb3dSCy Schubert n::*) 2672b15cb3dSCy Schubert newrcpoint=$rcpoint 2682b15cb3dSCy Schubert ;; 2692b15cb3dSCy Schubert i::) 2702b15cb3dSCy Schubert newrcpoint=1 2712b15cb3dSCy Schubert ;; 2722b15cb3dSCy Schubert i::[0-9]*) 2732b15cb3dSCy Schubert newrcpoint=`expr $rcpoint + 1` 2742b15cb3dSCy Schubert ;; 2752b15cb3dSCy Schubert z::*) 2762b15cb3dSCy Schubert newrcpoint= 277*09100258SXin LI case "$repo" in 278*09100258SXin LI dev) 2792b15cb3dSCy Schubert newbetapoint=0 2802b15cb3dSCy Schubert ;; 281*09100258SXin LI stable) 282*09100258SXin LI newbetapoint= 283*09100258SXin LI ;; 284*09100258SXin LI *) 285*09100258SXin LI echo "crcp::rcpoint - bogus repo <$repo>" 286*09100258SXin LI exit 1 287*09100258SXin LI ;; 288*09100258SXin LI esac 289*09100258SXin LI ;; 2902b15cb3dSCy Schubert *) echo "Unexpected value for 'crcp::rcpoint' <$crcp::$rcpoint>!" 2912b15cb3dSCy Schubert exit 1 2922b15cb3dSCy Schubert ;; 2932b15cb3dSCy Schubertesac 2942b15cb3dSCy Schubert 2952b15cb3dSCy Schubertcase "$setpr" in 2962b15cb3dSCy Schubert 0) 2972b15cb3dSCy Schubert newpr=$prerelease 2982b15cb3dSCy Schubertesac 2992b15cb3dSCy Schubert 3002b15cb3dSCy Schubert# display results 3012b15cb3dSCy Schubertprintf "prerelease $prerelease" 3022b15cb3dSCy Schubertcase "$newpr" in 3032b15cb3dSCy Schubert $prerelease) 3042b15cb3dSCy Schubert printf "\n" 3052b15cb3dSCy Schubert ;; 3062b15cb3dSCy Schubert *) printf " -> $newpr\n" 3072b15cb3dSCy Schubert ;; 3082b15cb3dSCy Schubertesac 3092b15cb3dSCy Schubertprintf "point $point" 3102b15cb3dSCy Schubertcase "$newpoint" in 3112b15cb3dSCy Schubert $point) 3122b15cb3dSCy Schubert printf "\n" 3132b15cb3dSCy Schubert ;; 3142b15cb3dSCy Schubert *) printf " -> $newpoint\n" 3152b15cb3dSCy Schubert ;; 3162b15cb3dSCy Schubertesac 3172b15cb3dSCy Schubertprintf "betapoint $betapoint" 3182b15cb3dSCy Schubertcase "$newbetapoint" in 3192b15cb3dSCy Schubert $betapoint) 3202b15cb3dSCy Schubert printf "\n" 3212b15cb3dSCy Schubert ;; 3222b15cb3dSCy Schubert *) printf " -> $newbetapoint\n" 3232b15cb3dSCy Schubert ;; 3242b15cb3dSCy Schubertesac 3252b15cb3dSCy Schubertprintf "rcpoint $rcpoint" 3262b15cb3dSCy Schubertcase "$newrcpoint" in 3272b15cb3dSCy Schubert $rcpoint) 3282b15cb3dSCy Schubert printf "\n" 3292b15cb3dSCy Schubert ;; 3302b15cb3dSCy Schubert *) printf " -> $newrcpoint\n" 3312b15cb3dSCy Schubert ;; 3322b15cb3dSCy Schubertesac 3332b15cb3dSCy Schubert 3342b15cb3dSCy Schubertprintf "Previous version: " 3352b15cb3dSCy Schubertscripts/build/VersionName 3362b15cb3dSCy Schubert 3372b15cb3dSCy Schubert# apply packageinfo.sh changes 3382b15cb3dSCy Schubert 3392b15cb3dSCy Schubertsed -e "s/^point=.*/point=$newpoint/" \ 3402b15cb3dSCy Schubert -e "s/^betapoint=.*/betapoint=$newbetapoint/" \ 3412b15cb3dSCy Schubert -e "s/^rcpoint=.*/rcpoint=$newrcpoint/" \ 3422b15cb3dSCy Schubert -e "s/^prerelease=.*/prerelease=$newpr/" \ 3432b15cb3dSCy Schubert < packageinfo.sh \ 3442b15cb3dSCy Schubert > packageinfo.sh+ 3452b15cb3dSCy Schubert 3462b15cb3dSCy Schubertcase "$test" in 3472b15cb3dSCy Schubert 0) 3482b15cb3dSCy Schubert mv packageinfo.sh+ packageinfo.sh 3492b15cb3dSCy Schubert printf "Updated version: " 3502b15cb3dSCy Schubert scripts/build/VersionName 3512b15cb3dSCy Schubert ;; 3522b15cb3dSCy Schubert *) 3532b15cb3dSCy Schubert printf "Next version would be: " 3542b15cb3dSCy Schubert scripts/build/VersionName -p ./packageinfo.sh+ 3552b15cb3dSCy Schubert rm packageinfo.sh+ 3562b15cb3dSCy Schubert ;; 3572b15cb3dSCy Schubertesac 358