Skip to content

Commit

Permalink
I should probably do it this way.
Browse files Browse the repository at this point in the history
  • Loading branch information
sahal committed Nov 14, 2014
1 parent 49e3640 commit 3f6cd8d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions zypper-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Copyright (c) 2014 Sahal Ansari - github@sahal.info
# License: MIT (see LICENSE)

# exit if anything fails
set -e

# the scripts directory
Expand All @@ -16,14 +17,15 @@ TEMP_DIR="$DIR/logs/"
# NOTE: if you use /tmp/ all users can read packages you (attempt to) install
#TEMP_DIR="/tmp/"

#function zypper { # used for testing on non-OpenSUSE systems
function run_zypper { # used for testing on non-OpenSUSE systems
# echo "actually zypper ""$@"
#}
$ZYPPER_LOCATION $@
}

# test if "$1" == "in" - if it is continue; otherwise pass everything to zypper
# NOTE: not dealing with installing multple packages
if [[ "$1" != "in" || "$#" != "2" ]]; then
$ZYPPER_LOCATION "$@"
run_zypper "$@"
exit
fi

Expand All @@ -36,14 +38,14 @@ else
exit 1
fi

zypper "$@" | tee "$temp"
run_zypper "$@" | tee "$temp"
# if zypper does not exit with 0
if [ " ${PIPESTATUS[0]}" -ne "0" ]; then
# check output for ...
#grep "'$2' not found in package names." < "$temp" &> /dev/null
grep "No provider of '$2' found." < "$temp" &> /dev/null
if [ "$?" -eq "0" ]; then
# have zypper search for "$2" in packages
zypper se "$2"
run_zypper se "$2"
fi
fi

0 comments on commit 3f6cd8d

Please sign in to comment.