[Reproducible-commits] [reprotest] 01/01: Work around probable bug in disorderfs with umask
Ceridwen
ceridwen-guest at moszumanska.debian.org
Thu Jun 9 20:40:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
ceridwen-guest pushed a commit to branch master
in repository reprotest.
commit 0a70ef20279c16ff619871d16869419504b01ac5
Author: Ceridwen <ceridwenv at gmail.com>
Date: Thu Jun 9 16:40:18 2016 -0400
Work around probable bug in disorderfs with umask
---
reprotest/__init__.py | 14 ++++++++++----
tests/build.py | 40 ++++++++++++++++++++++------------------
2 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index 6d01f3d..6b47df4 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -38,18 +38,19 @@ def captures_environment(command1, command2, env1, env2, tree1, tree2):
def domain_host(command1, command2, env1, env2, tree1, tree2):
yield command1, command2, env1, env2, tree1, tree2
-# TODO: disorderfs must be unmounted after the build, which probably
-# requires some context-manager silliness.
@contextlib.contextmanager
def filesystem(command1, command2, env1, env2, tree1, tree2):
disorderfs = tree2.parent/'disorderfs'
disorderfs.mkdir()
subprocess.check_call(['disorderfs', '--shuffle-dirents=yes',
- # '--pad-blocks=10',
str(tree2), str(disorderfs)])
yield command1, command2, env1, env2, tree1, disorderfs
subprocess.check_call(['fusermount', '-u', str(disorderfs)])
+# @contextlib.contextmanager
+# def filesystem(command1, command2, env1, env2, tree1, tree2):
+# yield command1, command2, env1, env2, tree1, tree2
+
@contextlib.contextmanager
def home(command1, command2, env1, env2, tree1, tree2):
env1['HOME'] = '/nonexistent/first-build'
@@ -114,9 +115,11 @@ def timezone(command1, command2, env1, env2, tree1, tree2):
env2['TZ'] = 'GMT-14'
yield command1, command2, env1, env2, tree1, tree2
+# TODO: This is currently operating on command1 to work around this
+# bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=826891
@contextlib.contextmanager
def umask(command1, command2, env1, env2, tree1, tree2):
- command2 = ['umask', '0002;'] + command2
+ command1 = ['umask', '0002;'] + command1
yield command1, command2, env1, env2, tree1, tree2
# TODO: This definitely requires superuser privileges.
@@ -135,6 +138,7 @@ VARIATIONS = collections.OrderedDict([
])
def build(command, source_root, built_artifact, artifact_store, **kws):
+ # print(command)
subprocess.check_call(command, cwd=source_root, **kws)
with open(built_artifact, 'rb') as artifact:
artifact_store.write(artifact.read())
@@ -148,9 +152,11 @@ def check(build_command, artifact_name, source_root, variations=VARIATIONS):
env2 = env1.copy()
tree1 = pathlib.Path(shutil.copytree(str(source_root), temp + '/tree1'))
tree2 = pathlib.Path(shutil.copytree(str(source_root), temp + '/tree2'))
+ # print(build_command)
with contextlib.ExitStack() as stack:
try:
for variation in variations:
+ # print(variation)
command1, command2, env1, env2, tree1, tree2 = stack.enter_context(VARIATIONS[variation](command1, command2, env1, env2, tree1, tree2))
build(' '.join(command1), str(tree1),
temp + '/tree1/' + artifact_name,
diff --git a/tests/build.py b/tests/build.py
index 6937795..083b24e 100755
--- a/tests/build.py
+++ b/tests/build.py
@@ -5,8 +5,9 @@ import argparse
import locale
import os
import pathlib
+import stat
import subprocess
-import tarfile
+# import tarfile
import tempfile
import time
@@ -18,20 +19,21 @@ if __name__ == '__main__':
help='Reproducibility properties.')
args = set(arg_parser.parse_args().commands)
output = [b'']
+ # This test can theoretically fail by producing the same
+ # random bits in both runs, but it is extremely unlikely.
if 'irreproducible' in args:
- # This test can theoretically fail by producing the same
- # random bits in both runs, but it is extremely unlikely.
output.append(os.urandom(1024))
+ # Like the above test, this test can theoretically fail by
+ # producing the same file order, but this is unlikely, if not
+ # as unlikely as in the above test.
if 'filesystem' in args:
- # Like the above test, this test can theoretically fail by
- # producing the same file order, but this is unlikely, if not
- # as unlikely as in the above test.
- test_file_order = pathlib.Path.cwd()/'test_file_order'
- if not test_file_order.exists():
- test_file_order.mkdir()
+ # Ensure this temporary directory is created in the disorders
+ # mount point by passing the dir argument.
+ with tempfile.TemporaryDirectory(dir=str(pathlib.Path.cwd())) as temp:
+ test_file_order = pathlib.Path(temp)
for i in range(20):
- (test_file_order/str(i)).touch()
- output.extend(p.name.encode('ascii') for p in test_file_order.iterdir())
+ str((test_file_order/str(i)).touch())
+ output.extend(p.name.encode('ascii') for p in test_file_order.iterdir())
if 'home' in args:
output.append(os.path.expanduser('~').encode('ascii'))
if 'kernel' in args:
@@ -45,12 +47,14 @@ if __name__ == '__main__':
if 'timezone' in args:
output.append(str(time.timezone).encode('ascii'))
if 'umask' in args:
- test_permissions = pathlib.Path.cwd()/'test_permissions'
- test_permissions.touch()
- with tempfile.TemporaryFile() as temp:
- archive = tarfile.open(name='temp', mode='w', fileobj=temp)
- archive.add(str(test_permissions))
- temp.seek(0)
- output.append(temp.read())
+ with tempfile.TemporaryDirectory(dir=str(pathlib.Path.cwd())) as temp:
+ test_permissions = pathlib.Path(temp)/'test_permissions'
+ test_permissions.touch()
+ output.append(stat.filemode(test_permissions.stat().st_mode).encode('ascii'))
+ # with tempfile.TemporaryFile() as file_object:
+ # archive_object = tarfile.open(name='temp', mode='w', fileobj=file_object)
+ # archive_object.add(str(test_permissions))
+ # file_object.seek(0)
+ # output.append(file_object.read())
with open('artifact', 'wb') as artifact:
artifact.write(b''.join(output))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git
More information about the Reproducible-commits
mailing list