Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Install and remove all rpms, including dependencies
Browse files Browse the repository at this point in the history
This also installs test dependencies if use_tests_requires
was set to true.

Change-Id: I980dccb02ff29ff5267c2cf8744091e71d94233a
Refs: bug #1187912
  • Loading branch information
iv-m committed Jun 21, 2013
1 parent 1394639 commit 31d9d5d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions anvil/packaging/yum.py
Expand Up @@ -376,6 +376,14 @@ def _convert_names_python2rpm(self, python_names):
pass
return rpm_names

def _all_rpm_names(self):
req_names = [pkg_resources.Requirement.parse(pkg).key
for pkg in open(self.gathered_requires_filename)]
rpm_names = set(self._convert_names_python2rpm(req_names))
for inst in self.instances:
rpm_names |= inst.package_names()
return list(rpm_names)

def install(self):
super(YumDependencyHandler, self).install()
# Ensure we copy the local repo file name to the main repo so that
Expand All @@ -402,12 +410,9 @@ def install(self):
cmdline = ["yum", "clean", "all"]
sh.execute(cmdline)

rpm_names = set()
for inst in self.instances:
rpm_names |= inst.package_names()

rpm_names = self._all_rpm_names()
if rpm_names:
cmdline = ["yum", "install", "-y"] + list(rpm_names)
cmdline = ["yum", "install", "-y"] + rpm_names
sh.execute(cmdline, stdout_fh=sys.stdout, stderr_fh=sys.stderr)
for name in rpm_names:
self.tracewriter.package_installed(name)
Expand All @@ -422,9 +427,7 @@ def uninstall(self):
sh.unlink(self.tracereader.filename())
self.tracereader = None

rpm_names = set()
for inst in self.instances:
rpm_names |= inst.package_names()
rpm_names = self._all_rpm_names()
if rpm_names:
cmdline = ["yum", "remove", "--remove-leaves", "-y"]
cmdline.extend(sorted(rpm_names))
Expand Down

0 comments on commit 31d9d5d

Please sign in to comment.