On Tue, 2014-02-25 at 14:40 -0500, David Shea wrote:
yumpayload.py uses rpm.addMacro to set rpm macro values, which does
exactly nothing because anaconda-yum runs in a separate process with a
different transaction context. Surprise!
Also, these settings should be shared by every packaging class that uses
rpm, not just used by yum. Add a rpmMacros property to PackagePayload,
move the macro settings into PackagePayload.preInstall, and modify the
call to anaconda-yum to include the rpmMacros values in --macro
arguments.
---
pyanaconda/packaging/__init__.py | 34 ++++++++++++++++++++++++++++++++++
pyanaconda/packaging/yumpayload.py | 26 +++-----------------------
scripts/anaconda-yum | 14 ++++++++++++--
3 files changed, 49 insertions(+), 25 deletions(-)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index b7a056a..f404d3c 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -643,6 +643,7 @@ class PackagePayload(Payload):
super(PackagePayload, self).__init__(data)
self.install_device = None
+ self._rpm_macros = []
# Used to determine which add-ons to display for each environment.
# The dictionary keys are environment IDs. The dictionary values are two-tuples
@@ -651,6 +652,30 @@ class PackagePayload(Payload):
# environment.
self._environmentAddons = {}
+ def preInstall(self, packages=None, groups=None):
+ super(PackagePayload, self).preInstall()
+
+ # Set rpm-specific options
+
+ # nofsync speeds things up at the risk of rpmdb data loss in a crash.
+ # But if we crash mid-install you're boned anyway, so who cares?
+ self.rpmMacros.append(('__dbi_htconfig', 'hash nofsync
%{__dbi_other} %{__dbi_perms}'))
+
+ if self.data.packages.excludeDocs:
+ self.rpmMacros.append(('_excludedocs', '1'))
+
+ if flags.selinux:
+ for d in ["/tmp/updates",
+ "/etc/selinux/targeted/contexts/files",
+ "/etc/security/selinux/src/policy",
+ "/etc/security/selinux"]:
+ f = d + "/file_contexts"
+ if os.access(f, os.R_OK):
+ self.rpmMacros.append(('__file_context_path', f))
+ break
+ else:
+ self.rpmMacros.append(('__file_context_path', '%{nil}'))
+
@property
def kernelPackages(self):
kernels = ["kernel"]
@@ -668,6 +693,15 @@ class PackagePayload(Payload):
return kernels
+ @property
+ def rpmMacros(self):
+ """A list of (name, value) paris to define as macros in the rpm
transaction."""
^ typo
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic