pck-update (a4): allow a distribution-ID "upgrade" when updating the release number (example: 1mamba --> 2mamba2)

Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
This commit is contained in:
Davide Madrisan 2012-05-29 23:20:59 +02:00
parent 90968556d3
commit a14b989d3a
2 changed files with 26 additions and 9 deletions

View File

@ -1,3 +1,15 @@
Changes in version 1.12.3
+ improvement
* pck-update - Davide Madrisan:
Action 4: allow a distribution-ID "upgrade" when updating the release
number.
Example: 1mamba --> 2mamba2
(when DISTRO_rpm="mamba2" is set in the configuration files).
Feature asked by Silvan Calarco.
-------------------------------------------------------------------------------
Changes in version 1.12.2
Mon May 28 2012 Davide Madrisan <davide.madrisan(a)gmail.com>

View File

@ -593,32 +593,37 @@ function specfile.newrelease() {
( . $infofile
# NOTE: allowed format is: '<version><distroid>'
[[ "$SPEC_RELEASE" =~ ^[0-9]+(\.[0-9]+){0,}[^0-9\.]+.*$ ]] ||
# NOTE: allowed format is: '<number[.<number>]*<distroid><dnumber>'
# <dnumber> will permit a distroid "upgrade": mamba --> mamba2
[[ "$SPEC_RELEASE" =~ ^[0-9]+(\.[0-9]+){0,}[^0-9\.]+[0-9]*$ ]] ||
notify.error \
$"release number: unsupported format"": \"$SPEC_RELEASE\""
if [ "$pck_newver" = $SPEC_VERSION ]; then
# the release has been specified at command line
if [ "$pck_newrel" ]; then
[[ "$pck_newrel" =~ ^[0-9]+.*${DISTRO_rpm}$ ]] ||
[[ "$pck_newrel" =~ ^[0-9]+(\.[0-9]+){0,}[^0-9\.]+[0-9]*$ ]] ||
notify.error \
$"release number: unsupported format"": \"$pck_newrel\""
$"release number: unsupported format"": \"$pck_newrel\""
[ "$pck_newrel" '>' "$SPEC_RELEASE" ] ||
notify.error $"\
new release \`$pck_newrel' must be greater than current one \`$SPEC_RELEASE'"
echo "$pck_newrel"
else
# example: 123.45.67mamba2 --> sr_relnum = 123.45.67
local sr_relnum="${SPEC_RELEASE%%[^0-9\.]*}"
local sr_distroid="${SPEC_RELEASE/$sr_relnum}"
notify.debug "$FUNCNAME: sr_relnum = \"$sr_relnum\""
notify.debug "$FUNCNAME: sr_distroid = \"$sr_distroid\""
# example: 123.45.67mamba2 --> sr_distroid = mamba2
local sr_distroid="${SPEC_RELEASE/$sr_relnum}"
[[ "$SPEC_RELEASE" =~ ^[0-9]+(\.[0-9]+){1,}[^\.]*$ ]] &&
# example: 13.155.24<distroid> --> 13.155.25${DISTRO_rpm}
[[ "$SPEC_RELEASE" =~ ^[0-9]+(\.[0-9]+){1,}${sr_distroid}$ ]] \
&& \
{ echo "${sr_relnum%\.*}.$(( ${sr_relnum/*\./} + 1 ))${DISTRO_rpm}"
return 0; }
# '<[0-9]+><distroid>'
[[ "$SPEC_RELEASE" =~ ^[0-9]+[^0-9]+$ ]] &&
# example: 12<distroid> --> 13${DISTRO_rpm}
[[ "$SPEC_RELEASE" =~ ^[0-9]+${sr_distroid}$ ]] &&
{ echo "$(( $sr_relnum + 1 ))${DISTRO_rpm}"
return 0; }