Backport PR #480 for DNF 3.6 compatibility (RHBZ #1595917)

This commit is contained in:
Adam Williamson 2018-09-26 19:40:37 -07:00
parent b97aa3bf95
commit d924be0c9e
2 changed files with 77 additions and 1 deletions

View File

@ -0,0 +1,68 @@
From a7c2d7d66b1a4df5b06a0c5b401558531199f791 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Wed, 26 Sep 2018 18:14:06 -0700
Subject: [PATCH] Don't try to append to DNF config value that can't take it
See https://bugzilla.redhat.com/show_bug.cgi?id=1595917 and
https://github.com/rpm-software-management/dnf/pull/1200 for
more on this. Briefly, DNF before 3.0 presented this config
value as a list...and mutating it worked. DNF from 3.0 until
3.6 presented it as a list...mutating it didn't work, but also
didn't *fail*, so this has actually not been doing anything on
DNF 3.x but we haven't noticed.
In DNF 3.6 values like this are presented as tuples instead of
lists, to try and catch usages like this, and it worked! We
need to change this one.
There is an additional weirdness here. tsflags is actually, in
libdnf terms, an OptionStringListAppend option: that means that
when something tries to *set* its value, the new value is just
appended to the existing list of values. This is very weird
behaviour when you're interacting with it like this, but
happens to be quite useful, as we can just 'set' the value to
a list like this and it will actually get appended (which is
what we want), and this one syntax happens to work correctly in
DNF 2.x, 3.0 through 3.5.1, and 3.6.
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
src/pylorax/api/dnfbase.py | 5 ++++-
src/sbin/lorax | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/pylorax/api/dnfbase.py b/src/pylorax/api/dnfbase.py
index b7a4d1c6..1d7f32cc 100644
--- a/src/pylorax/api/dnfbase.py
+++ b/src/pylorax/api/dnfbase.py
@@ -56,7 +56,10 @@ def get_base_object(conf):
dbc.reposdir = [repodir]
dbc.install_weak_deps = False
dbc.prepend_installroot('persistdir')
- dbc.tsflags.append('nodocs')
+ # this is a weird 'AppendOption' thing that, when you set it,
+ # actually appends. Doing this adds 'nodocs' to the existing list
+ # of values, over in libdnf, it does not replace the existing values.
+ dbc.tsflags = ['nodocs']
if conf.get_default("dnf", "proxy", None):
dbc.proxy = conf.get("dnf", "proxy")
diff --git a/src/sbin/lorax b/src/sbin/lorax
index 30b9cadc..2729757d 100755
--- a/src/sbin/lorax
+++ b/src/sbin/lorax
@@ -212,7 +212,10 @@ def get_dnf_base_object(installroot, sources, mirrorlists=None, repos=None,
conf.releasever = releasever
conf.installroot = installroot
conf.prepend_installroot('persistdir')
- conf.tsflags.append('nodocs')
+ # this is a weird 'AppendOption' thing that, when you set it,
+ # actually appends. Doing this adds 'nodocs' to the existing list
+ # of values, over in libdnf, it does not replace the existing values.
+ conf.tsflags = ['nodocs']
if proxy:
conf.proxy = proxy
--
2.19.0

View File

@ -4,7 +4,7 @@
Name: lorax
Version: 29.15
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Tool for creating the anaconda install images
Group: Applications/System
@ -15,6 +15,10 @@ URL: https://github.com/weldr/lorax
# git checkout -b archive-branch lorax-%%{version}-%%{release}
# tito build --tgz
Source0: %{name}-%{version}.tar.gz
# More DNF config interface shenanigans...
# https://github.com/weldr/lorax/pull/480
# https://bugzilla.redhat.com/show_bug.cgi?id=1595917
Patch0: 0001-Don-t-try-to-append-to-DNF-config-value-that-can-t-t.patch
BuildRequires: python3-devel
@ -156,6 +160,7 @@ build images, etc. from the command line.
%prep
%setup -q -n %{name}-%{version}
%patch0 -p1
%build
@ -230,6 +235,9 @@ getent passwd weldr >/dev/null 2>&1 || useradd -r -g weldr -d / -s /sbin/nologin
%{_sysconfdir}/bash_completion.d/composer-cli
%changelog
* Wed Sep 26 2018 Adam Williamson <awilliam@redhat.com> - 29.15-2
- Backport PR #480 for DNF 3.6 compatibility (RHBZ #1595917)
* Fri Sep 07 2018 Brian C. Lane <bcl@redhat.com> 29.15-1
- Add a Makefile target for building html docs using a rawhide environment (bcl@redhat.com)
- Revert "Don't activate default auto connections after switchroot" (rvykydal@redhat.com)