download-only, pt.2

Make changes to reflect the logic that "'install' includes 'build'
includes 'download'" vs. "'build' and 'buildinstall' are separate
alternatives, both of which implicitly assume 'download'":

* Expand {QUEUE,}TYPE's possible values to include
  'download|build|install' and create set_type() to set it in place of
  'build|buildinstall' and using the DOWNLOADONLY variable and the
  {B,I}FLAGs.
  * main: delete {B,I}FLAG from the 'unset' section and from the option
    parsing
  * main, set_type(): break out the option testing error message and
    TYPE assignments into set_type() which, rather than assigning to
    TYPE in one place and testing {B,I}FLAG in another, assigns to TYPE
    unless TYPE is already set and has a different value, in which case
    we error out. (People should theoretically be able to call -d, -b,
    -i and have each trump the previous ('-b foo -i foo' should
    download, build, and install foo), but calling '-b foo -i bar' is
    problematic at best.)
  * process_queue(),start_dialog_queue(): replace 'buildinstall's with
    'install's
* Clean up sbopkg's download/build/install logging and output:
  * check_source(): log that we've found the source and return if we're
    only doing a download.
  * process_package(): s/Building/Processing/; use pre-existent
    QUEUETYPE variable with new possible value of 'download'; say we've
    downloaded and return 1 rather than just breaking.
  * log_queuetype(): create by breaking out some redundancy in
    process_queue() relating to the PRE-CHECK and SUMMARY logs and make
    it handle 'Download only' in addition to build/install.
  * process_queue(): remove references to 'PACKAGE BUILDING/INSTALLING'
    because it can be downloading also and 'PACKAGE
    DOWNLOADING/BUILDING/INSTALLING' seems excessive; use
    log_queuetype()
* main: switch the -d and -D flags. It's not good to shuffle flags
  generally, but -d is probably rarely used and download would better be
  lowercase to be consistent with -b/uild and -i/nstall.
* main: while messing with options, sorted the getopts list, the option
  parsing, and the help output as though it had been sorted with 'sort
  -f' (previously, capitalized options were inconsistently sorted).
* src/usr/doc/NEWS,src/usr/man/man8/sbopkg.8: document user-visible
  aspects of the above (-d/-D), tweaking the DESCRIPTION and the -b, -i,
  -k and -R flags in the manual.
This commit is contained in:
slakmagik 2011-05-23 23:32:50 +00:00
parent c42ac608a1
commit b6a42615f2
3 changed files with 104 additions and 62 deletions

View file

@ -2,6 +2,20 @@ SBOPKG NEWS
sbopkg xxxVERSIONxxx (xxxDATExxx)
FEATURES
* Sbopkg now has a -d flag which can download without building
or installing, in addition to -b (download, build) and -i
(download, build, install). Thanks to Kristoffer Karlsson for
the feature request and some testing and to Mauro Giachero for
the initial patch and discussion and review of additional
patching.
MODIFICATIONS
* Specifying an alternate directory as repository root from the
command line, which was done with the -d flag, is now done
with the -D flag. Sorry for any inconvenience.
sbopkg 0.35.0 (2011-04-28 02:48 UTC)

View file

