1 |
Disable Manifest "stable mtime" behavior by default, and add |
2 |
a corresponding egencache option. |
3 |
|
4 |
Suggested-by: Michał Górny <mgorny@g.o> |
5 |
--- |
6 |
bin/egencache | 6 +++++- |
7 |
man/egencache.1 | 3 +++ |
8 |
pym/portage/manifest.py | 14 +++++++++----- |
9 |
.../package/ebuild/_parallel_manifest/ManifestProcess.py | 6 ++++-- |
10 |
.../package/ebuild/_parallel_manifest/ManifestScheduler.py | 7 +++++-- |
11 |
.../package/ebuild/_parallel_manifest/ManifestTask.py | 8 +++++--- |
12 |
6 files changed, 31 insertions(+), 13 deletions(-) |
13 |
|
14 |
diff --git a/bin/egencache b/bin/egencache |
15 |
index 7e3387e..07665e8 100755 |
16 |
--- a/bin/egencache |
17 |
+++ b/bin/egencache |
18 |
@@ -120,6 +120,9 @@ def parse_args(args): |
19 |
choices=('y', 'n'), |
20 |
metavar="<y|n>", |
21 |
help="manually override layout.conf sign-manifests setting") |
22 |
+ common.add_argument("--stable-mtime", |
23 |
+ action="store_true", |
24 |
+ help="apply stable mtime to generated manifests (for rsync)") |
25 |
common.add_argument("--strict-manifests", |
26 |
choices=('y', 'n'), |
27 |
metavar="<y|n>", |
28 |
@@ -1151,7 +1154,8 @@ def egencache_main(args): |
29 |
force_sign_key=force_sign_key, |
30 |
max_jobs=options.jobs, |
31 |
max_load=options.load_average, |
32 |
- event_loop=event_loop) |
33 |
+ event_loop=event_loop, |
34 |
+ manifest_kwargs=dict(stable_mtime=options.stable_mtime)) |
35 |
|
36 |
signum = run_main_scheduler(scheduler) |
37 |
if signum is not None: |
38 |
diff --git a/man/egencache.1 b/man/egencache.1 |
39 |
index 7fd17c2..081e8c1 100644 |
40 |
--- a/man/egencache.1 |
41 |
+++ b/man/egencache.1 |
42 |
@@ -100,6 +100,9 @@ Manually override layout.conf sign-manifests setting. |
43 |
.BR "\-\-strict\-manifests< y | n >" |
44 |
Manually override "strict" FEATURES setting. |
45 |
.TP |
46 |
+.BR "\-\-stable\-mtime" |
47 |
+Apply stable mtime to generated manifests (for rsync). |
48 |
+.TP |
49 |
.BR "\-\-thin\-manifests< y | n >" |
50 |
Manually override layout.conf thin-manifests setting. |
51 |
.TP |
52 |
diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py |
53 |
index 818515f..0724272 100644 |
54 |
--- a/pym/portage/manifest.py |
55 |
+++ b/pym/portage/manifest.py |
56 |
@@ -128,7 +128,7 @@ class Manifest(object): |
57 |
def __init__(self, pkgdir, distdir=None, fetchlist_dict=None, |
58 |
manifest1_compat=DeprecationWarning, from_scratch=False, thin=False, |
59 |
allow_missing=False, allow_create=True, hashes=None, |
60 |
- find_invalid_path_char=None): |
61 |
+ find_invalid_path_char=None, stable_mtime=False): |
62 |
""" Create new Manifest instance for package in pkgdir. |
63 |
Do not parse Manifest file if from_scratch == True (only for internal use) |
64 |
The fetchlist_dict parameter is required only for generation of |
65 |
@@ -145,6 +145,7 @@ class Manifest(object): |
66 |
find_invalid_path_char = _find_invalid_path_char |
67 |
self._find_invalid_path_char = find_invalid_path_char |
68 |
self.pkgdir = _unicode_decode(pkgdir).rstrip(os.sep) + os.sep |
69 |
+ self.stable_mtime = stable_mtime |
70 |
self.fhashdict = {} |
71 |
self.hashes = set() |
72 |
|
73 |
@@ -283,7 +284,6 @@ class Manifest(object): |
74 |
myentries = list(self._createManifestEntries()) |
75 |
update_manifest = True |
76 |
preserved_stats = {} |
77 |
- preserved_stats[self.pkgdir.rstrip(os.sep)] = os.stat(self.pkgdir) |
78 |
if myentries and not force: |
79 |
try: |
80 |
f = io.open(_unicode_encode(self.getFullname(), |
81 |
@@ -291,7 +291,9 @@ class Manifest(object): |
82 |
mode='r', encoding=_encodings['repo.content'], |
83 |
errors='replace') |
84 |
oldentries = list(self._parseManifestLines(f)) |
85 |
- preserved_stats[self.getFullname()] = os.fstat(f.fileno()) |
86 |
+ if self.stable_mtime: |
87 |
+ preserved_stats[self.getFullname()] = os.fstat(f.fileno()) |
88 |
+ preserved_stats[self.pkgdir.rstrip(os.sep)] = os.stat(self.pkgdir) |
89 |
f.close() |
90 |
if len(oldentries) == len(myentries): |
91 |
update_manifest = False |
92 |
@@ -313,7 +315,8 @@ class Manifest(object): |
93 |
# non-empty for all currently known use cases. |
94 |
write_atomic(self.getFullname(), "".join("%s\n" % |
95 |
_unicode(myentry) for myentry in myentries)) |
96 |
- self._apply_max_mtime(preserved_stats, myentries) |
97 |
+ if self.stable_mtime: |
98 |
+ self._apply_max_mtime(preserved_stats, myentries) |
99 |
rval = True |
100 |
else: |
101 |
# With thin manifest, there's no need to have |
102 |
@@ -442,7 +445,8 @@ class Manifest(object): |
103 |
fetchlist_dict=self.fetchlist_dict, from_scratch=True, |
104 |
thin=self.thin, allow_missing=self.allow_missing, |
105 |
allow_create=self.allow_create, hashes=self.hashes, |
106 |
- find_invalid_path_char=self._find_invalid_path_char) |
107 |
+ find_invalid_path_char=self._find_invalid_path_char, |
108 |
+ stable_mtime=self.stable_mtime) |
109 |
pn = os.path.basename(self.pkgdir.rstrip(os.path.sep)) |
110 |
cat = self._pkgdir_category() |
111 |
|
112 |
diff --git a/pym/portage/package/ebuild/_parallel_manifest/ManifestProcess.py b/pym/portage/package/ebuild/_parallel_manifest/ManifestProcess.py |
113 |
index 44e2576..01595a3 100644 |
114 |
--- a/pym/portage/package/ebuild/_parallel_manifest/ManifestProcess.py |
115 |
+++ b/pym/portage/package/ebuild/_parallel_manifest/ManifestProcess.py |
116 |
@@ -10,14 +10,16 @@ from portage.util._async.ForkProcess import ForkProcess |
117 |
|
118 |
class ManifestProcess(ForkProcess): |
119 |
|
120 |
- __slots__ = ("cp", "distdir", "fetchlist_dict", "repo_config") |
121 |
+ __slots__ = ("cp", "distdir", "fetchlist_dict", "manifest_kwargs", |
122 |
+ "repo_config") |
123 |
|
124 |
MODIFIED = 16 |
125 |
|
126 |
def _run(self): |
127 |
mf = self.repo_config.load_manifest( |
128 |
os.path.join(self.repo_config.location, self.cp), |
129 |
- self.distdir, fetchlist_dict=self.fetchlist_dict) |
130 |
+ self.distdir, fetchlist_dict=self.fetchlist_dict, |
131 |
+ **(self.manifest_kwargs or {})) |
132 |
|
133 |
try: |
134 |
mf.create(assumeDistHashesAlways=True) |
135 |
diff --git a/pym/portage/package/ebuild/_parallel_manifest/ManifestScheduler.py b/pym/portage/package/ebuild/_parallel_manifest/ManifestScheduler.py |
136 |
index 38ac482..8a1c1d0 100644 |
137 |
--- a/pym/portage/package/ebuild/_parallel_manifest/ManifestScheduler.py |
138 |
+++ b/pym/portage/package/ebuild/_parallel_manifest/ManifestScheduler.py |
139 |
@@ -12,11 +12,13 @@ from .ManifestTask import ManifestTask |
140 |
class ManifestScheduler(AsyncScheduler): |
141 |
|
142 |
def __init__(self, portdb, cp_iter=None, |
143 |
- gpg_cmd=None, gpg_vars=None, force_sign_key=None, **kwargs): |
144 |
+ gpg_cmd=None, gpg_vars=None, force_sign_key=None, |
145 |
+ manifest_kwargs=None, **kwargs): |
146 |
|
147 |
AsyncScheduler.__init__(self, **kwargs) |
148 |
|
149 |
self._portdb = portdb |
150 |
+ self._manifest_kwargs = manifest_kwargs |
151 |
|
152 |
if cp_iter is None: |
153 |
cp_iter = self._iter_every_cp() |
154 |
@@ -79,7 +81,8 @@ class ManifestScheduler(AsyncScheduler): |
155 |
yield ManifestTask(cp=cp, distdir=distdir, |
156 |
fetchlist_dict=fetchlist_dict, repo_config=repo_config, |
157 |
gpg_cmd=self._gpg_cmd, gpg_vars=self._gpg_vars, |
158 |
- force_sign_key=self._force_sign_key) |
159 |
+ force_sign_key=self._force_sign_key, |
160 |
+ manifest_kwargs=self._manifest_kwargs) |
161 |
|
162 |
def _task_exit(self, task): |
163 |
|
164 |
diff --git a/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py b/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py |
165 |
index 0ee2b91..fb5e16e 100644 |
166 |
--- a/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py |
167 |
+++ b/pym/portage/package/ebuild/_parallel_manifest/ManifestTask.py |
168 |
@@ -18,8 +18,8 @@ from .ManifestProcess import ManifestProcess |
169 |
|
170 |
class ManifestTask(CompositeTask): |
171 |
|
172 |
- __slots__ = ("cp", "distdir", "fetchlist_dict", "gpg_cmd", |
173 |
- "gpg_vars", "repo_config", "force_sign_key", "_manifest_path") |
174 |
+ __slots__ = ("cp", "distdir", "fetchlist_dict", "force_sign_key", |
175 |
+ "gpg_cmd", "gpg_vars", "manifest_kwargs", "repo_config", "_manifest_path") |
176 |
|
177 |
_PGP_HEADER = b"BEGIN PGP SIGNED MESSAGE" |
178 |
_manifest_line_re = re.compile(r'^(%s) ' % "|".join(MANIFEST2_IDENTIFIERS)) |
179 |
@@ -30,7 +30,9 @@ class ManifestTask(CompositeTask): |
180 |
self._manifest_path = os.path.join(self.repo_config.location, |
181 |
self.cp, "Manifest") |
182 |
manifest_proc = ManifestProcess(cp=self.cp, distdir=self.distdir, |
183 |
- fetchlist_dict=self.fetchlist_dict, repo_config=self.repo_config, |
184 |
+ fetchlist_dict=self.fetchlist_dict, |
185 |
+ manifest_kwargs=self.manifest_kwargs, |
186 |
+ repo_config=self.repo_config, |
187 |
scheduler=self.scheduler) |
188 |
self._start_task(manifest_proc, self._manifest_proc_exit) |
189 |
|
190 |
-- |
191 |
2.4.10 |