Skip to content

Commit

Permalink
Use dnf instead of yum when available
Browse files Browse the repository at this point in the history
Recent fedora releases use "dnf" instead of "yum" for package
management. While there is a compatible "yum" cli available, there's
no guarantee that it will be available.

With this patch, cloud-init will check for /usr/bin/dnf and use that
if it exists instead of yum.

rhbz: https://bugzilla.redhat.com/show_bug.cgi?id=1194451
LP: #1647118
  • Loading branch information
larsks authored and smoser committed Jan 12, 2017
1 parent e55ff8f commit a3daf18
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cloudinit/distros/rhel.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,18 @@ def package_command(self, command, args=None, pkgs=None):
if pkgs is None:
pkgs = []

cmd = ['yum']
# If enabled, then yum will be tolerant of errors on the command line
# with regard to packages.
# For example: if you request to install foo, bar and baz and baz is
# installed; yum won't error out complaining that baz is already
# installed.
cmd.append("-t")
if util.which('dnf'):
LOG.debug('Using DNF for package management')
cmd = ['dnf']
else:
LOG.debug('Using YUM for package management')
# the '-t' argument makes yum tolerant of errors on the command
# line with regard to packages.
#
# For example: if you request to install foo, bar and baz and baz
# is installed; yum won't error out complaining that baz is already
# installed.
cmd = ['yum', '-t']
# Determines whether or not yum prompts for confirmation
# of critical actions. We don't want to prompt...
cmd.append("-y")
Expand Down

0 comments on commit a3daf18

Please sign in to comment.