[pacman-dev] [PATCH] Manually check xdelta exit codes.
This is needed because 'xdelta delta' returns 1 even when the delta creation succeeds. This was causing makepkg to exit after the command due to bash's -e option. Some information from the xdelta man page: The delta command exits with status 0 to indicate that no differences were found, with status 1 to indicate that some differences were found, and with status 2 to indicate an error of some kind. Signed-off-by: Nathan Jones <nathanj@insightbb.com> --- scripts/makepkg.sh.in | 30 +++++++++++++++++++++++------- 1 files changed, 23 insertions(+), 7 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4a68c84..193afe4 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -900,17 +900,33 @@ create_xdelta() { msg "$(gettext "Making delta from version %s...")" "$latest_version" local delta_file="$PKGDEST/$pkgname-${latest_version}_to_$pkgver-$pkgrel-$CARCH.delta" + # 'xdelta delta' returns 1 even on success, so manually check exit codes + # bash's exit on error option must first be unset + set +e + # xdelta will decompress base_file & pkg_file into TMP_DIR (or /tmp if # TMP_DIR is unset) then perform the delta on the resulting tars xdelta delta "$base_file" "$pkg_file" "$delta_file" - # Generate the final gz using xdelta for compression. xdelta will be our - # common denominator compression utility between the packager and the users - # makepkg and pacman must use the same compression algorithm or the delta - # generated package may not match, producing md5 checksum errors. - msg2 "$(gettext "Recreating package tarball from delta to match md5 signatures")" - msg2 "$(gettext "NOTE: the delta should ONLY be distributed with this tarball")" - xdelta patch "$delta_file" "$base_file" "$pkg_file" + if [ $? = 0 -o $? = 1 ]; then + # Generate the final gz using xdelta for compression. xdelta will be our + # common denominator compression utility between the packager and the + # users. makepkg and pacman must use the same compression algorithm or + # the delta generated package may not match, producing md5 checksum + # errors. + msg2 "$(gettext "Recreating package tarball from delta to match md5 signatures")" + msg2 "$(gettext "NOTE: the delta should ONLY be distributed with this tarball")" + xdelta patch "$delta_file" "$base_file" "$pkg_file" + if [ $? != 0 ]; then + error "$(gettext "Could not generate the package from the delta.")" + exit 1 + fi + else + warning "$(gettext "Delta was not able to be created.")" + fi + + # turn exit on error back on + set -e else warning "$(gettext "No previous version found, skipping xdelta.")" fi -- 1.5.3.4
On Sat, Oct 13, 2007 at 05:00:25PM -0400, Nathan Jones wrote:
+ # 'xdelta delta' returns 1 even on success, so manually check exit codes + # bash's exit on error option must first be unset + set +e
I figured out how to get return codes without using the set command by looking through the rest of makepkg. I will resubmit this patch, so please ignore this one.
This is needed because 'xdelta delta' returns 1 even when the delta creation succeeds. This was causing makepkg to exit after the command due to bash's -e option. Some information from the xdelta man page: The delta command exits with status 0 to indicate that no differences were found, with status 1 to indicate that some differences were found, and with status 2 to indicate an error of some kind. Signed-off-by: Nathan Jones <nathanj@insightbb.com> --- scripts/makepkg.sh.in | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4a68c84..4399076 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -899,18 +899,29 @@ create_xdelta() { if [ "$base_file" != "" ]; then msg "$(gettext "Making delta from version %s...")" "$latest_version" local delta_file="$PKGDEST/$pkgname-${latest_version}_to_$pkgver-$pkgrel-$CARCH.delta" + local ret=0 # xdelta will decompress base_file & pkg_file into TMP_DIR (or /tmp if # TMP_DIR is unset) then perform the delta on the resulting tars - xdelta delta "$base_file" "$pkg_file" "$delta_file" - - # Generate the final gz using xdelta for compression. xdelta will be our - # common denominator compression utility between the packager and the users - # makepkg and pacman must use the same compression algorithm or the delta - # generated package may not match, producing md5 checksum errors. - msg2 "$(gettext "Recreating package tarball from delta to match md5 signatures")" - msg2 "$(gettext "NOTE: the delta should ONLY be distributed with this tarball")" - xdelta patch "$delta_file" "$base_file" "$pkg_file" + xdelta delta "$base_file" "$pkg_file" "$delta_file" || ret=$? + + if [ $ret -eq 0 -o $ret -eq 1 ]; then + # Generate the final gz using xdelta for compression. xdelta will be our + # common denominator compression utility between the packager and the + # users. makepkg and pacman must use the same compression algorithm or + # the delta generated package may not match, producing md5 checksum + # errors. + msg2 "$(gettext "Recreating package tarball from delta to match md5 signatures")" + msg2 "$(gettext "NOTE: the delta should ONLY be distributed with this tarball")" + ret=0 + xdelta patch "$delta_file" "$base_file" "$pkg_file" || ret=$? + if [ $ret -ne 0 ]; then + error "$(gettext "Could not generate the package from the delta.")" + exit 1 + fi + else + warning "$(gettext "Delta was not able to be created.")" + fi else warning "$(gettext "No previous version found, skipping xdelta.")" fi -- 1.5.3.4
On 10/14/07, Nathan Jones <nathanj@insightbb.com> wrote:
This is needed because 'xdelta delta' returns 1 even when the delta creation succeeds. This was causing makepkg to exit after the command due to bash's -e option.
Some information from the xdelta man page: The delta command exits with status 0 to indicate that no differences were found, with status 1 to indicate that some differences were found, and with status 2 to indicate an error of some kind.
Signed-off-by: Nathan Jones <nathanj@insightbb.com> --- scripts/makepkg.sh.in | 29 ++++++++++++++++++++--------- 1 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4a68c84..4399076 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -899,18 +899,29 @@ create_xdelta() { if [ "$base_file" != "" ]; then msg "$(gettext "Making delta from version %s...")" "$latest_version" local delta_file="$PKGDEST/$pkgname-${latest_version}_to_$pkgver-$pkgrel-$CARCH.delta" + local ret=0
# xdelta will decompress base_file & pkg_file into TMP_DIR (or /tmp if # TMP_DIR is unset) then perform the delta on the resulting tars - xdelta delta "$base_file" "$pkg_file" "$delta_file" - - # Generate the final gz using xdelta for compression. xdelta will be our - # common denominator compression utility between the packager and the users - # makepkg and pacman must use the same compression algorithm or the delta - # generated package may not match, producing md5 checksum errors. - msg2 "$(gettext "Recreating package tarball from delta to match md5 signatures")" - msg2 "$(gettext "NOTE: the delta should ONLY be distributed with this tarball")" - xdelta patch "$delta_file" "$base_file" "$pkg_file" + xdelta delta "$base_file" "$pkg_file" "$delta_file" || ret=$? + + if [ $ret -eq 0 -o $ret -eq 1 ]; then + # Generate the final gz using xdelta for compression. xdelta will be our + # common denominator compression utility between the packager and the + # users. makepkg and pacman must use the same compression algorithm or + # the delta generated package may not match, producing md5 checksum + # errors. + msg2 "$(gettext "Recreating package tarball from delta to match md5 signatures")" + msg2 "$(gettext "NOTE: the delta should ONLY be distributed with this tarball")" + ret=0 + xdelta patch "$delta_file" "$base_file" "$pkg_file" || ret=$? + if [ $ret -ne 0 ]; then + error "$(gettext "Could not generate the package from the delta.")" + exit 1 + fi + else + warning "$(gettext "Delta was not able to be created.")" + fi else warning "$(gettext "No previous version found, skipping xdelta.")" fi --
Cool, I was going to suggest using $ret but you figured it out first. :) I'll pull this into my working branch, thanks! -Dan
participants (2)
-
Dan McGee
-
Nathan Jones