Valentin David pushed to branch valentindavid/deterministic-source at BuildStream / buildstream
Commits:
-
e5c6d937
by Valentin David at 2018-08-07T08:40:18Z
1 changed file:
Changes:
... | ... | @@ -116,9 +116,12 @@ class TarSource(DownloadableFileSource): |
116 | 116 |
|
117 | 117 |
with utils.reproducible_umask():
|
118 | 118 |
if base_dir:
|
119 |
- tar.extractall(path=directory, members=self._extract_members(tar, base_dir))
|
|
119 |
+ members = self._extract_members(tar, base_dir)
|
|
120 |
+ tar.extractall(path=directory,
|
|
121 |
+ members=_deterministic_user(members))
|
|
120 | 122 |
else:
|
121 |
- tar.extractall(path=directory)
|
|
123 |
+ tar.extractall(path=directory,
|
|
124 |
+ members=_deterministic_user(tar))
|
|
122 | 125 |
|
123 | 126 |
except (tarfile.TarError, OSError) as e:
|
124 | 127 |
raise SourceError("{}: Error staging source: {}".format(self, e)) from e
|
... | ... | @@ -200,5 +203,15 @@ class TarSource(DownloadableFileSource): |
200 | 203 |
return matches[0]
|
201 | 204 |
|
202 | 205 |
|
206 |
+# Set deterministic user in metadata
|
|
207 |
+def _deterministic_user(tarinfos):
|
|
208 |
+ for tarinfo in tarinfos:
|
|
209 |
+ tarinfo.uid = 0
|
|
210 |
+ tarinfo.gid = 0
|
|
211 |
+ tarinfo.uname = 'root'
|
|
212 |
+ tarinfo.gname = 'root'
|
|
213 |
+ yield tarinfo
|
|
214 |
+ |
|
215 |
+ |
|
203 | 216 |
def setup():
|
204 | 217 |
return TarSource
|