[Reproducible-commits] [reprotest] 01/03: Improve documentation of variations

Ceridwen ceridwen-guest at moszumanska.debian.org
Sat Aug 20 15:57:57 UTC 2016


This is an automated email from the git hooks/post-receive script.

ceridwen-guest pushed a commit to branch variations
in repository reprotest.

commit a80173f275ae0b78ff06fca866bbe62dea8d7598
Author: Ceridwen <ceridwenv at gmail.com>
Date:   Thu Aug 18 10:23:42 2016 -0400

    Improve documentation of variations
---
 reprotest/__init__.py   | 42 ++++++++++++++++++++++++++----------------
 reprotest/_shell_ast.py |  7 +++----
 2 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index 36fbe80..eb3b55f 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -74,6 +74,7 @@ class Script(collections.namedtuple('_Script', 'build_command setup cleanup')):
     def __new__(cls, build_command, setup=_shell_ast.AndList(),
                 cleanup=_shell_ast.List()):
         return super().__new__(cls, build_command, setup, cleanup)
+        # return super().__new__(cls, _shell_ast.Quote(build_command), setup, cleanup)
 
     def append_command(self, command):
         '''Passes the current build command as the last argument to a given
@@ -114,6 +115,13 @@ class Script(collections.namedtuple('_Script', 'build_command setup cleanup')):
         is executed only if any of the setup commands or the build
         command fails.
 
+        TODO: schematic sketch
+
+        (setup && build);
+        exit_code=$?;
+        if [ $exit_code -ne 0 ];
+        then {cleanup};
+        fi
         '''
         subshell = _shell_ast.Subshell(self.setup +
                                        _shell_ast.AndList([self.build_command]))
@@ -382,6 +390,8 @@ def user_group(user, group, uid, gid):
     return user_group
 
 
+
+# TODO: calculate subsets rather than using the current truncation.
 class MultipleDispatch(collections.OrderedDict):
     '''This mapping holds the functions for creating the variations.
 
@@ -419,15 +429,17 @@ class MultipleDispatch(collections.OrderedDict):
 VARIATIONS_DISPATCH = types.MappingProxyType(MultipleDispatch([
     # (('bin_sh', 1), identity),
     (('build_path', 1), build_path),
+    (('file_ordering', 1, 'user'), file_ordering(['disorderfs', '--shuffle-dirents=yes'])),
+    (('file_ordering', 1, 'root'), file_ordering(['disorderfs', '--shuffle-dirents=yes', '--multi-user=yes'])),
+    # (('user_group', 0, 'root'), user_group('a-user', 'a-group', 20001, 20001)),
+    # (('user_group', 1, 'root'), user_group('another-user', 'another-group', 20002, 20002)),
     (('captures_environment', 1),
       environment_variable_variation(
           'CAPTURE_ENVIRONMENT', 'i_capture_the_environment')),
     (('domain', 1, 'root', 'qemu'), domain_host('domain')),
-    (('file_ordering', 1, 'user'), file_ordering(['disorderfs', '--shuffle-dirents=yes'])),
-    (('file_ordering', 1, 'root'), file_ordering(['disorderfs', '--shuffle-dirents=yes', '--multi-user=yes'])),
+    (('host', 1, 'root', 'qemu'), domain_host('host')),
     (('home', 0), environment_variable_variation('HOME', '/nonexistent/first-build')),
     (('home', 1), environment_variable_variation('HOME', '/nonexistent/second-build')),
-    (('host', 1, 'root', 'qemu'), domain_host('host')),
     (('kernel', 1), kernel),
     (('locales', 0), locales(types.MappingProxyType(
         {'LANG': 'C', 'LANGUAGE': 'en_US:en'}))),
@@ -443,25 +455,23 @@ VARIATIONS_DISPATCH = types.MappingProxyType(MultipleDispatch([
     (('time_zone', 0), environment_variable_variation('TZ', 'GMT+12')),
     (('time_zone', 1), environment_variable_variation('TZ', 'GMT-14')),
     (('umask', 1), umask),
-    (('user_group', 0, 'root'), user_group('a-user', 'a-group', 20001, 20001)),
-    (('user_group', 1, 'root'), user_group('another-user', 'another-group', 20002, 20002))
 ]))
 
 
-# The order of the variations is important.  At the moment, the only
-# constraint is that build_path must appear before file_ordering so
-# that the build path is changed before disorderfs is mounted.  This
-# uses an OrderedDict to simulate an ordered set when flattening the
-# dispatch table into a tuple of available variations.
+# The order of the variations is important.  build_path must appear
+# before file_ordering so that the build path is changed before
+# disorderfs is mounted; and user_group must appear before kernel, so
+# that su is added to the central build command first, executing the
+# quoted build command.  This could be changed so that the script can
+# handle having both execv-like commands (like setarch) and shell-like
+# commands (like su) added, but defining the order removes the
+# necessity of adding that functionality and makes the resulting
+# scripts easier to read, with fewer layers of shell-quoting.  This
+# calculation uses an OrderedDict to simulate an ordered set when
+# flattening the dispatch table into a tuple of available variations.
 VARIATIONS = tuple(collections.OrderedDict((k[0], None) for k in VARIATIONS_DISPATCH))
 
 
-# ('bin_sh', 'build_path', 'captures_environment',
-#               'domain', 'file_ordering', 'home', 'host', 'kernel',
-#               'locales', 'login_shell', 'path', 'time', 'time_zone',
-#               'umask', 'user_group')
-
-
 def build(script, source_root, build_path, built_artifact, testbed,
           artifact_store, env):
     # print(source_root)
diff --git a/reprotest/_shell_ast.py b/reprotest/_shell_ast.py
index ebb287d..a40e1c3 100644
--- a/reprotest/_shell_ast.py
+++ b/reprotest/_shell_ast.py
@@ -245,12 +245,11 @@ class CmdPrefix(BaseNode, _SequenceNode):
 
 class AssignmentWord(BaseNode,
                      collections.namedtuple('_AssignmentWord', 'target value')):
-    '''Corresponds to environment variable assignments of the form
-    target=value.
+    '''Corresponds to variable assignments of the form target=value.
 
     Attributes:
-        target (str): Environment variable name.
-        value (str): Environment variable value.
+        target (str): Variable name.
+        value (str): Variable value.
     '''
     __slots__ = ()
 

-- 
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