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,65 +2860,72 @@ directory_checks
# Check for another instance # Check for another instance
pid_check pid_check
if [ -n "$BUILD" ]; then if [[ "$DIAG" ]]; then
if has_root; then main_menu
for PKGBUILD in $BUILD; do cleanup
echo $PKGBUILD >> $TMP/sbopkg-start-queue else
done if [ -n "$BUILD" ]; then
process_queue if has_root; then
else for PKGBUILD in $BUILD; do
crunch_fmt "You must run this script as the root user in order \ echo $PKGBUILD >> $TMP/sbopkg-start-queue
to build packages." done
cleanup process_queue
exit 0 else
crunch_fmt "You must run this script as the root user in order \
to build packages." >&2
cleanup
exit 0
fi
fi fi
if [ -n "$CHK_UPDATES" ]; then
check_for_updates
fi
if [ -n "$CHANGELOG" ]; then
show_changelog
fi
if [ -n "$OBSOLETESRC" ]; then
remove_obsoleted_sources
fi
if [ -n "$GETPKGS" ]; then
get_sbo_packages
fi
if [ -n "$RSYNC" ]; then
echo "Rsyncing with Slackbuilds.org repository into \
$LOCALREPO/$SLACKVER."
rsync_repo
echo "Finished rsync."
fi
if [ -n "$SEARCH" ]; then
check_if_repo_exists
for PKGSEARCH in "$SEARCH"; do
echo "Searching for $PKGSEARCH"
search_package "$PKGSEARCH"
pick_info "$PKGSEARCH"
show_readme
done
fi
if [ -n "$UPDATE" ]; then
check_for_latest
fi
if [ -n "$GENSEARCH" ]; then
check_if_repo_exists
for PKGSEARCH in $GENSEARCH; do
echo "Searching for $PKGSEARCH"
gen_search_package $PKGSEARCH
done
fi
cleanup
echo
echo "All done."
fi fi
if [ -n "$CHK_UPDATES" ]; then
check_for_updates
fi
if [ -n "$CHANGELOG" ]; then
show_changelog
fi
if [ -n "$OBSOLETESRC" ]; then
remove_obsoleted_sources
fi
if [ -n "$GETPKGS" ]; then
get_sbo_packages
fi
if [ -n "$RSYNC" ]; then
echo "Rsyncing with Slackbuilds.org repository into $LOCALREPO/$SLACKVER."
rsync_repo
echo "Finished rsync."
fi
if [ -n "$SEARCH" ]; then
check_if_repo_exists
for PKGSEARCH in "$SEARCH"; do
echo "Searching for $PKGSEARCH"
search_package "$PKGSEARCH"
pick_info "$PKGSEARCH"
show_readme
done
fi
if [ -n "$UPDATE" ]; then
check_for_latest
fi
if [ -n "$GENSEARCH" ]; then
check_if_repo_exists
for PKGSEARCH in $GENSEARCH; do
echo "Searching for $PKGSEARCH"
gen_search_package $PKGSEARCH
done
fi
cleanup
echo
echo "All done."
exit 0 exit 0