commit two patches by Mauro Giachero implementing an 'autoqueue' feature, where the user can specify either a list of packages to -b or -i (already implemented) or a queuefile (new addition). Couple this with the new -e switch, that allows user to decide how build errors are handled (options are ask|stop|continue) and sbopkg can now automatically run through a large queue without stopping on errors (hence the term 'autoqueue'). Also, slakmagik provides a few fixes on this, provided a patch to allow for a more graceful exit on certain circumstances; many thanks to Mauro for the autoqueue implementation and thanks to slakmagik for the addtional cleanup patch; also update ChangeLog-current.txt and sbopkg(8) man page to reflect new command line switches.

This commit is contained in:
chess.griffin 2009-02-24 22:01:47 +00:00
parent e2d3eef879
commit c14c9d6359
3 changed files with 124 additions and 21 deletions

View file

@ -34,7 +34,7 @@ enhancements:
* Move the -q option to -g (General search) in order to make way for -q, * Move the -q option to -g (General search) in order to make way for -q,
'quiet mode' where the output of some of the command line options (i.e. 'quiet mode' where the output of some of the command line options (i.e.
the command line progressbar) can be minimized. More quieting will likely the command line progressbar) can be minimized. More quieting will likely
occur in future releases. Thanks to alkos333 for the feature request occur in future releases. Thanks to alkos333 for the feature request.
* Implement a workaround so that the dialog interface now works better with * Implement a workaround so that the dialog interface now works better with
GNU Screen and rxvt-based terminals. Thanks to Phillip Warner for raising GNU Screen and rxvt-based terminals. Thanks to Phillip Warner for raising
the issue and thanks to Mauro Giachero for working on the implementation. the issue and thanks to Mauro Giachero for working on the implementation.
@ -50,4 +50,10 @@ enhancements:
queues, modifies how the saved queues and backup queues work, and modifies queues, modifies how the saved queues and backup queues work, and modifies
several other queue-related functions and menus. Many thanks to slakmagik several other queue-related functions and menus. Many thanks to slakmagik
for his continually excellent contributions. for his continually excellent contributions.
* Allow specifying queue names to '-b' and '-i'. Thanks to Alan Hicks for
suggesting this feature.
* Allow the user to specify what to do on errors once and for all with the
'-e' command line switch. The user can now tell sbopkg to ignore any error
or to automatically stop on the first one. Thanks to Alan Hicks for
suggesting this feature.
+--------------------------+ +--------------------------+

View file