@ -112,8 +112,8 @@ directory, then
.B sbopkg
will automatically add a new menu entry allowing the user to install the
package if he chooses.
Alternatively, the user can choose to automatically build, or both build
and install, individual packages or several packages in a build queue.
Alternatively, the user can choose to automatically download, build, or
install individual packages or several packages in a build queue.
Finally, if
.B KEEPLOG
is set to
@ -233,7 +233,17 @@ time it is encountered.
Display a list of installed SBo packages and potential updates.
.\"---------------------------------------------------------------------
.TP
.BI \-d " DIRECTORY"
.BI \-d " PACKAGE(s)/QUEUE(s)"
Download source archives of the argument(s) from the URL specified in
the active repository.
.IP
See the
.B \-b
option for details since, other than the build, these two options
operate similarly.
.\"---------------------------------------------------------------------
.TP
.BI \-D " DIRECTORY"
Manually specify the full path to the
.I DIRECTORY
containing the local SBo repository.
@ -291,7 +301,7 @@ Display the help.
.\"---------------------------------------------------------------------
.TP
.BI \-i " PACKAGE(s)/QUEUE(s)"
Build and install packages of the argument(s) from the active
Download, build, and install packages of the argument(s) from the active
repository.
.IP
See the
@ -307,12 +317,13 @@ and installed.
.TP
.B \-k
When used together with
.B \-b
.BR \-b ,
.BR \-d ,
or
.BR \-i ,
this option tells
.B sbopkg
to skip (i.e., don't build) any package it finds to be already
to skip (i.e., don't process) any package it finds to be already
installed.
.IP
Please note that only a name comparison is performed, so when this
@ -361,13 +372,13 @@ options is minimized.
.TP
.B \-R
When combined with
.B -b
.BR -b ,
.BR -d ,
or
.BR -i ,
view the
.I README
files of the packages to be built/installed before starting the build
process.
files of the packages to be processed before processing them.
This is useful for making a final check.
When combined with
.BR -p ,

View file

@ -71,6 +71,23 @@ split_pkg_name() {
')
}
set_type() {
# This function enforces the exclusivity of the -b/-d/-i flags and sets
# the value of TYPE. It takes an argument of 'download', 'build', or
# 'install' and sets TYPE to that value unless it's already been set to
# another, in which case it errors out.
local OPT_TYPE=$1
if [[ $TYPE && $TYPE != $OPT_TYPE ]]; then
printf "$SCRIPT: the -b, -d and -i options are exclusive. " >&2
printf "Please use only one.\n" >&2
exit 1
else # set global type
TYPE=$OPT_TYPE
fi
}
config_check() {
# Check if config file is there and if so check that it has all
# needed variables with any value, and set them.
@ -2874,6 +2891,10 @@ check_source() {
if [[ -f $SRCDIR/$SRCNAME ]]; then
echo "Found $SRCNAME in $SRCDIR."
unset NO_DL_LOOP
if [[ $QUEUETYPE == download ]]; then
echo " Found $SRCNAME in $SRCDIR." >> $TMPSUMMARYLOG
return 0
fi
else
echo "$PKG not found in $SRCDIR."
return 1
@ -3340,7 +3361,7 @@ process_package() {
local REPLY
echo
echo "Building $PKGNAME"
echo "Processing $PKGNAME"
# Prepare a temporary output directory
rm -rf $SB_OUTPUT
mkdir -p $SB_OUTPUT
@ -3363,8 +3384,9 @@ process_package() {
# necessarily a download.
# If the sources are successfully fetched, start the build.
if get_source $PKGNAME.info.build; then
if [[ $DOWNLOADONLY ]]; then
break
if [[ $QUEUETYPE == download ]]; then
echo "Done downloading source for $PKGBUILD."
return 1
fi
build_package $PKGNAME
fi
@ -3767,8 +3789,22 @@ EOF
return 0
}
log_queuetype() {
# This function is auxilary to process_queue() and simply logs the correct
# operation based on QUEUETYPE.
printf "Queue Process:" >> $TMPLOG
if [[ $QUEUETYPE == "install" ]]; then
echo " Download, build, and install" >> $TMPLOG
elif [[ $QUEUETYPE == "build" ]]; then
echo " Download and build" >> $TMPLOG
else
echo " Download only" >> $TMPLOG
fi
}
process_queue() {
local QUEUETYPE=$1 # build|buildinstall
local QUEUETYPE=$1 # download|build|install
local CHKBUILD REPLY
# The first (and largest) of three sections in this function is a precheck
@ -3782,14 +3818,9 @@ process_queue() {
echo "###########################################" >> $TMPLOG
echo >> $TMPLOG
echo "+++++++++++++++++++++++++++++++++++++++++++" >> $TMPLOG
echo "PACKAGE BUILDING/INSTALLATION PRE-CHECK LOG" >> $TMPLOG
echo "PRE-CHECK LOG" >> $TMPLOG
echo "Using the $REPO_DESC" >> $TMPLOG
echo -n "Queue Process:" >> $TMPLOG
if [[ $QUEUETYPE == "buildinstall" ]]; then
echo " Build and install" >> $TMPLOG
else
echo " Build only" >> $TMPLOG
fi
log_queuetype
echo >> $TMPLOG
for CHKBUILD in $(< $STARTQUEUE); do
unset PKG PKGPATH PKGNAME VERSION BUILD PICKFILE FILE
@ -3880,8 +3911,8 @@ process_queue() {
fi
rm $TMPLOG
# Okay, precheck done, now start the actual queue processing (build or
# build+install)
# Okay, precheck done, now start the actual queue processing (download,
# build, install)
> $SBOPKGTMP/sbopkg_build.lck
for PKGBUILD in $(< $FINALQUEUE); do
if ! search_package $PKGBUILD; then
@ -3916,7 +3947,7 @@ process_queue() {
echo "Built package: $NEWPACKAGE"
if [[ -f $NEWPACKAGE ]]; then
mv $NEWPACKAGE $OUTPUT
if [[ $QUEUETYPE == "buildinstall" ]]; then
if [[ $QUEUETYPE == "install" ]]; then
install_package $OUTPUT $NEWPACKAGE
echo " Installing package $NEWPACKAGE ... OK" >> \
$TMPSUMMARYLOG
@ -3938,14 +3969,9 @@ process_queue() {
rm -f $SBOPKGTMP/sbopkg_build.lck
echo >> $TMPLOG
echo "+++++++++++++++++++++++++++++++++++++++++++" >> $TMPLOG
echo "PACKAGE BUILDING/INSTALLATION SUMMARY LOG" >> $TMPLOG
echo "SUMMARY LOG" >> $TMPLOG
echo "Using the $REPO_DESC" >> $TMPLOG
echo -n "Queue Process:" >> $TMPLOG
if [[ $QUEUETYPE == "buildinstall" ]]; then
echo " Build and install" >> $TMPLOG
else
echo " Build only" >> $TMPLOG
fi
log_queuetype
cat $TMPSUMMARYLOG >> $TMPLOG
rm $TMPSUMMARYLOG
echo >> $TMPLOG
@ -3989,7 +4015,7 @@ start_dialog_queue() {
to exit.")" 8 50
case $? in
0 ) # Build and install
process_queue buildinstall
process_queue install
if [[ $? == 1 ]]; then
dialog --title "Error" --msgbox "$(crunch "No valid \
packages found.")" 8 40
@ -4465,9 +4491,8 @@ unset CLEANUP # If set, delete the sources & c. after the build
unset KEEPLOG # If set, keep a permanent build log
unset ALLOW_MULTI # If set, allow more that one instance of sbopkg running
unset BUILDLIST # List of packages to build/install (from CLI)
unset DOWNLOADONLY # Don't build packages, only download the sources
unset BUILD BFLAG IFLAG CHK_UPDATES GENSEARCH CHANGELOG OBSOLETESRC GETPKGS
unset BUILD CHK_UPDATES GENSEARCH CHANGELOG OBSOLETESRC GETPKGS
unset RSYNC SEARCH UPDATE VERSION CUSTOMVER SKIP_INSTALLED VIEW_READMES
unset UNINSTPKG
@ -4511,11 +4536,10 @@ else
fi
# This is the command line options and help.
while getopts ":b:cd:D:e:f:g:hi:kloPpqrRs:uV:v" OPT; do
while getopts ":b:cD:d:e:f:g:hi:kloPpqRrs:uV:v" OPT; do
case $OPT in
b ) # Build
BFLAG=1
TYPE="build"
b ) # Download, build
set_type build
BUILDLIST+=("$OPTARG")
unset DIAG
;;
@ -4523,11 +4547,11 @@ while getopts ":b:cd:D:e:f:g:hi:kloPpqrRs:uV:v" OPT; do
CHK_UPDATES=1
unset DIAG
;;
d ) # Location of the local SBo repository
D ) # Location of the local SBo repository
REPO_ROOT=$OPTARG
;;
D ) # Download-only mode
DOWNLOADONLY=1
d ) # Download
set_type download
BUILDLIST+=("$OPTARG")
unset DIAG
;;
@ -4542,9 +4566,8 @@ while getopts ":b:cd:D:e:f:g:hi:kloPpqrRs:uV:v" OPT; do
GENSEARCH+=("$OPTARG")
unset DIAG
;;
i ) # Build and install
IFLAG=1
TYPE="buildinstall"
i ) # Download, build, install
set_type install
BUILDLIST+=("$OPTARG")
unset DIAG
;;
@ -4572,14 +4595,14 @@ while getopts ":b:cd:D:e:f:g:hi:kloPpqrRs:uV:v" OPT; do
QUIET=1
unset DIAG
;;
r ) # Sync with the remote repository
SYNC=1
unset DIAG
;;
R ) # Preview the READMEs before building
VIEW_READMES=1
unset DIAG
;;
r ) # Sync with the remote repository
SYNC=1
unset DIAG
;;
s ) # Name search
SEARCH+=("$OPTARG")
unset DIAG
@ -4588,14 +4611,14 @@ while getopts ":b:cd:D:e:f:g:hi:kloPpqrRs:uV:v" OPT; do
UPDATE=1
unset DIAG
;;
v ) # print version
echo $SBOVER
exit
;;
V ) # Set repository
VERSION=1
CUSTOMVER="$OPTARG"
;;
v ) # print version
echo $SBOVER
exit
;;
h | * ) # Help
cat << EOF
$SCRIPT $SBOVER
@ -4604,8 +4627,8 @@ Options are:
-b pkg/queue(s) Build the specified package(s). If one or more queuefiles
are specified, build the packages they refer to.
-c Check for updates to installed packages.
-d localdir Location of local copy of the repositories.
-D pkg/queue(s) Like '-b', but only download sources.
-D localdir Location of local copy of the repositories.
-d pkg/queue(s) Like '-b', but only download sources.
-e error_action Specify what sbopkg is supposed to do on build errors.
Valid options are: ask (default), continue, stop.
-f file Override default configuration file with specified file.
@ -4618,20 +4641,20 @@ Options are:
-P List uninstalled cached package files & prompt for deletion.
-p List installed packages from active repo.
-q Quiet some of the command-line output.
-r Sync the remote repository with the local mirror and then
quit.
-R When combined with -b or -i, preview the READMEs of the
packages to be built/installed before starting the build
process. When combined with -p, show the READMEs of all
installed packages from the active repo.
-r Sync the remote repository with the local mirror and then
quit.
-s package(s) Specific search by specific package and, if found,
display package information.
-u Check for an update to sbopkg.
-v Print sbopkg's version on stdout.
-V repo/branch Set the repository/branch. The repo is optional and, if
not given, sbopkg will try to make the best match,
starting with the default repo. For a list of valid repos,
issue '-V ?'
-v Print sbopkg's version on stdout.
Note: multiple arguments to -b, -g, -i, and -s must be quoted ("pkg1 pkg2") or
can be specified multiple times (-i foo -i bar). If using the latter syntax,
@ -4651,12 +4674,6 @@ if [[ $# -gt 0 ]]; then
exit 1
fi
if [[ $BFLAG && $IFLAG ]]; then
echo "Error: The -b and -i options cannot be used together." >&2
echo "Please use one or the other. Exiting." >&2
exit 1
fi
if [[ $ON_ERROR != ask && \
$ON_ERROR != continue && \
$ON_ERROR != stop ]]; then