1 |
Trust that the PKGDIR index file is valid, meaning that no packages |
2 |
have been manually added or removed since the last call to emaint --fix |
3 |
binhost. This feature eliminates overhead involved with detection of |
4 |
packages that have been manually added or removed, which significantly |
5 |
improves performance in some cases, such as when PKGDIR resides on |
6 |
a high-latency network file system. |
7 |
|
8 |
Bug: https://bugs.gentoo.org/688902 |
9 |
Signed-off-by: Zac Medico <zmedico@g.o> |
10 |
--- |
11 |
lib/portage/const.py | 1 + |
12 |
lib/portage/dbapi/bintree.py | 36 ++++++++++++++++++++++++++---------- |
13 |
man/make.conf.5 | 8 ++++++++ |
14 |
3 files changed, 35 insertions(+), 10 deletions(-) |
15 |
|
16 |
diff --git a/lib/portage/const.py b/lib/portage/const.py |
17 |
index 0ed64a742..36b33af92 100644 |
18 |
--- a/lib/portage/const.py |
19 |
+++ b/lib/portage/const.py |
20 |
@@ -176,6 +176,7 @@ SUPPORTED_FEATURES = frozenset([ |
21 |
"parallel-fetch", |
22 |
"parallel-install", |
23 |
"pid-sandbox", |
24 |
+ "pkgdir-index-trusted", |
25 |
"prelink-checksums", |
26 |
"preserve-libs", |
27 |
"protect-owned", |
28 |
diff --git a/lib/portage/dbapi/bintree.py b/lib/portage/dbapi/bintree.py |
29 |
index 9c2d877e7..ba21e6d23 100644 |
30 |
--- a/lib/portage/dbapi/bintree.py |
31 |
+++ b/lib/portage/dbapi/bintree.py |
32 |
@@ -537,7 +537,8 @@ class binarytree(object): |
33 |
|
34 |
self._populating = True |
35 |
try: |
36 |
- update_pkgindex = self._populate_local() |
37 |
+ update_pkgindex = self._populate_local( |
38 |
+ reindex='pkgdir-index-trusted' not in self.settings.features) |
39 |
|
40 |
if update_pkgindex and self.dbapi.writable: |
41 |
# If the Packages file needs to be updated, then _populate_local |
42 |
@@ -568,7 +569,14 @@ class binarytree(object): |
43 |
|
44 |
self.populated = True |
45 |
|
46 |
- def _populate_local(self): |
47 |
+ def _populate_local(self, reindex=True): |
48 |
+ """ |
49 |
+ Populates the binarytree with local package metadata. |
50 |
+ |
51 |
+ @param reindex: detect added / modified / removed packages and |
52 |
+ regenerate the index file if necessary |
53 |
+ @type reindex: bool |
54 |
+ """ |
55 |
self.dbapi.clear() |
56 |
_instance_key = self.dbapi._instance_key |
57 |
# In order to minimize disk I/O, we never compute digests here. |
58 |
@@ -580,9 +588,10 @@ class binarytree(object): |
59 |
pkg_paths = {} |
60 |
self._pkg_paths = pkg_paths |
61 |
dir_files = {} |
62 |
- for parent, dir_names, file_names in os.walk(self.pkgdir): |
63 |
- relative_parent = parent[len(self.pkgdir)+1:] |
64 |
- dir_files[relative_parent] = file_names |
65 |
+ if reindex: |
66 |
+ for parent, dir_names, file_names in os.walk(self.pkgdir): |
67 |
+ relative_parent = parent[len(self.pkgdir)+1:] |
68 |
+ dir_files[relative_parent] = file_names |
69 |
|
70 |
pkgindex = self._load_pkgindex() |
71 |
if not self._pkgindex_version_supported(pkgindex): |
72 |
@@ -597,8 +606,14 @@ class binarytree(object): |
73 |
path = d.get("PATH") |
74 |
if not path: |
75 |
path = cpv + ".tbz2" |
76 |
- basename = os.path.basename(path) |
77 |
- basename_index.setdefault(basename, []).append(d) |
78 |
+ |
79 |
+ if reindex: |
80 |
+ basename = os.path.basename(path) |
81 |
+ basename_index.setdefault(basename, []).append(d) |
82 |
+ else: |
83 |
+ instance_key = _instance_key(cpv) |
84 |
+ pkg_paths[instance_key] = path |
85 |
+ self.dbapi.cpv_inject(cpv) |
86 |
|
87 |
update_pkgindex = False |
88 |
for mydir, file_names in dir_files.items(): |
89 |
@@ -798,9 +813,10 @@ class binarytree(object): |
90 |
d.pop("PATH", None) |
91 |
metadata[_instance_key(mycpv)] = d |
92 |
|
93 |
- for instance_key in list(metadata): |
94 |
- if instance_key not in pkg_paths: |
95 |
- del metadata[instance_key] |
96 |
+ if reindex: |
97 |
+ for instance_key in list(metadata): |
98 |
+ if instance_key not in pkg_paths: |
99 |
+ del metadata[instance_key] |
100 |
|
101 |
if update_pkgindex: |
102 |
del pkgindex.packages[:] |
103 |
diff --git a/man/make.conf.5 b/man/make.conf.5 |
104 |
index cc4e1eba8..9dcd35b2c 100644 |
105 |
--- a/man/make.conf.5 |
106 |
+++ b/man/make.conf.5 |
107 |
@@ -561,6 +561,14 @@ Supported only on Linux. Requires PID and mount namespace support |
108 |
in kernel. /proc is remounted inside the mount namespace to account |
109 |
for new PID namespace. |
110 |
.TP |
111 |
+.B pkgdir\-index\-trusted |
112 |
+Trust that the \fBPKGDIR\fR index file is valid, meaning that no packages |
113 |
+have been manually added or removed since the last call to |
114 |
+\fBemaint \-\-fix binhost\fR. This feature eliminates overhead involved |
115 |
+with detection of packages that have been manually added or removed, |
116 |
+which significantly improves performance in some cases, such as when |
117 |
+\fBPKGDIR\fR resides on a high\-latency network file system. |
118 |
+.TP |
119 |
.B prelink\-checksums |
120 |
If \fBprelink\fR(8) is installed then use it to undo any prelinks on files |
121 |
before computing checksums for merge and unmerge. This feature is |
122 |
-- |
123 |
2.21.0 |