Skip to content

Commit

Permalink
Fail gracefully when there's an error computing a pkg repo version.
Browse files Browse the repository at this point in the history
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 <mauro.giachero@gmail.com>
  • Loading branch information
mauro.giachero committed Feb 26, 2010
1 parent 246d57f commit 59ac74e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ChangeLog-current.txt
Expand Up @@ -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.
+--------------------------+
10 changes: 10 additions & 0 deletions src/usr/doc/KNOWN_ISSUES
Expand Up @@ -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
19 changes: 13 additions & 6 deletions src/usr/sbin/sbopkg
Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 ))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 59ac74e

Please sign in to comment.