Haha, guess what we didn't notice stopped working a few years back.
And while I was all up in anaconda-yum, moved the Exception handler so that errors are processed by anaconda as a real error and we don't get a ENOENT while trying to run authconfig instead.
David Shea (4): Move the anaconda-yum exception handler (#1057120) Set rpm macro information in anaconda-yum. Implement %packages --instLangs (#156477) Set rpm macros in DNFPayload
pyanaconda/packaging/__init__.py | 41 ++++++++++++++++++++++++++++++++++++++ pyanaconda/packaging/dnfpayload.py | 5 +++++ pyanaconda/packaging/yumpayload.py | 26 +++--------------------- scripts/anaconda-yum | 32 +++++++++++++++++++---------- 4 files changed, 70 insertions(+), 34 deletions(-)
Catch exceptions that could be raised early in run_yum_transaction while manipulating stdout or modifying the environment. --- scripts/anaconda-yum | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum index 341f7a9..cae3ee1 100755 --- a/scripts/anaconda-yum +++ b/scripts/anaconda-yum @@ -176,9 +176,6 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l logfile.close() except YumBaseError as e: print("ERROR: transaction error: %s" % e) - # pylint: disable-msg=W0703 - except Exception as e: - print("ERROR: unexpected error: %s" % e) finally: print("QUIT:")
@@ -393,12 +390,15 @@ class RPMCallback(object):
if __name__ == "__main__": - arg_parser = setup_parser() - args = arg_parser.parse_args() + try: + arg_parser = setup_parser() + args = arg_parser.parse_args()
- # force output to be flushed - sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) - - run_yum_transaction(args.release, args.arch, args.config, args.installroot, - args.tsfile, args.rpmlog, args.test, args.debug) + # force output to be flushed + sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
+ run_yum_transaction(args.release, args.arch, args.config, args.installroot, + args.tsfile, args.rpmlog, args.test, args.debug) + # pylint: disable-msg=W0703 + except Exception as e: + print("ERROR: unexpected error: %s" % e)
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.""" + return self._rpm_macros + + @rpmMacros.setter + def rpmMacros(self, value): + self._rpm_macros = value + def reset(self, root=None, releasever=None): # cdrom: install_device.teardown (INSTALL_TREE) # hd: umount INSTALL_TREE, install_device.teardown (ISO_DIR) diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py index a26ab2b..9bde5a8 100644 --- a/pyanaconda/packaging/yumpayload.py +++ b/pyanaconda/packaging/yumpayload.py @@ -1377,29 +1377,6 @@ reposdir=%s while True: time.sleep(100000)
- # doPreInstall - # create mountpoints for protected device mountpoints (?) - # write static configs (storage, modprobe.d/anaconda.conf, network, keyboard) - - # 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? - rpm.addMacro("__dbi_htconfig", - "hash nofsync %{__dbi_other} %{__dbi_perms}") - - if self.data.packages.excludeDocs: - rpm.addMacro("_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): - rpm.addMacro("__file_context_path", f) - break - else: - rpm.addMacro("__file_context_path", "%{nil}")
def install(self): """ Install the payload. @@ -1437,6 +1414,9 @@ reposdir=%s "--release", release, "--arch", blivet.arch.getArch()]
+ for macro in self.rpmMacros: + args.extend(["--macro", macro[0], macro[1]]) + log.info("Running anaconda-yum to install packages") # Watch output for progress, debug and error information install_errors = [] diff --git a/scripts/anaconda-yum b/scripts/anaconda-yum index cae3ee1..91161af 100755 --- a/scripts/anaconda-yum +++ b/scripts/anaconda-yum @@ -47,12 +47,13 @@ def setup_parser(): parser.add_argument("-i", "--installroot", help="Path to top directory of installroot", default="/mnt/sysimage") parser.add_argument("-T", "--test", action="store_true", help="Test transaction, don't actually install") parser.add_argument("-d", "--debug", action="store_true", help="Extra debugging output") + parser.add_argument("-m", "--macro", action="append", metavar=('NAME', 'VALUE'), nargs=2, help="Macros to add to the rpm transaction")
return parser
def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_log, - testing=False, debug=False): + testing=False, debug=False, macros=None): """ Execute a yum transaction loaded from a transaction file
:param release: The release version to use @@ -69,6 +70,10 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l :type script_log: string :param testing: True sets RPMTRANS_FLAG_TEST (default is false) :type testing: bool + :param debug: True set verbosity to "debug" + :type debug: bool + :param macros: Macros to define in the rpm transaction + :type macros: list :returns: Nothing
This is used to run the yum transaction in a separate process, preventing @@ -82,6 +87,11 @@ def run_yum_transaction(release, arch, yum_conf, install_root, ts_file, script_l if k in os.environ: os.environ.pop(k)
+ # Initialize the rpm macros + if macros: + for macro in macros: + rpm.addMacro(macro[0], macro[1]) + try: # Setup the basics, point to the config file and install_root yb = yum.YumBase() @@ -398,7 +408,7 @@ if __name__ == "__main__": sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
run_yum_transaction(args.release, args.arch, args.config, args.installroot, - args.tsfile, args.rpmlog, args.test, args.debug) + args.tsfile, args.rpmlog, args.test, args.debug, args.macro) # pylint: disable-msg=W0703 except Exception as e: print("ERROR: unexpected error: %s" % e)
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))breakelse: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
--- pyanaconda/packaging/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py index f404d3c..9d254bd 100644 --- a/pyanaconda/packaging/__init__.py +++ b/pyanaconda/packaging/__init__.py @@ -664,6 +664,13 @@ class PackagePayload(Payload): if self.data.packages.excludeDocs: self.rpmMacros.append(('_excludedocs', '1'))
+ if self.data.packages.instLangs is not None: + if not self.data.packages.instLangs: + instLangs = '%{nil}' + else: + instLangs = self.data.packages.instLangs + self.rpmMacros.append(('_install_langs', instLangs)) + if flags.selinux: for d in ["/tmp/updates", "/etc/selinux/targeted/contexts/files",
On Tue, 2014-02-25 at 14:40 -0500, David Shea wrote:
pyanaconda/packaging/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py index f404d3c..9d254bd 100644 --- a/pyanaconda/packaging/__init__.py +++ b/pyanaconda/packaging/__init__.py @@ -664,6 +664,13 @@ class PackagePayload(Payload): if self.data.packages.excludeDocs: self.rpmMacros.append(('_excludedocs', '1'))
if self.data.packages.instLangs is not None:if not self.data.packages.instLangs:instLangs = '%{nil}'else:instLangs = self.data.packages.instLangs
These four lines could be reduced to a single one: instLangs = self.data.packages.instLangs or '%{nil}'
but I don't know if you like these shortcuts.
--- pyanaconda/packaging/dnfpayload.py | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py index 138d21b..ec80213 100644 --- a/pyanaconda/packaging/dnfpayload.py +++ b/pyanaconda/packaging/dnfpayload.py @@ -409,6 +409,11 @@ class DNFPayload(packaging.PackagePayload):
def install(self): progressQ.send_message(_('Starting package installation process')) + + # Add the rpm macros to the global transaction environment + for macro in self.rpmMacros: + rpm.addMacro(macro[0], macro[1]) + if self.install_device: self._setupMedia(self.install_device) try:
On Tue, 2014-02-25 at 14:40 -0500, David Shea wrote:
Haha, guess what we didn't notice stopped working a few years back.
And while I was all up in anaconda-yum, moved the Exception handler so that errors are processed by anaconda as a real error and we don't get a ENOENT while trying to run authconfig instead.
David Shea (4): Move the anaconda-yum exception handler (#1057120) Set rpm macro information in anaconda-yum. Implement %packages --instLangs (#156477) Set rpm macros in DNFPayload
pyanaconda/packaging/__init__.py | 41 ++++++++++++++++++++++++++++++++++++++ pyanaconda/packaging/dnfpayload.py | 5 +++++ pyanaconda/packaging/yumpayload.py | 26 +++--------------------- scripts/anaconda-yum | 32 +++++++++++++++++++---------- 4 files changed, 70 insertions(+), 34 deletions(-)
Other than those two neatpicks these both look good to me.
anaconda-patches@lists.fedorahosted.org