fix failure to remove sources in get_source_names() ( issue 34 )

This is a band-aid which explicitly enables all flash-player-plugin sources to
be removed by testing for its names. It also fixes more general issues with
some SRCNAMEs not containing the VERSION number and get_source_names()
sometimes emitting bare newlines in cases where it should emit nothing at all.

This patch also modifies a regex in remove_sources_for_app() and adds unrelated
comments to string_search().

Thanks to artourter for the report, Chess for review, and Mauro for review and
suggestions.
This commit is contained in:
slakmagik 2010-01-29 18:38:05 +00:00
parent 3f348276aa
commit e75ec7e845

View File

@ -2524,7 +2524,7 @@ string_search() {
SRCHPKG=${PICKED##*/} SRCHPKG=${PICKED##*/}
case $BUTTON in case $BUTTON in
0) 0) # OK
echo $SRCHPKG > $ITEM_SELECTION echo $SRCHPKG > $ITEM_SELECTION
if ! info_item; then if ! info_item; then
rm -f $PICKED_FILE $MENU_FILE $CAT_SELECTION \ rm -f $PICKED_FILE $MENU_FILE $CAT_SELECTION \
@ -2532,7 +2532,7 @@ string_search() {
return 1 return 1
fi fi
;; ;;
3) 3) # Add to Queue
SHORTPATH=$REPO_DIR/$SRCHCAT/$SRCHPKG SHORTPATH=$REPO_DIR/$SRCHCAT/$SRCHPKG
RVERSION=$(grep VERSION $SHORTPATH/$SRCHPKG.info | RVERSION=$(grep VERSION $SHORTPATH/$SRCHPKG.info |
cut -d= -f2 | sed s/\"//g) cut -d= -f2 | sed s/\"//g)
@ -2541,7 +2541,7 @@ string_search() {
add_item_to_queue $SRCHPKG add_item_to_queue $SRCHPKG
continue continue
;; ;;
*) *) # Back, etc.
rm -f $PICKED_FILE $MENU_FILE $CAT_SELECTION $ITEM_SELECTION rm -f $PICKED_FILE $MENU_FILE $CAT_SELECTION $ITEM_SELECTION
return 0 return 0
;; ;;
@ -2666,7 +2666,10 @@ get_source_names() {
read_info $INFO read_info $INFO
for DL in "${DOWNLOAD[@]}"; do for DL in "${DOWNLOAD[@]}"; do
SRCNAME=${DL##*/} # remove the '/download' from any SRCNAME that ends that way rather
# than in the actual tarball
SRCNAME=${DL//%\/download}
SRCNAME=${SRCNAME##*/}
# Replace URI hex sequences (like %20 for ' ' and %2B for '+') with # Replace URI hex sequences (like %20 for ' ' and %2B for '+') with
# their corresponding characters. # their corresponding characters.
# This is done by replacing '%' with '\x' and passing the string to # This is done by replacing '%' with '\x' and passing the string to
@ -2678,7 +2681,7 @@ get_source_names() {
# file name either explicitly or correctly. If this is the case, our # file name either explicitly or correctly. If this is the case, our
# SRCNAME doesn't correspond to a file, and all we can do is guess # SRCNAME doesn't correspond to a file, and all we can do is guess
# from the file that was downloaded and/or the name of the package. # from the file that was downloaded and/or the name of the package.
if [[ -n $NO_DL_LOOP && ! -f $(readlink $SRCNAME) && if [[ -n $NO_DL_LOOP && ! -f $(readlink "$SRCNAME") &&
${#DOWNLOAD[@]} == 1 ]]; then ${#DOWNLOAD[@]} == 1 ]]; then
# If the source has a name resembling $PRGNAM-$VERSION.tar.gz, # If the source has a name resembling $PRGNAM-$VERSION.tar.gz,
# catch it. # catch it.
@ -2694,21 +2697,44 @@ get_source_names() {
# If the user asked for "all" sources, let's try to find similar names # If the user asked for "all" sources, let's try to find similar names
if [[ $ALL ]]; then if [[ $ALL ]]; then
# The following is based on the idea that the source name contains # The following is based on the idea that, if the source name
# the version number. The expression below takes the parts before # contains the version number, the expression below takes the
# and after the version number, and replaces the version number # parts before and after the version number, and replaces the
# with a regular expression matching and digit and any character # version number with a regular expression matching a digit and
# present in the known version number (this is to match odd # any character present in the known version number (this is to
# version numbers containing letters, like "svn1234", but makes it # match odd version numbers containing letters, like "svn1234",
# less likely to match different packages with similar names, like # but makes it less likely to match different packages with
# virtualbox-kernel and virtualbox-kernel-addons) # similar names, like virtualbox-kernel and
SRCNAME=${SRCNAME%%$VERSION*}[0-9$VERSION]\*${SRCNAME##*$VERSION} # virtualbox-kernel-addons). If the source name does not contain
# the version number, we leave SRCNAME alone, though this means
# that when the user is using the remove sources functionality
# they can only remove the source one at a time, starting with the
# most recent.
#
# The flash conditional is based on the fact that the source names
# of the flash player plugin (which are different on different
# arches) don't contain the version number. The grep (rather than
# egrep) is due to a grep having already been used below and this
# having fewer potential side effects - this should eventually get
# a proper fix rather than this ad hockery.
if grep -q \
'\(install_\|lib\)flash_\?player.*\.tar\.gz' <<< $SRCNAME; then
SRCNAME='\(install_\|lib\)flash_\?player.*\.tar\.gz'
elif [[ $SRCNAME =~ $VERSION ]]; then
SRCNAME=${SRCNAME%%$VERSION*}[0-9$VERSION]\*${SRCNAME##*$VERSION}
fi
fi fi
# This isn't just 'ls -A $SRCDIR/${SRCNAME##*/} 2> /dev/null' because # This isn't just 'ls -A $SRCDIR/${SRCNAME##*/} 2> /dev/null' because
# we want only the basename - though we could 'cd' first or 'basename' # we want only the basename - though we could 'cd' first or 'basename'
# after, rather than grepping. # after, rather than grepping. And the conditionals ensure that we
ls -A $SRCDIR | grep "^${SRCNAME##*/}" || echo $PLACEHOLDER # only return PLACEHOLDER when we don't have any other results and
# PLACEHOLDER is actually called for and set.
if ! ls -A $SRCDIR | grep "^${SRCNAME##*/}"; then
if [[ $PLACEHOLDER ]]; then
echo $PLACEHOLDER
fi
fi
done done
} }
@ -2897,7 +2923,7 @@ remove_sources_for_app() {
APP=${INFO##*/} APP=${INFO##*/}
APP=${APP%%.*} APP=${APP%%.*}
get_source_names --all "$INFO" | sed "s/^\(.*\)$/\"\\1\"/g" > $APP_SOURCES get_source_names --all "$INFO" | sed 's/.*/"&"/' > $APP_SOURCES
remove_files $SRCDIR "$APP sources" $APP_SOURCES OFF remove_files $SRCDIR "$APP sources" $APP_SOURCES OFF
} }