implemented CLI build option passing

Created parse_arguments() and modified main to call it and use_options()
to use the results. Updated the man page to reflect the changes.

Also caught up on the ChangeLog.
This commit is contained in:
slakmagik 2010-06-29 14:56:51 +00:00
parent f5efdc1fea
commit 0bd695fa24
3 changed files with 103 additions and 16 deletions

View file

@ -24,6 +24,24 @@ enhancements:
* Fix an ARCH display issue in the updates screen; thanks to alkos333, Marc
Payne, and David Spencer for confirming the issue and thanks to David
Spencer for testing the fix.
* Fixed bugs with dzen2 and *zarafa* not downloading/building properly. Note
that, while the changes fix these issues and should make it easier to
handle similar problems in the future, this change may introduce
regressions. If a download or build fails due to a downloaded tarball
looking something like 'blah?actual_tarball.tar.gz' or the like, please
report it to us.
* Fixed bugs with the '-s' option where only the first of multiple
arguments would be returned and where the command line select menu was
broken. Also where it and the -g flag might inadvertently expand globs
wrongly.
* It's now possible to specify the b,g,i,s flags multiple times. Previously
multiple arguments to these flags had to be quoted (-b "foo bar") but now
they can be given as '-b foo -b bar'. The original style is still
supported.
* With the new style of passing multiple arguments, it is now possible to
specify app-specific options on the command line. These take the form of,
e.g., '-i app1:opt1="foo bar":opt2=baz app2:opt=mu'. If that's cryptic,
see the manual for details.
+--------------------------+
Thu May 27 18:13:59 UTC 2010
Sbopkg 0.33.1 released. This version contains the following fixes and

View file

@ -184,7 +184,10 @@ will suffice.
.TP 5
.BI \-b " PACKAGE(s)/QUEUE(s)"
Build packages of the argument(s) from the active repository.
If more than one package is specified, they must be quoted.
If more than one package is specified, they may either be quoted or the
switch can be given multiple times.
Using this second form, a colon-separated list of options may be given.
If whitespace occurs between the colons, it must be quoted.
.IP
For example:
.RS
@ -198,6 +201,18 @@ will build
.I foo
and then
.IR bar .
.IP
Or
.RS
.IP
.nf
\fC# sbopkg -b app1:opt1="foo bar":opt2=baz -b app2:opt=mu"\fP
.fi
.RE
.IP
will build app1 with the options ``foo bar'' and ``baz'', and app2 with
the option ``mu''.
.IP
Queuefile names can also be specified.
In that case, all the packages specified in the queuefile will be built.
In the unfortunate case a token matches both a queuefile name and a
@ -255,7 +270,8 @@ General search for
.I PACKAGE(s)
by case-insensitive glob where the argument is automatically wrapped in
.BR * s.
If more than one glob is specified, they must be quoted.
If more than one glob is specified, they must be quoted or the \-g flag
must be used multiple times, once for each glob.
.IP
For example:
.RS
@ -372,7 +388,8 @@ files in that order for each
.I PACKAGE
found, using
.IR $PAGER .
If more than one glob is specified, they must be quoted.
If more than one glob is specified, they must be quoted or the \-s flag
must be used multiple times, once for each glob.
.IP
For example:
.RS
@ -398,6 +415,8 @@ instance,
.RE
.IP
will return all packages with 'open' or 'Open' anywhere in the name.
If multiple applications are returned, the user will be presented with a
menu to select from.
.\"---------------------------------------------------------------------
.TP
.B \-u

View file

