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