Browse code

Allow use of dnf instead of yum on Fedora

Since Fedora 20 it has been possible to use 'dnf' as a drop-in
replacement for 'yum', and it is targetted to become the default
in Fedora 22

http://fedoraproject.org/wiki/Changes/ReplaceYumWithDNF

There are many benefits of 'dnf' over 'yum' but the biggest
from the POV of an openstack developer is its speed.

Assuming an existing running devstack install ie all required
RPMs already installed on the system. Now look at how long it
takes to run stack.sh, during which yum does not have to
actually install anything

# ./unstack.sh
# time ./stack.sh
real 11m12.193s
user 10m17.129s
sys 0m15.275s

Now, with 'export YUM=dnf' set in local.conf, run the same
test again

# ./unstack.sh
# time ./stack.sh
real 0m48.610s
user 0m28.939s
sys 0m7.801s

So, this is showing that devstack is wasting 10 minutes just
for yum to figure out that everything is already installed.
The overhead of yum vs dnf is even worse when yum has to
acutally depsolve to install new packages.

Change-Id: Ia01a5f330a47b32207586902a861bedfc8a0f6e2

Daniel P. Berrange authored on 2014/12/10 00:21:22
Showing 2 changed files
... ...
@@ -1165,7 +1165,7 @@ function uninstall_package {
1165 1165
     if is_ubuntu; then
1166 1166
         apt_get purge "$@"
1167 1167
     elif is_fedora; then
1168
-        sudo yum remove -y "$@"
1168
+        sudo $YUM remove -y "$@" ||:
1169 1169
     elif is_suse; then
1170 1170
         sudo zypper rm "$@"
1171 1171
     else
... ...
@@ -1174,7 +1174,7 @@ function uninstall_package {
1174 1174
 }
1175 1175
 
1176 1176
 # Wrapper for ``yum`` to set proxy environment variables
1177
-# Uses globals ``OFFLINE``, ``*_proxy``
1177
+# Uses globals ``OFFLINE``, ``*_proxy``, ``YUM``
1178 1178
 # yum_install package [package ...]
1179 1179
 function yum_install {
1180 1180
     [[ "$OFFLINE" = "True" ]] && return
... ...
@@ -1186,7 +1186,7 @@ function yum_install {
1186 1186
     # https://bugzilla.redhat.com/show_bug.cgi?id=965567
1187 1187
     $sudo http_proxy=$http_proxy https_proxy=$https_proxy \
1188 1188
         no_proxy=$no_proxy \
1189
-        yum install -y "$@" 2>&1 | \
1189
+        $YUM install -y "$@" 2>&1 | \
1190 1190
         awk '
1191 1191
             BEGIN { fail=0 }
1192 1192
             /No package/ { fail=1 }
... ...
@@ -1196,7 +1196,7 @@ function yum_install {
1196 1196
 
1197 1197
     # also ensure we catch a yum failure
1198 1198
     if [[ ${PIPESTATUS[0]} != 0 ]]; then
1199
-        die $LINENO "Yum install failure"
1199
+        die $LINENO "$YUM install failure"
1200 1200
     fi
1201 1201
 }
1202 1202
 
... ...
@@ -621,6 +621,12 @@ API_WORKERS=${API_WORKERS:=$(( ($(nproc)/2)<2 ? 2 : ($(nproc)/2) ))}
621 621
 # Service startup timeout
622 622
 SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
623 623
 
624
+# Support alternative yum -- in future Fedora 'dnf' will become the
625
+# only supported installer, but for now 'yum' and 'dnf' are both
626
+# available in parallel with compatible CLIs.  Allow manual switching
627
+# till we get to the point we need to handle this automatically
628
+YUM=${YUM:-yum}
629
+
624 630
 # Following entries need to be last items in file
625 631
 
626 632
 # Local variables: