remove_obsolete_sources(): make the progressbar interruptible.

Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
mauro.giachero 2009-05-28 10:19:13 +00:00
parent cfdf6ac7be
commit 8b681ae0b3
2 changed files with 15 additions and 3 deletions

View file

@ -85,4 +85,6 @@ enhancements:
alphabetical list, so shuffling/reordering of the queue will be necessary alphabetical list, so shuffling/reordering of the queue will be necessary
in order to list the dependencies correctly, but at least this will give in order to list the dependencies correctly, but at least this will give
users a head start on setting up a large build queue. users a head start on setting up a large build queue.
* The process of searching for obsolete source archives can now be
interrupted with ESC.
+--------------------------+ +--------------------------+

View file

@ -2408,10 +2408,13 @@ remove_obsoleted_sources() {
local FIND_RESULT=$SBOPKGTMP/sbopkg_obsolete_find local FIND_RESULT=$SBOPKGTMP/sbopkg_obsolete_find
local SOURCES=$SBOPKGTMP/sbopkg_app_sources local SOURCES=$SBOPKGTMP/sbopkg_app_sources
local PROGRESSBAR_INTERRUPTED=$SBOPKGTMP/sbopkg_progressbar-interrupted
local PROGRESS=0 local PROGRESS=0
local NUMINFO local NUMINFO
local INFO APP_CURRSRC REGEX local INFO APP_CURRSRC REGEX
rm -f $PROGRESSBAR_INTERRUPTED
{ # Grouping for progressbar { # Grouping for progressbar
echo 0 # Progressbar begin echo 0 # Progressbar begin
@ -2419,8 +2422,10 @@ remove_obsoleted_sources() {
NUMINFO=$(wc -l < $FIND_RESULT) NUMINFO=$(wc -l < $FIND_RESULT)
ls -A $SRCDIR > $SOURCES ls -A $SRCDIR > $SOURCES
# Reading from $FIND_RESULT... for INFO in $(cat $FIND_RESULT); do
while read INFO; do # Bail out if the user pressed ESC
progressbar_interrupted && touch $PROGRESSBAR_INTERRUPTED && break
APP_CURRSRC=$(get_source_names "$INFO") APP_CURRSRC=$(get_source_names "$INFO")
if [[ $APP_CURRSRC ]]; then if [[ $APP_CURRSRC ]]; then
REGEX="/^$APP_CURRSRC$/d;$REGEX" REGEX="/^$APP_CURRSRC$/d;$REGEX"
@ -2429,11 +2434,16 @@ remove_obsoleted_sources() {
# Progress indicator, for the progressbar # Progress indicator, for the progressbar
(( PROGRESS += 1 )) (( PROGRESS += 1 ))
echo $(($PROGRESS * 100 / $NUMINFO)) echo $(($PROGRESS * 100 / $NUMINFO))
done < $FIND_RESULT done
sed -i "$REGEX" $SOURCES sed -i "$REGEX" $SOURCES
} | progressbar "Searching obsolete sources" \ } | progressbar "Searching obsolete sources" \
"This may take a while, so please be patient..." "This may take a while, so please be patient..."
if [[ -f $PROGRESSBAR_INTERRUPTED ]]; then
rm -f $PROGRESSBAR_INTERRUPTED $SOURCES
return
fi
# Quote file names # Quote file names
sed -i "s/^\(.*\)$/\"\\1\"/" $SOURCES sed -i "s/^\(.*\)$/\"\\1\"/" $SOURCES