Package: yum / 3.4.3-3

02_Get-correct-rpmdb-path-from-rpm-configuration.patch Patch series | download
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
Description: Get correct rpmdb path from rpm configuration
Author: Mike Miller <mtmiller@ieee.org>
Forwarded: http://lists.baseurl.org/pipermail/yum-devel/2012-June/009354.html

--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -222,6 +222,11 @@ class RPMDBPackageSack(PackageSackBase):
             self._persistdir = root +  '/' + persistdir
         else:
             self._persistdir = persistdir
+        if hasattr(rpm, 'expandMacro'):
+            dbpath = rpm.expandMacro('%_dbpath')
+        else:
+            dbpath = '/var/lib/rpm'
+        self._rpmdbpath = os.path.normpath(root + '/' + dbpath)
         self._have_cached_rpmdbv_data = None
         self._cached_conflicts_data = None
         # Store the result of what happens, if a transaction completes.
@@ -325,7 +330,7 @@ class RPMDBPackageSack(PackageSackBase):
 
         #  We are keeping some data from before, and sometimes (Eg. remove only)
         # we never open the rpmdb again ... so get the mtime now.
-        rpmdbfname  = self.root + "/var/lib/rpm/Packages"
+        rpmdbfname  = self._rpmdbpath + "/Packages"
         self._cached_rpmdb_mtime = os.path.getmtime(rpmdbfname)
 
         def _safe_del(x, y):
@@ -1049,7 +1054,7 @@ class RPMDBPackageSack(PackageSackBase):
         # http://lists.rpm.org/pipermail/rpm-maint/2007-November/001719.html
         # ...if anything gets implemented, we should change.
         rpmdbvfname = self._cachedir + "/version"
-        rpmdbfname  = self.root + "/var/lib/rpm/Packages"
+        rpmdbfname  = self._rpmdbpath + "/Packages"
 
         if os.path.exists(rpmdbvfname) and os.path.exists(rpmdbfname):
             # See if rpmdb has "changed" ...
@@ -1072,7 +1077,7 @@ class RPMDBPackageSack(PackageSackBase):
         if self._cached_rpmdb_mtime is None:
             return # We haven't loaded any packages!!!
 
-        rpmdbfname  = self.root + "/var/lib/rpm/Packages"
+        rpmdbfname  = self._rpmdbpath + "/Packages"
         if not os.path.exists(rpmdbfname):
             return # haha
 
@@ -1268,7 +1273,7 @@ class RPMDBPackageSack(PackageSackBase):
         self._name2pkg.setdefault(po.name, []).append(po)
         self._tup2pkg[po.pkgtup] = po
         if self.__cache_rpmdb__ and self._cached_rpmdb_mtime is None:
-            rpmdbfname  = self.root + "/var/lib/rpm/Packages"
+            rpmdbfname  = self._rpmdbpath + "/Packages"
             self._cached_rpmdb_mtime = os.path.getmtime(rpmdbfname)
 
         return po