Add the new -k option to skip building already installed packages.

This is the CLI variant of the previous commit.

Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
mauro.giachero 2009-08-05 21:27:33 +00:00
parent e7803ae655
commit 6c04fea0be
3 changed files with 43 additions and 35 deletions

View file

@ -128,4 +128,8 @@ enhancements:
'view queue' now only shows the queue; new 'sort' and 'remove' queue menu 'view queue' now only shows the queue; new 'sort' and 'remove' queue menu
items now handle the editing functions; thanks to Pierre Cazenave for the items now handle the editing functions; thanks to Pierre Cazenave for the
suggestion. suggestion.
* Add dialog notification of whether a queued package is installed.
* Add a dialog option to automatically uncheck installed packages from the
active queue, together with a command line option that automatically skips
such packages when building with -b or -i.
+--------------------------+ +--------------------------+

View file

@ -160,6 +160,15 @@ Still, when when it works, it can be helpful.
Queuefile names are supported, too. See the explanation for the '-b' Queuefile names are supported, too. See the explanation for the '-b'
command for details. command for details.
.TP 5
.B -k
When used together with -b or -i, this option tells sbopkg to skip
(i.e. don't build) any package it finds to be already installed.
Please note that only a name comparison is performed, so when this
option is specified sbopkg will also omit the build of different
versions of installed packages.
.TP 5 .TP 5
.B -l .B -l
Display the SBo ChangeLog.txt and quit. Display the SBo ChangeLog.txt and quit.

View file

@ -1908,33 +1908,22 @@ add_item_to_queue() {
if grep -q "^$APP " $TMPQUEUE 2> /dev/null; then if grep -q "^$APP " $TMPQUEUE 2> /dev/null; then
: # it's the same app and version so toss it : # it's the same app and version so toss it
else else
if [[ $DIAG ]]; then INSTALLED=$(ls -1 /var/log/packages |
INSTALLED=$(ls -1 /var/log/packages | grep "$APP-[^-]*-[^-]*-[^-]*$REPO_TAG\$")
grep "$APP-[^-]*-[^-]*-[^-]*$REPO_TAG\$") if [[ -n $INSTALLED ]]; then
if [[ -n $INSTALLED ]]; then VERSION=$(sed 's:^.*-\([^-]*\)-[^-]*-[^-]*$:\1:'<<<$INSTALLED)
VERSION=$(sed 's:^.*-\([^-]*\)-[^-]*-[^-]*$:\1:'<<<$INSTALLED) # NOTE: When changing, see the uncheck_installed() comment
# NOTE: When changing, see the uncheck_installed() comment echo "$APP \"Installed $VERSION\" $ONOFF" >> $TMPQUEUE
echo "$APP \"Installed $VERSION\" $ONOFF" >> $TMPQUEUE echo "$APP \"Installed $VERSION\" $ONOFF" >> $QUEUELIST
echo "$APP \"Installed $VERSION\" $ONOFF" >> $QUEUELIST
else
# NOTE: When changing, see the uncheck_installed() comment
echo "$APP New $ONOFF" >> $TMPQUEUE
echo "$APP New $ONOFF" >> $QUEUELIST
fi
if [[ $LOADOPTIONS ]]; then
echo "$LOADOPTIONS" > $SBOPKGTMP/sbopkg_"$APP"_loadoptions
else
rm -f $SBOPKGTMP/sbopkg_"$APP"_loadoptions
fi
else else
if [[ $ONOFF == "ON" ]]; then # NOTE: When changing, see the uncheck_installed() comment
echo "$APP" >> $TMPQUEUE echo "$APP New $ONOFF" >> $TMPQUEUE
if [[ $LOADOPTIONS ]]; then echo "$APP New $ONOFF" >> $QUEUELIST
echo "$LOADOPTIONS" > $SBOPKGTMP/sbopkg_"$APP"_loadoptions fi
else if [[ $LOADOPTIONS ]]; then
rm -f $SBOPKGTMP/sbopkg_"$APP"_loadoptions echo "$LOADOPTIONS" > $SBOPKGTMP/sbopkg_"$APP"_loadoptions
fi else
fi rm -f $SBOPKGTMP/sbopkg_"$APP"_loadoptions
fi fi
fi fi
# Only display this if we are not loading a queue; otherwise getting this # Only display this if we are not loading a queue; otherwise getting this
@ -4041,7 +4030,7 @@ unset CLEANUP # If set, delete the sources & c. after the build
unset KEEPLOG # If set, keep a permanent build log unset KEEPLOG # If set, keep a permanent build log
unset BUILD BFLAG IFLAG CHK_UPDATES GENSEARCH CHANGELOG OBSOLETESRC GETPKGS unset BUILD BFLAG IFLAG CHK_UPDATES GENSEARCH CHANGELOG OBSOLETESRC GETPKGS
unset RSYNC SEARCH UPDATE VERSION CUSTOMVER unset RSYNC SEARCH UPDATE VERSION CUSTOMVER SKIP_INSTALLED
SCRIPT=${0##*/} SCRIPT=${0##*/}
SBOPKG_CONF=${SBOPKG_CONF:-/etc/sbopkg/sbopkg.conf} SBOPKG_CONF=${SBOPKG_CONF:-/etc/sbopkg/sbopkg.conf}
@ -4068,7 +4057,7 @@ if [[ ! $(uname -m) =~ 'i.86' ]]; then
fi fi
# This is the command line options and help. # This is the command line options and help.
while getopts ":b:cd:e:f:g:hi:lopqrs:uv:" OPT; do while getopts ":b:cd:e:f:g:hi:klopqrs:uv:" OPT; do
case $OPT in case $OPT in
b ) # Build b ) # Build
BFLAG=1 BFLAG=1
@ -4100,6 +4089,10 @@ while getopts ":b:cd:e:f:g:hi:lopqrs:uv:" OPT; do
BUILD="$OPTARG" BUILD="$OPTARG"
unset DIAG unset DIAG
;; ;;
k ) # Skip installed packages
SKIP_INSTALLED=1
unset DIAG
;;
l ) # Show SBo ChangeLog l ) # Show SBo ChangeLog
CHANGELOG=1 CHANGELOG=1
unset DIAG unset DIAG
@ -4147,6 +4140,7 @@ Options are:
-g package(s) General search for packages matching string. -g package(s) General search for packages matching string.
-h Display this help message. -h Display this help message.
-i pkg/queue(s) Like '-b', but also install built packages. -i pkg/queue(s) Like '-b', but also install built packages.
-k Skip installed packages when building.
-l Display the repo's ChangeLog.txt and then quit. -l Display the repo's ChangeLog.txt and then quit.
-o Display the obsolete source files and prompt for deletion. -o Display the obsolete source files and prompt for deletion.
-p List installed repo's packages. -p List installed repo's packages.
@ -4264,7 +4258,7 @@ else
q* | Q* ) parse_queue $QUEUEDIR/$PKGBUILD.sqf q* | Q* ) parse_queue $QUEUEDIR/$PKGBUILD.sqf
break break
;; ;;
p* | P* ) echo $PKGBUILD >> $TMPQUEUE p* | P* ) add_item_to_queue $PKGBUILD
break break
;; ;;
a* | A* ) cleanup a* | A* ) cleanup
@ -4278,10 +4272,7 @@ else
# Add an entire queue # Add an entire queue
parse_queue $QUEUEDIR/$PKGBUILD.sqf parse_queue $QUEUEDIR/$PKGBUILD.sqf
else else
if search_package $PKGBUILD; then if ! add_item_to_queue $PKGBUILD; then
# Add a single package
echo $PKGBUILD >> $TMPQUEUE
else
crunch_fmt "Queuefile or package $PKGBUILD not found\ crunch_fmt "Queuefile or package $PKGBUILD not found\
- skipping." - skipping."
echo echo
@ -4299,13 +4290,17 @@ else
cleanup cleanup
exit 1 exit 1
fi fi
# Skip installed packages
if [[ $SKIP_INSTALLED ]]; then
uncheck_installed $TMPQUEUE
fi
# Reading from $TMPQUEUE... # Reading from $TMPQUEUE...
while read PICK; do while read PICK; do
if can_skip_line $PICK; then if can_skip_line $PICK; then
continue continue
fi fi
PICK_NAME=${PICK%% *} PICK_NAME=${PICK%% *}
if [[ ${PICK_NAME:0:1} == "-" ]]; then if [[ ${PICK: -3} == "OFF" ]]; then
continue continue
else else
if ! grep -qx $PICK_NAME $STARTQUEUE; then if ! grep -qx $PICK_NAME $STARTQUEUE; then
@ -4316,7 +4311,7 @@ else
rm -f $TMPQUEUE rm -f $TMPQUEUE
process_queue $TYPE process_queue $TYPE
if [[ $? == 1 ]]; then if [[ $? == 1 ]]; then
echo "No valid packages found. Exiting." echo "No valid packages found, or no packages to build. Exiting."
exit 1 exit 1
fi fi
fi fi