Don't always disable the GUI when CLI arguments are provided

Some CLI switches (-d, -f and -v) make sense even when
starting the GUI version of sbopkg.
Allow the usage of these flags also when starting the dialog
version of sbopkg.
Thanks to Patzy for raising the issue on #sbopkg and to
Chess Griffin for pointing out a weakness of the first version
of the patch.

Signed-off-by: Mauro Giachero <mauro.giachero@gmail.com>
This commit is contained in:
mauro.giachero 2009-02-16 16:57:14 +00:00
parent 7c04aeab39
commit c7a8c23b7e

View File

@ -2758,27 +2758,17 @@ main_menu () {
# END OF FUNCTIONS. What comes below is the actual start of the # END OF FUNCTIONS. What comes below is the actual start of the
# script when it is first run. # script when it is first run.
# If there are no command line options then we will use the dialog DIAG=1
# version of sbopkg.
if [ $# -eq 0 ]; then
DIAG=1
config_check
directory_checks
pid_check
main_menu
cleanup
exit 0
fi
# This is the command line options and help. # This is the command line options and help.
while getopts ":b:cd:f:hi:lopq:rs:uv:" OPT; do while getopts ":b:cd:f:hi:lopq:rs:uv:" OPT; do
case $OPT in case $OPT in
b ) BFLAG=1 b ) BFLAG=1
BUILDPKGS=1 BUILDPKGS=1
BUILD="$OPTARG" BUILD="$OPTARG"
unset DIAG
;; ;;
c ) CHK_UPDATES=1 c ) CHK_UPDATES=1
unset DIAG
;; ;;
d ) LOCALREPO="$OPTARG" d ) LOCALREPO="$OPTARG"
;; ;;
@ -2788,20 +2778,28 @@ while getopts ":b:cd:f:hi:lopq:rs:uv:" OPT; do
BUILDPKGS=1 BUILDPKGS=1
INSTALLPKGS=1 INSTALLPKGS=1
BUILD="$OPTARG" BUILD="$OPTARG"
unset DIAG
;; ;;
l ) CHANGELOG=1 l ) CHANGELOG=1
unset DIAG
;; ;;
o ) OBSOLETESRC=1 o ) OBSOLETESRC=1
unset DIAG
;; ;;
p ) GETPKGS=1 p ) GETPKGS=1
unset DIAG
;; ;;
q ) GENSEARCH="$OPTARG" q ) GENSEARCH="$OPTARG"
unset DIAG
;; ;;
r ) RSYNC=1 r ) RSYNC=1
unset DIAG
;; ;;
s ) SEARCH="$OPTARG" s ) SEARCH="$OPTARG"
unset DIAG
;; ;;
u ) UPDATE=1 u ) UPDATE=1
unset DIAG
;; ;;
v ) VERSION=1 v ) VERSION=1
CUSTOMVER="$OPTARG" CUSTOMVER="$OPTARG"
@ -2836,11 +2834,15 @@ done
# End of option parsing. # End of option parsing.
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [[ $# -gt 0 ]]; then
echo "Error: unknown token \"$@\"" >&2
exit 0
fi
if [[ "$BFLAG" = 1 && "$BUILD" = "i" || "$IFLAG" = 1 && \ if [[ "$BFLAG" = 1 && "$BUILD" = "i" || "$IFLAG" = 1 && \
"$BUILD" = "b" ]]; then "$BUILD" = "b" ]]; then
echo "Error: The -b and -i options cannot be used together." echo "Error: The -b and -i options cannot be used together." >&2
echo "Please use one or the other. Exiting." echo "Please use one or the other. Exiting." >&2
exit 0 exit 0
fi fi
@ -2858,7 +2860,11 @@ directory_checks
# Check for another instance # Check for another instance
pid_check pid_check
if [ -n "$BUILD" ]; then if [[ "$DIAG" ]]; then
main_menu
cleanup
else
if [ -n "$BUILD" ]; then
if has_root; then if has_root; then
for PKGBUILD in $BUILD; do for PKGBUILD in $BUILD; do
echo $PKGBUILD >> $TMP/sbopkg-start-queue echo $PKGBUILD >> $TMP/sbopkg-start-queue
@ -2866,35 +2872,36 @@ if [ -n "$BUILD" ]; then
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 \
to build packages." to build packages." >&2
cleanup cleanup
exit 0 exit 0
fi fi
fi fi
if [ -n "$CHK_UPDATES" ]; then if [ -n "$CHK_UPDATES" ]; then
check_for_updates check_for_updates
fi fi
if [ -n "$CHANGELOG" ]; then if [ -n "$CHANGELOG" ]; then
show_changelog show_changelog
fi fi
if [ -n "$OBSOLETESRC" ]; then if [ -n "$OBSOLETESRC" ]; then
remove_obsoleted_sources remove_obsoleted_sources
fi fi
if [ -n "$GETPKGS" ]; then if [ -n "$GETPKGS" ]; then
get_sbo_packages get_sbo_packages
fi fi
if [ -n "$RSYNC" ]; then if [ -n "$RSYNC" ]; then
echo "Rsyncing with Slackbuilds.org repository into $LOCALREPO/$SLACKVER." echo "Rsyncing with Slackbuilds.org repository into \
$LOCALREPO/$SLACKVER."
rsync_repo rsync_repo
echo "Finished rsync." echo "Finished rsync."
fi fi
if [ -n "$SEARCH" ]; then if [ -n "$SEARCH" ]; then
check_if_repo_exists check_if_repo_exists
for PKGSEARCH in "$SEARCH"; do for PKGSEARCH in "$SEARCH"; do
echo "Searching for $PKGSEARCH" echo "Searching for $PKGSEARCH"
@ -2902,21 +2909,23 @@ if [ -n "$SEARCH" ]; then
pick_info "$PKGSEARCH" pick_info "$PKGSEARCH"
show_readme show_readme
done done
fi fi
if [ -n "$UPDATE" ]; then if [ -n "$UPDATE" ]; then
check_for_latest check_for_latest
fi fi
if [ -n "$GENSEARCH" ]; then if [ -n "$GENSEARCH" ]; then
check_if_repo_exists check_if_repo_exists
for PKGSEARCH in $GENSEARCH; do for PKGSEARCH in $GENSEARCH; do
echo "Searching for $PKGSEARCH" echo "Searching for $PKGSEARCH"
gen_search_package $PKGSEARCH gen_search_package $PKGSEARCH
done done
fi
cleanup
echo
echo "All done."
fi fi
cleanup
echo
echo "All done."
exit 0 exit 0