zypper: fix package removal

zypper only supports the --no-recommends option during installs, giving
the option during removals results in an error.

When setting ACTION=remove, remove --no-recommends from EXTRA_ARGS, and
set --clean-deps to also remove no-longer-needed dependencies.

Rename EXTRA_ARGS to ACTION_ARGS for increased readability.

Change-Id: Ifbd168992b1a20658b6b4a99ba175234f6c78f6d
This commit is contained in:
K Jonathan Harker 2017-11-03 10:14:30 -07:00 committed by K Jonathan Harker
parent 3c8e424150
commit 7470ee26e0

View File

@ -20,9 +20,9 @@ fi
set -eu set -eu
set -o pipefail set -o pipefail
EXTRA_ARGS="--no-recommends"
MAP_ELEMENT= MAP_ELEMENT=
ACTION=install ACTION=install
ACTION_ARGS="--no-recommends"
SCRIPTNAME=$(basename $0) SCRIPTNAME=$(basename $0)
function show_options () { function show_options () {
@ -48,8 +48,8 @@ eval set -- "$TEMP"
while true ; do while true ; do
case "$1" in case "$1" in
-u) run_zypper dist-upgrade --no-recommends; exit 0;; -u) run_zypper dist-upgrade --no-recommends; exit 0;;
-e) ACTION="remove"; shift;; -e) ACTION="remove"; ACTION_ARGS="--clean-deps"; shift;;
-d) EXTRA_ARGS="--download-only"; shift;; -d) ACTION_ARGS="${ACTION_ARGS} --download-only"; shift;;
-m) MAP_ELEMENT=$2; shift 2;; -m) MAP_ELEMENT=$2; shift 2;;
-h) show_options;; -h) show_options;;
--) shift; break ;; --) shift; break ;;
@ -68,5 +68,5 @@ fi
if [ -z "${PKGS}" ]; then if [ -z "${PKGS}" ]; then
echo "Not running install-packages $ACTION with empty packages list" echo "Not running install-packages $ACTION with empty packages list"
else else
run_zypper $ACTION $EXTRA_ARGS $PKGS run_zypper $ACTION $ACTION_ARGS $PKGS
fi fi