From c14c9d6359ae07df109e410efc70f49dbb1cc413 Mon Sep 17 00:00:00 2001 From: "chess.griffin" Date: Tue, 24 Feb 2009 22:01:47 +0000 Subject: [PATCH] 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. --- ChangeLog-current.txt | 8 ++- src/usr/bin/sbopkg | 107 +++++++++++++++++++++++++++++++------- src/usr/man/man8/sbopkg.8 | 30 ++++++++++- 3 files changed, 124 insertions(+), 21 deletions(-) diff --git a/ChangeLog-current.txt b/ChangeLog-current.txt index 416ba53..79984c2 100644 --- a/ChangeLog-current.txt +++ b/ChangeLog-current.txt @@ -34,7 +34,7 @@ enhancements: * 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. 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 GNU Screen and rxvt-based terminals. Thanks to Phillip Warner for raising 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 several other queue-related functions and menus. Many thanks to slakmagik 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. +--------------------------+ diff --git a/src/usr/bin/sbopkg b/src/usr/bin/sbopkg index 11a077e..2266ca8 100755 --- a/src/usr/bin/sbopkg +++ b/src/usr/bin/sbopkg @@ -1534,9 +1534,15 @@ search_package () { PKG="$1" PKGPATH=( $(find -type d -mindepth 2 -name "$PKG") ) if [[ -z $PKGPATH ]]; then + if [[ $SINGLE == yes ]]; then + echo "ERROR: Package or queuefile \"$PKG\" not found. Exiting." + exit 1 + fi if [ "$BUILDPKGS" = 1 ]; then echo "ERROR: Package \"$PKG\" not found" >> $PRECHECKLOG echo "ERROR: Package \"$PKG\" not found - skipped" >> $SUMMARYLOG + echo >> $PRECHECKLOG + echo >> $SUMMARYLOG continue else if [ "$DIAG" = 1 ]; then @@ -1848,23 +1854,23 @@ get_source () { while :; do cat <> $SUMMARYLOG echo "PACKAGE BUILDING/INSTALLATION SUMMARY LOG" >> $SUMMARYLOG echo "Using SlackBuilds.org $SLACKVER repository" >> $SUMMARYLOG + if [ -z $QUEUEFILE ]; then + echo "Using the queuefile $CLIQUEUEFILE" >> $SUMMARYLOG + fi echo >> $SUMMARYLOG if [ "$BUILDPKGS" = 1 ]; then touch $PRECHECKLOG @@ -2448,9 +2477,15 @@ process_queue () { echo "******************************************" >> $PRECHECKLOG echo "PACKAGE BUILDING/INSTALLATION PRECHECK LOG" >> $PRECHECKLOG echo "Using SlackBuilds.org $SLACKVER repository" >> $PRECHECKLOG + if [ -z $QUEUEFILE ]; then + echo "Using the queuefile $CLIQUEUEFILE" >> $PRECHECKLOG + fi echo >> $PRECHECKLOG for CHKBUILD in $(cat $STARTQUEUE); do unset PKG + if [[ $(wc -l <$STARTQUEUE) == 1 ]]; then + local SINGLE=yes + fi search_package $CHKBUILD pick_info $CHKBUILD if [ "$QUITBUILD" = 1 ]; then @@ -2928,8 +2963,9 @@ main_menu () { DIAG=1 unset QUIET +ON_ERROR=ask # 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 b ) BFLAG=1 BUILDPKGS=1 @@ -2941,6 +2977,9 @@ while getopts ":b:cd:f:g:hi:lopqrs:uv:" OPT; do ;; d ) LOCALREPO="$OPTARG" ;; + e ) ON_ERROR="$OPTARG" + unset DIAG + ;; f ) SBOPKG_CONF="$OPTARG" ;; g ) GENSEARCH="$OPTARG" @@ -2980,13 +3019,16 @@ while getopts ":b:cd:f:g:hi:lopqrs:uv:" OPT; do $SCRIPT $SBOVER Usage: $SCRIPT [OPTIONS] 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. -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. -g package(s) General search for packages matching string. -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. -o Display the obsoleted source files and prompt for deletion. -p List installed SlackBuilds.org packages. @@ -3010,14 +3052,21 @@ done shift $(($OPTIND - 1)) if [[ $# -gt 0 ]]; then echo "Error: unknown token \"$@\"" >&2 - exit 0 + exit 1 fi -if [[ "$BFLAG" = 1 && "$BUILD" = "i" || "$IFLAG" = 1 && \ - "$BUILD" = "b" ]]; then +if [[ "$BFLAG" = 1 && "$IFLAG" = 1 ]]; then echo "Error: The -b and -i options cannot be used together." >&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 # Check for a good config file and set initial variables @@ -3042,9 +3091,29 @@ if [[ "$DIAG" ]]; then else if [ -n "$BUILD" ]; then if has_root; then + CLIQUEUE=$TMP/sbopkg_cli_queue + > $TMP/sbopkg-start-queue 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 + rm -f $CLIQUEUE + unset CLIQUEUE process_queue else crunch_fmt "You must run this script as the root user in order \ @@ -3071,8 +3140,8 @@ else fi if [ -n "$RSYNC" ]; then - echo "Rsyncing with Slackbuilds.org repository into \ -$LOCALREPO/$SLACKVER." + crunch_fmt "Rsyncing with Slackbuilds.org repository into \ + $LOCALREPO/$SLACKVER." rsync_repo echo "Finished rsync." fi diff --git a/src/usr/man/man8/sbopkg.8 b/src/usr/man/man8/sbopkg.8 index 66e8975..faf4efe 100644 --- a/src/usr/man/man8/sbopkg.8 +++ b/src/usr/man/man8/sbopkg.8 @@ -69,13 +69,22 @@ similar configuration file to export $EDITOR will suffice. .SH OPTIONS .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 than one package is specified, they must be in quotes. For example: #sbopkg -b "foo 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 .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 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 .B -f 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. 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 .B -l Display the SBo ChangeLog.txt and quit.