@ -1534,9 +1534,15 @@ search_package () {
PKG="$1" PKG="$1"
PKGPATH=( $(find -type d -mindepth 2 -name "$PKG") ) PKGPATH=( $(find -type d -mindepth 2 -name "$PKG") )
if [[ -z $PKGPATH ]]; then if [[ -z $PKGPATH ]]; then
if [[ $SINGLE == yes ]]; then
echo "ERROR: Package or queuefile \"$PKG\" not found. Exiting."
exit 1
fi
if [ "$BUILDPKGS" = 1 ]; then if [ "$BUILDPKGS" = 1 ]; then
echo "ERROR: Package \"$PKG\" not found" >> $PRECHECKLOG echo "ERROR: Package \"$PKG\" not found" >> $PRECHECKLOG
echo "ERROR: Package \"$PKG\" not found - skipped" >> $SUMMARYLOG echo "ERROR: Package \"$PKG\" not found - skipped" >> $SUMMARYLOG
echo >> $PRECHECKLOG
echo >> $SUMMARYLOG
continue continue
else else
if [ "$DIAG" = 1 ]; then if [ "$DIAG" = 1 ]; then
@ -1848,23 +1854,23 @@ get_source () {
while :; do while :; do
cat <<EOF cat <<EOF
What do you want to do with the downloaded $PKG source: Do you want to use the downloaded $PKG source:
$SRCNAME in $SRCDIR? $SRCNAME in $SRCDIR?
You can choose among the following options: You can choose among the following options:
- (Y)es, delete the source and abort build. - (Y)es, keep the source and continue;
- (N)o, keep the source and continue. - (N)o, delete the source and abort build.
Your choice? Your choice?
EOF EOF
read ANS error_read ANS
case $ANS in case $ANS in
y* | Y* ) n* | N* )
rm -f "$SRCDIR/$SRCNAME" rm -f "$SRCDIR/$SRCNAME"
echo "Source deleted." echo "Source deleted."
FAILURE=md5sum FAILURE=md5sum
break break
;; ;;
n* | N* ) y* | Y* )
MD5SUM=$(tr / _ <<<"$MD5CHK") MD5SUM=$(tr / _ <<<"$MD5CHK")
echo "Keeping the source and continuing." | echo "Keeping the source and continuing." |
tee -a $SUMMARYLOG tee -a $SUMMARYLOG
@ -1893,7 +1899,7 @@ EOF
echo "then it may not make sense to continue." echo "then it may not make sense to continue."
echo echo
echo "Press (Y)es to continue or (N)o to abort." echo "Press (Y)es to continue or (N)o to abort."
read ANS error_read ANS
case $ANS in case $ANS in
y* | Y* ) return 1 y* | Y* ) return 1
;; ;;
@ -2102,6 +2108,26 @@ install_package () {
fi fi
} }
error_read () {
# This function wraps a simple 'read' call. The read itself is skipped if
# $ON_ERROR != "ask", and the value put in the variable ($1) is "Yes" when
# $ON_ERROR == "continue", and "No" when $ON_ERROR == "stop".
# Useful in all those places where the CLI version of sbopkg asks the
# user what to do on build errors.
# The automatic answer is printed to stdout, to record it on the permanent
# build log.
case $ON_ERROR in
ask) read $1 ; return ;;
stop) eval $1=No
echo -n "No "
;;
cont*) eval $1=Yes
echo -n "Yes "
;;
esac
echo "(as specified with '-e')"
}
build_package () { build_package () {
unset MD5CHK MD5SUM unset MD5CHK MD5SUM
# Start fetching and building the package. # Start fetching and building the package.
@ -2123,7 +2149,7 @@ build_package () {
*) return 1 ;; *) return 1 ;;
esac esac
echo "Building Slackware package for $PKG..." echo "Building Slackware package for $PKG..."
export $BUILDOPTIONS [[ $BUILDOPTIONS ]] && export $BUILDOPTIONS
sh $PKG.SlackBuild.build sh $PKG.SlackBuild.build
cd $OUTPUT cd $OUTPUT
if [ ! -e *.tgz ]; then if [ ! -e *.tgz ]; then
@ -2139,7 +2165,7 @@ build_package () {
echo "then it may not make sense to continue." echo "then it may not make sense to continue."
echo echo
echo "Press (Y)es to continue or (N)o to abort." echo "Press (Y)es to continue or (N)o to abort."
read ANS error_read ANS
case $ANS in case $ANS in
y* | Y* ) continue y* | Y* ) continue
;; ;;
@ -2441,6 +2467,9 @@ process_queue () {
echo "******************************************" >> $SUMMARYLOG echo "******************************************" >> $SUMMARYLOG
echo "PACKAGE BUILDING/INSTALLATION SUMMARY LOG" >> $SUMMARYLOG echo "PACKAGE BUILDING/INSTALLATION SUMMARY LOG" >> $SUMMARYLOG
echo "Using SlackBuilds.org $SLACKVER repository" >> $SUMMARYLOG echo "Using SlackBuilds.org $SLACKVER repository" >> $SUMMARYLOG
if [ -z $QUEUEFILE ]; then
echo "Using the queuefile $CLIQUEUEFILE" >> $SUMMARYLOG
fi
echo >> $SUMMARYLOG echo >> $SUMMARYLOG
if [ "$BUILDPKGS" = 1 ]; then if [ "$BUILDPKGS" = 1 ]; then
touch $PRECHECKLOG touch $PRECHECKLOG
@ -2448,9 +2477,15 @@ process_queue () {
echo "******************************************" >> $PRECHECKLOG echo "******************************************" >> $PRECHECKLOG
echo "PACKAGE BUILDING/INSTALLATION PRECHECK LOG" >> $PRECHECKLOG echo "PACKAGE BUILDING/INSTALLATION PRECHECK LOG" >> $PRECHECKLOG
echo "Using SlackBuilds.org $SLACKVER repository" >> $PRECHECKLOG echo "Using SlackBuilds.org $SLACKVER repository" >> $PRECHECKLOG
if [ -z $QUEUEFILE ]; then
echo "Using the queuefile $CLIQUEUEFILE" >> $PRECHECKLOG
fi
echo >> $PRECHECKLOG echo >> $PRECHECKLOG
for CHKBUILD in $(cat $STARTQUEUE); do for CHKBUILD in $(cat $STARTQUEUE); do
unset PKG unset PKG
if [[ $(wc -l <$STARTQUEUE) == 1 ]]; then
local SINGLE=yes
fi
search_package $CHKBUILD search_package $CHKBUILD
pick_info $CHKBUILD pick_info $CHKBUILD
if [ "$QUITBUILD" = 1 ]; then if [ "$QUITBUILD" = 1 ]; then
@ -2928,8 +2963,9 @@ main_menu () {
DIAG=1 DIAG=1
unset QUIET unset QUIET
ON_ERROR=ask
# This is the command line options and help. # This is the command line options and help.
while getopts ":b:cd:f:g:hi:lopqrs:uv:" OPT; do while getopts ":b:cd:e:f:g:hi:lopqrs:uv:" OPT; do
case $OPT in case $OPT in
b ) BFLAG=1 b ) BFLAG=1
BUILDPKGS=1 BUILDPKGS=1
@ -2941,6 +2977,9 @@ while getopts ":b:cd:f:g:hi:lopqrs:uv:" OPT; do
;; ;;
d ) LOCALREPO="$OPTARG" d ) LOCALREPO="$OPTARG"
;; ;;
e ) ON_ERROR="$OPTARG"
unset DIAG
;;
f ) SBOPKG_CONF="$OPTARG" f ) SBOPKG_CONF="$OPTARG"
;; ;;
g ) GENSEARCH="$OPTARG" g ) GENSEARCH="$OPTARG"
@ -2980,13 +3019,16 @@ while getopts ":b:cd:f:g:hi:lopqrs:uv:" OPT; do
$SCRIPT $SBOVER $SCRIPT $SBOVER
Usage: $SCRIPT [OPTIONS] <packagename(s)> Usage: $SCRIPT [OPTIONS] <packagename(s)>
Options are: Options are:
-b package(s) Build package(s). -b pkg/queue(s) Build the specified package(s). If one or more queues are
specified, build the packages they refer to.
-c Check for updates to installed SlackBuilds.org packages. -c Check for updates to installed SlackBuilds.org packages.
-d localdir Location of local copy of SlackBuilds.org repository -d localdir Location of local copy of SlackBuilds.org repository
-e error_action Specify what sbopkg is supposed to do on build errors.
Valid options are: ask (default), continue, stop.
-f Override default configuration file with specified file. -f Override default configuration file with specified file.
-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 package(s) Build and install package(s). -i pkg/queue(s) Like '-b', but also install built packages.
-l Display the SlackBuilds.org ChangeLog.txt and then quit. -l Display the SlackBuilds.org ChangeLog.txt and then quit.
-o Display the obsoleted source files and prompt for deletion. -o Display the obsoleted source files and prompt for deletion.
-p List installed SlackBuilds.org packages. -p List installed SlackBuilds.org packages.
@ -3010,14 +3052,21 @@ done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [[ $# -gt 0 ]]; then if [[ $# -gt 0 ]]; then
echo "Error: unknown token \"$@\"" >&2 echo "Error: unknown token \"$@\"" >&2
exit 0 exit 1
fi fi
if [[ "$BFLAG" = 1 && "$BUILD" = "i" || "$IFLAG" = 1 && \ if [[ "$BFLAG" = 1 && "$IFLAG" = 1 ]]; then
"$BUILD" = "b" ]]; then
echo "Error: The -b and -i options cannot be used together." >&2 echo "Error: The -b and -i options cannot be used together." >&2
echo "Please use one or the other. Exiting." >&2 echo "Please use one or the other. Exiting." >&2
exit 0 exit 1
fi
if [[ "$ON_ERROR" != "ask" && \
"$ON_ERROR" != "continue" && \
"$ON_ERROR" != "stop" ]]; then
echo "Unknown -e specifier -- \"$ON_ERROR\"" >&2
echo "Valid values are: ask (default), continue, stop" >&2
exit 1
fi fi
# Check for a good config file and set initial variables # Check for a good config file and set initial variables
@ -3042,9 +3091,29 @@ if [[ "$DIAG" ]]; then
else else
if [ -n "$BUILD" ]; then if [ -n "$BUILD" ]; then
if has_root; then if has_root; then
CLIQUEUE=$TMP/sbopkg_cli_queue
> $TMP/sbopkg-start-queue
for PKGBUILD in $BUILD; do for PKGBUILD in $BUILD; do
echo $PKGBUILD >> $TMP/sbopkg-start-queue if [[ -r $QUEUEDIR/$PKGBUILD ]]; then
# Add an entire queue
CLIQUEUEFILE=$PKGBUILD
echo "Using the queuefile $CLIQUEUEFILE"
cp $QUEUEDIR/$PKGBUILD $CLIQUEUE
else
# Add a single package
echo $PKGBUILD >$CLIQUEUE
fi
# Reading from $CLIQUEUE...
while read PICK; do
PICK_NAME=${PICK%% *}
#search_package "$PICK_NAME"
if ! grep -qx $PICK_NAME $TMP/sbopkg-start-queue; then
echo $PICK_NAME >>$TMP/sbopkg-start-queue
fi
done < $CLIQUEUE
done done
rm -f $CLIQUEUE
unset CLIQUEUE
process_queue process_queue
else else
crunch_fmt "You must run this script as the root user in order \ crunch_fmt "You must run this script as the root user in order \
@ -3071,8 +3140,8 @@ else
fi fi
if [ -n "$RSYNC" ]; then if [ -n "$RSYNC" ]; then
echo "Rsyncing with Slackbuilds.org repository into \ crunch_fmt "Rsyncing with Slackbuilds.org repository into \
$LOCALREPO/$SLACKVER." $LOCALREPO/$SLACKVER."
rsync_repo rsync_repo
echo "Finished rsync." echo "Finished rsync."
fi fi

View file

@ -69,13 +69,22 @@ similar configuration file to export $EDITOR will suffice.
.SH OPTIONS .SH OPTIONS
.TP 5 .TP 5
.B -b PACKAGE(s) .B -b PACKAGE(s)/QUEUE(s)
Search for and build PACKAGE(s) from the local SBo repository. If more Search for and build PACKAGE(s) from the local SBo repository. If more
than one package is specified, they must be in quotes. For example: than one package is specified, they must be in quotes. For example:
#sbopkg -b "foo bar" #sbopkg -b "foo bar"
will build foo and then bar. will build foo and then bar.
Queue names can also be specified. In that case, all the packages specified
in the queue file will be built. In the unfortunate case a token matches both
a queue name and a package name (i.e. the user named a queue with the name of
a package), sbopkg will interpret it as a queue name.
The tokens (package names or queues) are processed in the order they are
specified on the command line, and the build order specified in the queue
files is retained.
If a package is specified more than once, it gets queued only the first time
it's encountered.
.TP 5 .TP 5
.B -c .B -c
@ -86,6 +95,22 @@ Display list of installed SBo packages and potential updates.
Manually specify the full path to the DIRECTORY containing the Manually specify the full path to the DIRECTORY containing the
local SBo repository. local SBo repository.
.TP 5
.B -e ask|continue|stop
Specify what sbopkg should do when it encounters an error while building a
package. Valid options are:
.B ask
: This is the default behavior, asking the user what to do;
.B continue
: Ignore the error and continue processing (act as if the user
answered "Yes" to all questions);
.B stop
: Stop the processing (act as if the user answered "No" to all
questions).
.TP 5 .TP 5
.B -f .B -f
Override the default configuration file, which is located by Override the default configuration file, which is located by
@ -123,6 +148,9 @@ nature of dependencies, this may not always be possible and so
building dependencies like this is not really a supported feature. building dependencies like this is not really a supported feature.
Still, when when it works, it can be helpful. Still, when when it works, it can be helpful.
Queue names are supported, too. See the explanation for the '-b' command
for details.
.TP 5 .TP 5
.B -l .B -l
Display the SBo ChangeLog.txt and quit. Display the SBo ChangeLog.txt and quit.