From f112b6f6902fa8cd84578dede5d6bd7f533a5710 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 27 May 2015 14:42:10 +1000 Subject: [PATCH] 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 --- elements/fedora/environment.d/11-yum-dnf.bash | 8 ++++++++ elements/yum/bin/install-packages | 8 ++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 elements/fedora/environment.d/11-yum-dnf.bash diff --git a/elements/fedora/environment.d/11-yum-dnf.bash b/elements/fedora/environment.d/11-yum-dnf.bash new file mode 100644 index 00000000..568419d9 --- /dev/null +++ b/elements/fedora/environment.d/11-yum-dnf.bash @@ -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 diff --git a/elements/yum/bin/install-packages b/elements/yum/bin/install-packages index e67ab55f..25c77aef 100755 --- a/elements/yum/bin/install-packages +++ b/elements/yum/bin/install-packages @@ -24,6 +24,9 @@ EXTRA_ARGS= ACTION=install MAP_ELEMENT= +# allow override for dnf, as shipped by default with >=F22 +YUM=${YUM:-yum} + SCRIPTNAME=$(basename $0) function show_options () { echo "Usage: $SCRIPTNAME [package ...]" @@ -42,7 +45,7 @@ eval set -- "$TEMP" while true ; do case "$1" in - -u) yum -y update; exit 0;; + -u) ${YUM} -y update; exit 0;; -d) EXTRA_ARGS="--downloadonly"; shift;; -e) ACTION="erase"; shift;; -m) MAP_ELEMENT=$2; shift 2;; @@ -52,6 +55,7 @@ while true ; do esac done + # Packages that aren't available in the distro but requested for installation # can be ignored by adding them to the exclude list 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" else 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 if [ "$pkg" = "python-pip" ] ; then alternatives --install /usr/bin/pip pip /usr/bin/pip-python 10