Patches 1 and 2 are just cleanups of unneeded code.
Patch 3 handles the problem of accessing dnf payload properties before there's a payload to access by leaving empty data in unsetup payloads. This is kind of like all of those if not self._yumGroups lines in yumpayload.py, but not half a dozen places.
Patch 4 makes dnfpayload not crash is the base repo can't be setup, because that's really uncalled for.
David Shea (4): Remove obsolete packaging code. Remove the checks for whether dnf and rpm were imported Make dnf._base and dnf._base.comps always available. Don't treat the baserepo as special when gathering metadata (#1177502)
pyanaconda/install.py | 2 +- pyanaconda/packaging/__init__.py | 56 +++----------------------------- pyanaconda/packaging/dnfpayload.py | 15 +++++---- pyanaconda/packaging/rpmostreepayload.py | 2 +- pyanaconda/packaging/yumpayload.py | 8 ++--- 5 files changed, 19 insertions(+), 64 deletions(-)
reset is never called with arguments. updateBaseRepo is never called with a root argument. recreateInitrds is always called with force=True, so there's no need for force. None of that stuff at the end of packaging/__init__.py is used anymore. --- pyanaconda/install.py | 2 +- pyanaconda/packaging/__init__.py | 56 +++----------------------------- pyanaconda/packaging/dnfpayload.py | 4 +-- pyanaconda/packaging/rpmostreepayload.py | 2 +- pyanaconda/packaging/yumpayload.py | 8 ++--- 5 files changed, 12 insertions(+), 60 deletions(-)
diff --git a/pyanaconda/install.py b/pyanaconda/install.py index 6246fd2..1984a0f 100644 --- a/pyanaconda/install.py +++ b/pyanaconda/install.py @@ -104,7 +104,7 @@ def doConfiguration(storage, payload, ksdata, instClass): ksdata.addons.execute(storage, ksdata, instClass, u)
with progress_report(_("Generating initramfs")): - payload.recreateInitrds(force=True) + payload.recreateInitrds()
if willRunRealmd: with progress_report(_("Joining realm: %s") % ksdata.realm.discovered): diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py index 74096a2..a5004bd 100644 --- a/pyanaconda/packaging/__init__.py +++ b/pyanaconda/packaging/__init__.py @@ -130,7 +130,6 @@ class Payload(object): self.instclass = None self._kernelVersionList = [] self._rescueVersionList = [] - self._createdInitrds = False self.txID = None
def setup(self, storage, instClass): @@ -156,7 +155,7 @@ class Payload(object): """ pass
- def reset(self, root=None, releasever=None): + def reset(self): """ Reset the instance, not including ksdata. """ pass
@@ -222,7 +221,7 @@ class Payload(object): def needsNetwork(self): return any(self._repoNeedsNetwork(r) for r in self.data.repo.dataList())
- def updateBaseRepo(self, fallback=True, root=None, checkmount=True): + def updateBaseRepo(self, fallback=True, checkmount=True): """ Update the base repository from ksdata.method. """ pass
@@ -541,19 +540,14 @@ class Payload(object): # XXX TODO: real error handling, as this is probably going to # prevent boot on some systems
- def recreateInitrds(self, force=False): + def recreateInitrds(self): """ Recreate the initrds by calling new-kernel-pkg
This needs to be done after all configuration files have been written, since dracut depends on some of them.
- :param force: Always recreate, default is to only do it on first call - :type force: bool :returns: None """ - if not force and self._createdInitrds: - return - for kernel in self.kernelVersionList: log.info("recreating initrd for %s", kernel) if not flags.imageInstall: @@ -569,9 +563,6 @@ class Payload(object): "-f", "/boot/initramfs-%s.img" % kernel, kernel])
- self._createdInitrds = True - - def _setDefaultBootTarget(self): """ Set the default systemd target for the system. """ if not os.path.exists(iutil.getSysroot() + "/etc/systemd/system"): @@ -739,7 +730,7 @@ class PackagePayload(Payload): def rpmMacros(self, value): self._rpm_macros = value
- def reset(self, root=None, releasever=None): + def reset(self): self.reset_install_device()
def reset_install_device(self): @@ -1265,42 +1256,3 @@ class PayloadManager(object):
# Initialize the PayloadManager instance payloadMgr = PayloadManager() - -def show_groups(payload): - #repo = ksdata.RepoData(name="anaconda", baseurl="http://cannonball/install/rawhide/os/") - #obj.addRepo(repo) - - desktops = [] - addons = [] - - for grp in payload.groups: - if grp.endswith("-desktop"): - desktops.append(payload.description(grp)) - elif not grp.endswith("-support"): - addons.append(payload.description(grp)) - - import pprint - - print("==== DESKTOPS ====") - pprint.pprint(desktops) - print("==== ADDONS ====") - pprint.pprint(addons) - - print(payload.groups) - -def print_txmbrs(payload, f=None): - if f is None: - f = sys.stdout - - print("###########", file=f) - for txmbr in payload._yum.tsInfo.getMembers(): - print(txmbr, file=f) - print("###########", file=f) - -def write_txmbrs(payload, filename): - if os.path.exists(filename): - os.unlink(filename) - - f = open(filename, 'w') - print_txmbrs(payload, f) - f.close() diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py index 7a91c26..5317ecf 100644 --- a/pyanaconda/packaging/dnfpayload.py +++ b/pyanaconda/packaging/dnfpayload.py @@ -676,7 +676,7 @@ class DNFPayload(packaging.PackagePayload): self.requiredGroups = groups self.addDriverRepos()
- def reset(self, root=None, releasever=None): + def reset(self): super(DNFPayload, self).reset() self.txID = None self._base.reset(sack=True, repos=True) @@ -684,7 +684,7 @@ class DNFPayload(packaging.PackagePayload): def selectEnvironment(self, env_id): self._select_environment(env_id)
- def updateBaseRepo(self, fallback=True, root=None, checkmount=True): + def updateBaseRepo(self, fallback=True, checkmount=True): log.info('configuring base repo') self.reset() url, mirrorlist, sslverify = self._setupInstallDevice(self.storage, diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py index dcfed15..2e4688c 100644 --- a/pyanaconda/packaging/rpmostreepayload.py +++ b/pyanaconda/packaging/rpmostreepayload.py @@ -250,7 +250,7 @@ class RPMOSTreePayload(ArchivePayload): ["--create", "--boot", "--root=" + iutil.getSysroot(), "--prefix=/var/" + varsubdir])
- def recreateInitrds(self, force=False): + def recreateInitrds(self): # For rpmostree payloads, we're replicating an initramfs from # a compose server, and should never be regenerating them # per-machine. diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py index 9daacb6..16b7e24 100644 --- a/pyanaconda/packaging/yumpayload.py +++ b/pyanaconda/packaging/yumpayload.py @@ -183,7 +183,7 @@ class YumPayload(PackagePayload):
self.reset()
- def reset(self, root=None, releasever=None): + def reset(self): """ Reset this instance to its initial (unconfigured) state. """
super(YumPayload, self).reset() @@ -192,7 +192,7 @@ class YumPayload(PackagePayload): # available we can use that as a better value. self._space_required = Size("3000 MB")
- self._resetYum(root=root, releasever=releasever) + self._resetYum()
def setup(self, storage, instClass): super(YumPayload, self).setup(storage, instClass) @@ -500,7 +500,7 @@ reposdir=%s return super(YumPayload, self).isRepoEnabled(repo_id)
@refresh_base_repo() - def updateBaseRepo(self, fallback=True, root=None, checkmount=True): + def updateBaseRepo(self, fallback=True, checkmount=True): """ Update the base repo based on self.data.method.
- Tear down any previous base repo devices, symlinks, &c. @@ -531,7 +531,7 @@ reposdir=%s method.method, e)
# start with a fresh YumBase instance & tear down old install device - self._resetYum(root=root, releasever=releasever) + self._resetYum(releasever=releasever) self._yumCacheDirHack()
# If this is a kickstart install and no method has been set up, or
Import failures are ImportErrors now. --- pyanaconda/packaging/dnfpayload.py | 2 -- 1 file changed, 2 deletions(-)
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py index 5317ecf..757885d 100644 --- a/pyanaconda/packaging/dnfpayload.py +++ b/pyanaconda/packaging/dnfpayload.py @@ -182,8 +182,6 @@ def do_transaction(base, queue): class DNFPayload(packaging.PackagePayload): def __init__(self, data): packaging.PackagePayload.__init__(self, data) - if rpm is None or dnf is None: - raise packaging.PayloadError("unsupported payload type")
self._base = None self._configure()
Instead of setting _base to None when a dnf payload is unsetup, reconfigure it. Initialize the comps property as soon as the payload is configured (and before any repos have been set) so that the environment and group properties can be used immediately. --- pyanaconda/packaging/dnfpayload.py | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py index 757885d..90f9480 100644 --- a/pyanaconda/packaging/dnfpayload.py +++ b/pyanaconda/packaging/dnfpayload.py @@ -189,6 +189,7 @@ class DNFPayload(packaging.PackagePayload): def unsetup(self): super(DNFPayload, self).unsetup() self._base = None + self._configure()
def _replace_vars(self, url): """ Replace url variables with their values @@ -343,6 +344,12 @@ class DNFPayload(packaging.PackagePayload): # transaction, disable it in RPM: conf.tsflags.append('nocrypto')
+ # Start with an empty comps so we can go ahead and use the environment + # and group properties. Unset reposdir to ensure dnf has nothing it can + # check automatically + conf.reposdir = [] + self._base.read_comps() + conf.reposdir = REPO_DIRS
@property
There's no need to raise an error. It's all going to be ok. --- pyanaconda/packaging/dnfpayload.py | 2 -- 1 file changed, 2 deletions(-)
diff --git a/pyanaconda/packaging/dnfpayload.py b/pyanaconda/packaging/dnfpayload.py index 90f9480..5cde775 100644 --- a/pyanaconda/packaging/dnfpayload.py +++ b/pyanaconda/packaging/dnfpayload.py @@ -471,8 +471,6 @@ class DNFPayload(packaging.PackagePayload): dnf_repo.load() except dnf.exceptions.RepoError as e: id_ = dnf_repo.id - if id_ == self.baseRepo: - raise packaging.MetadataError(str(e)) log.info('_sync_metadata: addon repo error: %s', e) self.disableRepo(id_)
On Tue, 2015-01-06 at 15:33 -0500, David Shea wrote:
Patches 1 and 2 are just cleanups of unneeded code.
Patch 3 handles the problem of accessing dnf payload properties before there's a payload to access by leaving empty data in unsetup payloads. This is kind of like all of those if not self._yumGroups lines in yumpayload.py, but not half a dozen places.
Patch 4 makes dnfpayload not crash is the base repo can't be setup, because that's really uncalled for.
David Shea (4): Remove obsolete packaging code. Remove the checks for whether dnf and rpm were imported Make dnf._base and dnf._base.comps always available. Don't treat the baserepo as special when gathering metadata (#1177502)
pyanaconda/install.py | 2 +- pyanaconda/packaging/__init__.py | 56 +++----------------------------- pyanaconda/packaging/dnfpayload.py | 15 +++++---- pyanaconda/packaging/rpmostreepayload.py | 2 +- pyanaconda/packaging/yumpayload.py | 8 ++--- 5 files changed, 19 insertions(+), 64 deletions(-)
These all look good to me.
anaconda-patches@lists.fedorahosted.org