Gentoo Archives: gentoo-portage-dev

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

Replies

Subject Author
Re: [gentoo-portage-dev] [PATCH v2] egencache: add --stable-mtime option Alexander Berntsen <bernalex@g.o>