[packages/rpm-build-tools] doc for try_upgrade, try make it more readable
glen
glen at pld-linux.org
Tue Mar 4 22:41:53 CET 2014
commit 52a2ef00e8fec0d74192471b727d8f67c8338131
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Tue Mar 4 23:40:47 2014 +0200
doc for try_upgrade, try make it more readable
builder.sh | 83 +++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 47 insertions(+), 36 deletions(-)
---
diff --git a/builder.sh b/builder.sh
index b997716..72c5f66 100755
--- a/builder.sh
+++ b/builder.sh
@@ -1510,50 +1510,61 @@ set_version() {
" $specfile
}
+# try to upgrade .spec to new version
+# if --upgrade-version is specified, use that as new version, otherwise invoke pldnotify to find new version
+#
+# return 1: if .spec was updated
+# return 0: no changes to .spec
+# exit 1 in case of error
try_upgrade() {
- if [ -n "$TRY_UPGRADE" ]; then
- local TNOTIFY TNEWVER TOLDVER
- update_shell_title "build_package: try_upgrade"
+ if [ -z "$TRY_UPGRADE" ]; then
+ return 0
+ fi
- cd "$PACKAGE_DIR"
-
- if [ "$UPGRADE_VERSION" ]; then
- TNEWVER=$UPGRADE_VERSION
- else
- if [ -n "$FLOAT_VERSION" ]; then
- TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
- else
- TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
- fi
+ local TNOTIFY TNEWVER TOLDVER
+ update_shell_title "build_package: try_upgrade"
- # pldnotify.awk does not set exit codes, but it has match for ERROR
- # in output which means so.
- if [[ "$TNOTIFY" = *ERROR* ]]; then
- echo >&2 "$TNOTIFY"
- exit 1
- fi
+ cd "$PACKAGE_DIR"
- TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
+ if [ "$UPGRADE_VERSION" ]; then
+ TNEWVER=$UPGRADE_VERSION
+ echo "Updating spec file to version $TNEWVER"
+ else
+ if [ -n "$FLOAT_VERSION" ]; then
+ TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
+ else
+ TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
fi
- if [ -n "$TNEWVER" ]; then
- TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
- echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
- if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
- cp -f $SPECFILE $SPECFILE.bak
- fi
- chmod +w $SPECFILE
- set_release $SPECFILE $PACKAGE_RELEASE 1
- set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
- parse_spec
- if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
- echo >&2 "Upgrading version failed, you need to update spec yourself"
- exit 1
- fi
- return 1
+ # pldnotify.awk does not set exit codes, but it has match for ERROR
+ # in output which means so.
+ if [[ "$TNOTIFY" = *ERROR* ]]; then
+ echo >&2 "$TNOTIFY"
+ exit 1
fi
+
+ TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
+ echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
+
+ TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
+ fi
+
+ if [ -z "$TNEWVER" ]; then
+ return 0
+ fi
+
+ if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
+ cp -f $SPECFILE $SPECFILE.bak
fi
- return 0
+ chmod +w $SPECFILE
+ set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
+ set_release $SPECFILE $PACKAGE_RELEASE 1
+ parse_spec
+ if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
+ echo >&2 "Upgrading version failed, you need to update spec yourself"
+ exit 1
+ fi
+ return 1
}
build_package() {
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/52a2ef00e8fec0d74192471b727d8f67c8338131
More information about the pld-cvs-commit
mailing list