From 59ac74efb19639855f073d0aac08ede91990c3d9 Mon Sep 17 00:00:00 2001 From: "mauro.giachero" Date: Fri, 26 Feb 2010 11:07:30 +0000 Subject: [PATCH] Fail gracefully when there's an error computing a pkg repo version. Sometimes sbopkg can't determine the version of a package. For example, the google-chrome script looks at the source archive to determine it, and such archive can very well be unavailable. This patch makes sbopkg intercept the error condition and notify it to the user gracefully, while at the same time falling back to trusting the version provided in the .info file. Thanks to alkos333 for the bug report. Signed-off-by: Mauro Giachero --- ChangeLog-current.txt | 4 ++++ src/usr/doc/KNOWN_ISSUES | 10 ++++++++++ src/usr/sbin/sbopkg | 19 +++++++++++++------ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/ChangeLog-current.txt b/ChangeLog-current.txt index c982468..8557604 100644 --- a/ChangeLog-current.txt +++ b/ChangeLog-current.txt @@ -20,4 +20,8 @@ enhancements: artourter for the report. * Modify links in check_for_latest() function to use new sbopkg.org redirects. + * Prevent sbopkg from spitting error messages when trying to determine the + version of some packages (e.g. google-chrome, whose version is discovered + looking into the source package which can be missing). Thanks to alkos333 + for the bug report. +--------------------------+ diff --git a/src/usr/doc/KNOWN_ISSUES b/src/usr/doc/KNOWN_ISSUES index 593bd61..5529220 100644 --- a/src/usr/doc/KNOWN_ISSUES +++ b/src/usr/doc/KNOWN_ISSUES @@ -15,3 +15,13 @@ tools it uses: Details: http://code.google.com/p/sbopkg/issues/detail?id=30 Workaround: use dialog's own exit methods - its buttons, escape, ^C, etc. + +* when checking for updates, for some packages Sbopkg may tell you + "Note: repo version not obtainable by standard method, may be inaccurate.". + This happens with packages whose version is very difficult/impossible to + determine without actually building the package -- one example of this at + the time of writing is the google-chrome package, whose version is picked + from the source archive itself. In these cases sbopkg falls back to trusting + the .info file, and warns the user about it. + + Workaround: none needed diff --git a/src/usr/sbin/sbopkg b/src/usr/sbin/sbopkg index 9f2ae0b..99681b1 100755 --- a/src/usr/sbin/sbopkg +++ b/src/usr/sbin/sbopkg @@ -637,6 +637,7 @@ check_for_updates() { # Giachero for this much-improved update code and related functions! local TEMPFILE=$SBOPKGTMP/sbopkg_updates_tempfile + local ERRORMSG=$SBOPKGTMP/sbopkg_updates_errormsg local NEWSB NEWINFO NEWVER local VERSION_EXPRESSION local UPDATELIST VERSION_FILE PROGRESSBAR_INTERRUPTED @@ -657,7 +658,7 @@ check_for_updates() { # Check to see if there are any updates to installed SBo pkgs. check_if_repo_exists UPDATELIST=$SBOPKGTMP/sbopkg_updatelist - rm -f $UPDATELIST + rm -f $UPDATELIST $ERRORMSG cd /var/log/packages PKGS=$(ls *$REPO_TAG 2> /dev/null) NUMPKGS=$(wc -w <<< "$PKGS") @@ -737,19 +738,20 @@ check_for_updates() { # Step 3 - reverse the file order # Because dependencies must be first... - tac $VERSION_FILE > $TEMPFILE + tac $VERSION_FILE >> $TEMPFILE mv $TEMPFILE $VERSION_FILE # Step 4 - let's get the version number! # Also, strip any residual program name token. - NEWVER=$(sh $VERSION_FILE | rev | cut -d- -f1 | rev) + NEWVER=$(sh $VERSION_FILE 2> $ERRORMSG | sed 's/.*-//g') rm -f $VERSION_FILE # Step 5 - fixup braindead cases # Sometimes the above doesn't work -- see cpan2tgz for 12.1 # In that case, let's trust the .info file... - if [[ -z $NEWVER ]]; then - NEWINFO=$(echo $NEWSB | rev | cut -d. -f2- | rev).info + [[ -z $NEWVER ]] && echo "Empty version!" >> $ERRORMSG + if [[ $(< $ERRORMSG) ]]; then + NEWINFO=$(sed 's/\.SlackBuild$/\.info/g' <<< "$NEWSB") NEWVER=$(grep "^VERSION" $NEWINFO | cut -d\" -f2) fi @@ -808,12 +810,17 @@ check_for_updates() { echo " No update." >> $UPDATELIST fi fi + if [[ $(< $ERRORMSG) ]]; then + echo " Note: repo version not obtainable by" \ + "standard method, may be inaccurate." >> $UPDATELIST + fi else if [[ $DEBUG -ge 1 ]]; then echo $NAME: >> $UPDATELIST echo " Not in the repository." >> $UPDATELIST fi fi + rm -f $ERRORMSG # Progress indicator, for the progressbar (( PROGRESSCOUNTER += 1 )) @@ -1542,9 +1549,9 @@ queue_dir_lister() { -maxdepth 1 | sed -e 's/.sqf//' | sort > $QFM if [[ -z $(< $QFM) ]]; then if [[ $DIAG ]]; then - rm -f $QFM dialog --title "ERROR" --msgbox "$(crunch "The queue directory \ $QUEUEDIR is empty.")" 8 30 + rm -f $QFM return 1 fi fi