#!/bin/sh
# this is a compatibility replacement for a C++ program
# that was in yast2-packagemanager.rpm

ZYPPER=zypper

# be even more compatible, #223795
Zypper() {
  $ZYPPER "$@" 2>&1
  E=$?
  if [ $E -gt 0 -a $E -lt 100 ]; then
    echo ERROR
  fi
  exit $E
}

if [ "x$1" = "x-s" ]; then
   Zypper service-list
fi

if [ "x$1" = "x-e" ]; then
   shift # do nothing, enabled is default
elif [ "x$1" = "x-d" ]; then
   ENABLED=--disable
   shift
fi

if [ "x$1" = "x-a" -a -n "$2" ]; then
   Zypper service-add $ENABLED "$2"
fi

cat >&2 <<EOF
Usage:
  installation_sources [-e|-d] -a url   Add source at given URL.
    -e  Enable source. This is the default.
    -d  Disable source.
  installation_sources -s       Show all available sources.
EOF
exit 1
