1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
From 8cd0503612573c455f34db74cd1c2216ed25b69c Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Wed, 12 Apr 2017 15:42:06 +0300
Subject: [PATCH] Revert "proper check of releasever, when using installroot
(RhBug:1417542)"
This reverts commit 3ddf684b7c67a2b384aa99dde53d8a43218f2e68, as it's causing
breakage when installing packages into a pristin rootfs. Upstream has been notified:
https://bugzilla.redhat.com/show_bug.cgi?id=1441636
Upstream-Status: Inappropriate [pending proper fix]
Signed-off-by: Alex Kanavin <alex.kanavin@gmail.com>
---
dnf/rpm/__init__.py | 59 +++++++++++++++++++++++++----------------------------
doc/command_ref.rst | 3 +--
2 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/dnf/rpm/__init__.py b/dnf/rpm/__init__.py
index 5976acd6..1d50e6a0 100644
--- a/dnf/rpm/__init__.py
+++ b/dnf/rpm/__init__.py
@@ -30,38 +30,35 @@ def detect_releasever(installroot):
# :api
"""Calculate the release version for the system."""
- # if installroot is empty dir releasever is None,
- # that's why releasever is checked from '/'
- for root in [installroot, "/"]:
- ts = transaction.initReadOnlyTransaction(root=root)
- ts.pushVSFlags(~(rpm._RPMVSF_NOSIGNATURES | rpm._RPMVSF_NODIGESTS))
- for distroverpkg in dnf.const.DISTROVERPKG:
- try:
- idx = ts.dbMatch('provides', distroverpkg)
- except (TypeError, rpm.error) as e:
- raise dnf.exceptions.Error('Error: %s' % str(e))
- if not len(idx):
- continue
- try:
- hdr = next(idx)
- except StopIteration:
- msg = 'Error: rpmdb failed to list provides. Try: rpm --rebuilddb'
- raise dnf.exceptions.Error(msg)
- releasever = hdr['version']
- try:
- off = hdr[rpm.RPMTAG_PROVIDENAME].index(distroverpkg)
- flag = hdr[rpm.RPMTAG_PROVIDEFLAGS][off]
- ver = hdr[rpm.RPMTAG_PROVIDEVERSION][off]
- if flag == rpm.RPMSENSE_EQUAL and ver:
- if hdr['name'] != distroverpkg:
- # override the package version
- releasever = ver
- except (ValueError, KeyError, IndexError):
- pass
+ ts = transaction.initReadOnlyTransaction(root=installroot)
+ ts.pushVSFlags(~(rpm._RPMVSF_NOSIGNATURES | rpm._RPMVSF_NODIGESTS))
+ for distroverpkg in dnf.const.DISTROVERPKG:
+ try:
+ idx = ts.dbMatch('provides', distroverpkg)
+ except (TypeError, rpm.error) as e:
+ raise dnf.exceptions.Error('Error: %s' % str(e))
+ if not len(idx):
+ continue
+ try:
+ hdr = next(idx)
+ except StopIteration:
+ msg = 'Error: rpmdb failed to list provides. Try: rpm --rebuilddb'
+ raise dnf.exceptions.Error(msg)
+ releasever = hdr['version']
+ try:
+ off = hdr[rpm.RPMTAG_PROVIDENAME].index(distroverpkg)
+ flag = hdr[rpm.RPMTAG_PROVIDEFLAGS][off]
+ ver = hdr[rpm.RPMTAG_PROVIDEVERSION][off]
+ if flag == rpm.RPMSENSE_EQUAL and ver:
+ if hdr['name'] != distroverpkg:
+ # override the package version
+ releasever = ver
+ except (ValueError, KeyError, IndexError):
+ pass
- if is_py3bytes(releasever):
- releasever = str(releasever, "utf-8")
- return releasever
+ if is_py3bytes(releasever):
+ releasever = str(releasever, "utf-8")
+ return releasever
return None
diff --git a/doc/command_ref.rst b/doc/command_ref.rst
index 77e885ab..3dd451b5 100644
--- a/doc/command_ref.rst
+++ b/doc/command_ref.rst
@@ -205,8 +205,7 @@ Options
Note: You may also want to use the command-line option
``--releasever=<release>`` when creating the installroot otherwise the
*$releasever* value is taken from the rpmdb within the installroot (and thus
- it is empty at time of creation and *$releasever* is taken from rpmdb using
- installroot=/).
+ it is empty at time of creation, the transaction will fail).
The new installroot path at time of creation do not contain *repository*,
*releasever*, and *dnf.conf* file.
--
2.11.0
|