@ -1908,6 +1908,32 @@ remove_from_queue() {
done
}
parse_arguments() {
# this converts the 'app:opt1="arg1 arg2":opt2=arg1' syntax we need on the
# command line to the 'app' and 'opt1="arg1 arg2" opt2="arg1"' syntax we
# need internally and passes it on to a file.
local CLI_OPTIONS
if [[ "$PKGBUILD" == *:* ]]; then # it has options
PKGBUILD=$(sed '
s/:/ /
s/=/="/g
s/:/":/g
s/:/ /g
s/$/"/' <<< $PKGBUILD)
CLI_OPTIONS="${PKGBUILD#* }"
PKGBUILD="${PKGBUILD%% *}"
echo "$CLI_OPTIONS" > $SBOPKGTMP/sbopkg_$PKGBUILD.cliopts
fi
if ! add_item_to_queue $PKGBUILD; then
echo "Queuefile or package $PKGBUILD not found - skipping." >>\
$MISSING_SINGLE_FILE
echo
fi
}
parse_queue() {
# This begins the process of parsing through a queuefile. The $2
# assignment to NODELETE is used in order to remove the $DUPEQUEUE file
@ -3506,10 +3532,15 @@ use_options() {
local OPTAPP=$2
local OPTCHOICE=$SBOPKGTMP/sbopkg_options_choice
local OPTLIST=$SBOPKGTMP/sbopkg_options_list
local TMPOPTIONS LDOPTIONS CHOICE OPTIONS_MSG REPLY SAVEDOPT QUEUEOPT
local CLI_OPTFILE=$SBOPKGTMP/sbopkg_$OPTAPP.cliopts
local CLI_OPTIONS TMPOPTIONS LDOPTIONS CHOICE OPTIONS_MSG
local REPLY CLI_OPT SAVEDOPT QUEUEOPT
# By default (i.e. no options.sbopkg file) there are no build options.
unset BUILDOPTIONS
if [[ -f $CLI_OPTFILE ]]; then
CLI_OPTIONS=$(< $CLI_OPTFILE)
fi
if [[ -f $PKGPATH/options.sbopkg ]]; then
TMPOPTIONS=$(< $PKGPATH/options.sbopkg)
fi
@ -3517,8 +3548,8 @@ use_options() {
LDOPTIONS=$(< $SBOPKGTMP/sbopkg_"$OPTAPP"_loadoptions)
fi
rm -f $PKGPATH/options.build
if [[ $TMPOPTIONS || $LDOPTIONS ]]; then
if [[ $DIAG ]]; then
if [[ $DIAG ]]; then
if [[ $TMPOPTIONS || $LDOPTIONS ]]; then
rm -f $OPTLIST $OPTCHOICE
if [[ $TMPOPTIONS ]]; then
echo 'Saved "Build with your saved options"' >> $OPTLIST
@ -3549,11 +3580,17 @@ use_options() {
fi
rm -f $OPTLIST $OPTCHOICE
fi
else
fi
else
if [[ $CLI_OPTIONS || $TMPOPTIONS || $LDOPTIONS ]]; then
echo
echo "One or more build option files for the $OPTAPP"
echo "SlackBuild script were found:"
echo
if [[ $CLI_OPTIONS ]]; then
echo "Command line options: $CLI_OPTIONS"
CLI_OPT=" (C)ommand line options,"
fi
if [[ $TMPOPTIONS ]]; then
echo "Saved options: $TMPOPTIONS"
SAVEDOPT=" (S)aved,"
@ -3564,9 +3601,16 @@ use_options() {
fi
echo
while :; do
read $NFLAG -ep "Use (N)one,$SAVEDOPT$QUEUEOPT or (A)bort?: "
read $NFLAG -ep "Use (N)one,$CLI_OPT$SAVEDOPT$QUEUEOPT or (A)bort?: "
case $REPLY in
N|n) break ;;
C|c)
if [[ $CLI_OPTIONS ]]; then
BUILDOPTIONS="$CLI_OPTIONS"
cp $CLI_OPTFILE $PKGPATH/options.build
break
fi
;;
S|s)
if [[ $TMPOPTIONS ]]; then
cp $PKGPATH/options.sbopkg $PKGPATH/options.build
@ -4531,7 +4575,11 @@ Options are:
starting with the default repo. For a list of valid repos,
issue '-V ?'
Note: multiple arguments to -b, -g, -i, and -s must be quoted ("pkg1 pkg2")
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,
build options may also be passed on the command line on a per app basis using
the -b or -i flags in colon-separated groups (where whitespace must also be
quoted). For example, '-i app:opt1="arg1 arg2":opt2=arg1 app2'
EOF
exit
;;
@ -4619,7 +4667,13 @@ else
> $SBOPKGTMP/sbopkg_user_queue.lck
> $MISSING_LIST_FILE
> $MISSING_SINGLE_FILE
for PKGBUILD in ${BUILDLIST[*]}; do
if [[ ${#BUILDLIST[*]} == 1 && ${BUILDLIST[*]} != *:* ]]; then
# we've got either a single package or old-style optionless quoted
# multi-args, so split 'em if you got 'em
BUILDLIST=(${BUILDLIST[*]})
fi
for ((i=0; i<${#BUILDLIST[*]}; i++)); do
PKGBUILD="${BUILDLIST[$i]}"
if [[ ${PKGBUILD:(-4)} == ".sqf" ]]; then
parse_queue $QUEUEDIR/$PKGBUILD
continue
@ -4633,7 +4687,7 @@ else
read $NFLAG -ep "Use (Q)ueuefile, (P)ackage, or (A)bort?: "
case $REPLY in
Q|q) parse_queue $QUEUEDIR/$PKGBUILD.sqf; break ;;
P|p) add_item_to_queue $PKGBUILD; break ;;
P|p) parse_arguments "$PKGBUILD"; break ;;
A|a) cleanup; exit 1 ;;
*) unknown_response ;;
esac
@ -4643,11 +4697,7 @@ else
# Add an entire queue
parse_queue $QUEUEDIR/$PKGBUILD.sqf
else
if ! add_item_to_queue $PKGBUILD; then
crunch_fmt "Queuefile or package $PKGBUILD not found\
- skipping." >> $MISSING_SINGLE_FILE
echo
fi
parse_arguments "$PKGBUILD"
fi
fi
done