diff --git a/app/views/templates/script/package_action.erb b/app/views/templates/script/package_action.erb index dfe34636e..4b15fc063 100644 --- a/app/views/templates/script/package_action.erb +++ b/app/views/templates/script/package_action.erb @@ -118,19 +118,27 @@ handle_zypp_res_codes () { end end -%> - OUTFILE=$(mktemp) - trap "rm -f $OUTFILE" EXIT - set -o pipefail + run_cmd() + { + LANG=C apt-get -o APT::Get::Upgrade-Allow-New="true" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y <%= input("options") %> <%= action %> <%= input("package") %> 2>&1 + } export DEBIAN_FRONTEND=noninteractive apt-get -y update - LANG=C apt-get -o APT::Get::Upgrade-Allow-New="true" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y <%= input("options") %> <%= action %> <%= input("package") %> 2>&1 | tee $OUTFILE - RETVAL=$? - if grep -q "Unable to locate" $OUTFILE && [ "<%= action %>" = "remove" ]; then - true + if [ "<%= action %>" = "remove" ]; then + OUTFILE=$(mktemp) + trap "rm -f $OUTFILE" EXIT + run_cmd > $OUTFILE + RETVAL=$? + cat $OUTFILE + if grep -q "Unable to locate" $OUTFILE; then + RETVAL=0 + fi else - setReturnValue() { RETVAL=$1; return $RETVAL; } - setReturnValue $RETVAL + run_cmd + RETVAL=$? fi + setReturnValue() { RETVAL=$1; return $RETVAL; } + setReturnValue $RETVAL <% elsif package_manager == 'zypper' -%> <%- if action == "group install"