Add YUM variable to for Fedora >= 22

Add a YUM variable that defaults to dnf for Fedora 22 and greater.  At
this stage the yum element can do double-duty with dnf -- it's mostly
the same.  If we find it starts getting too unwieldy we can separate
this later.

Modify the install-packages for yum to use this variable when set, but
default back to "yum" to retain the status-quo.

Change-Id: Ibff71465b392d9f66b6f93955ff9223575d6165c
This commit is contained in:
Ian Wienand 2015-05-27 14:42:10 +10:00
parent 6bf4631cfa
commit f112b6f690
2 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,8 @@
# since f22, dnf is the yum replacement. Mostly it drops in
# unmodified, so while we transision KISS and use this to choose
if [ $DIB_RELEASE -ge 22 ]; then
export YUM=dnf
else
export YUM=yum
fi

View File

@ -24,6 +24,9 @@ EXTRA_ARGS=
ACTION=install ACTION=install
MAP_ELEMENT= MAP_ELEMENT=
# allow override for dnf, as shipped by default with >=F22
YUM=${YUM:-yum}
SCRIPTNAME=$(basename $0) SCRIPTNAME=$(basename $0)
function show_options () { function show_options () {
echo "Usage: $SCRIPTNAME [package ...]" echo "Usage: $SCRIPTNAME [package ...]"
@ -42,7 +45,7 @@ eval set -- "$TEMP"
while true ; do while true ; do
case "$1" in case "$1" in
-u) yum -y update; exit 0;; -u) ${YUM} -y update; exit 0;;
-d) EXTRA_ARGS="--downloadonly"; shift;; -d) EXTRA_ARGS="--downloadonly"; shift;;
-e) ACTION="erase"; shift;; -e) ACTION="erase"; shift;;
-m) MAP_ELEMENT=$2; shift 2;; -m) MAP_ELEMENT=$2; shift 2;;
@ -52,6 +55,7 @@ while true ; do
esac esac
done done
# Packages that aren't available in the distro but requested for installation # Packages that aren't available in the distro but requested for installation
# can be ignored by adding them to the exclude list # can be ignored by adding them to the exclude list
BLACKLIST=$(cat /tmp/yum-blacklist 2>/dev/null || echo "") BLACKLIST=$(cat /tmp/yum-blacklist 2>/dev/null || echo "")
@ -87,7 +91,7 @@ if [ -n "$WHITELIST" ]; then
echo "Not running install-packages $ACTION with empty packages list" echo "Not running install-packages $ACTION with empty packages list"
else else
echo "Running install-packages ${ACTION}. Package list: $PKGS" echo "Running install-packages ${ACTION}. Package list: $PKGS"
yum -y $ACTION $EXTRA_ARGS $PKGS ${YUM} -v -y $ACTION $EXTRA_ARGS $PKGS
for pkg in "$@"; do for pkg in "$@"; do
if [ "$pkg" = "python-pip" ] ; then if [ "$pkg" = "python-pip" ] ; then
alternatives --install /usr/bin/pip pip /usr/bin/pip-python 10 alternatives --install /usr/bin/pip pip /usr/bin/pip-python 10