[reprotest] 01/04: Automatically detect arch linux

Ximin Luo infinity0 at debian.org
Mon Nov 6 10:30:28 UTC 2017


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

infinity0 pushed a commit to branch master
in repository reprotest.

commit 0844688ee496f2b3b5ba2b16838db8fe66dcaed4
Author: kpcyrd <git at rxv.cc>
Date:   Thu Nov 2 03:09:41 2017 +0100

    Automatically detect arch linux
---
 reprotest/__init__.py        |  6 +++---
 reprotest/lib/adt_testbed.py | 23 ++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index b6349c6..4494529 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -70,7 +70,7 @@ class Testbed(adt_testbed.Testbed):
         raise _type(m)
 
 @contextlib.contextmanager
-def start_testbed(args, temp_dir, no_clean_on_error=False, host_distro='debian'):
+def start_testbed(args, temp_dir, no_clean_on_error=False, host_distro=None):
     '''This is a simple wrapper around adt_testbed that automates the
     initialization and cleanup.'''
     # Find the location of reprotest using setuptools and then get the
@@ -251,7 +251,7 @@ def run_diff(dist_0, dist_1, diffoscope_args, store_dir):
 class TestbedArgs(collections.namedtuple('_TestbedArgs',
     'virtual_server_args testbed_pre testbed_init testbed_build_pre host_distro')):
     @classmethod
-    def of(cls, virtual_server_args=[], testbed_pre=None, testbed_init=None, testbed_build_pre=None, host_distro='debian'):
+    def of(cls, virtual_server_args=[], testbed_pre=None, testbed_init=None, testbed_build_pre=None, host_distro=None):
         return cls(virtual_server_args, testbed_pre, testbed_init, testbed_build_pre, host_distro)
 
 
@@ -535,7 +535,7 @@ def cli_parser():
         help='An integer.  Control which messages are displayed.')
     group1.add_argument('-v', '--verbose', dest='verbosity', action='count',
         help='Like --verbosity, but given multiple times without arguments.')
-    group1.add_argument('--host-distro', default='debian',
+    group1.add_argument('--host-distro', default=None,
         help='The distribution that will run the tests (Default: %(default)s)')
     group1.add_argument('-s', '--source-root', default=None, metavar='PATH',
         help='Root of the source tree, that is copied to the virtual server '
diff --git a/reprotest/lib/adt_testbed.py b/reprotest/lib/adt_testbed.py
index 2fa9763..9e70e6c 100644
--- a/reprotest/lib/adt_testbed.py
+++ b/reprotest/lib/adt_testbed.py
@@ -50,10 +50,27 @@ timeouts = {'short': 100, 'copy': 300, 'install': 3000, 'test': 10000,
             'build': 100000}
 
 
+def os_release():
+    os_release = dict()
+
+    try:
+        with open('/etc/os-release') as f:
+            for line in f:
+                try:
+                    key, value = line.strip().split('=', 1)
+                    os_release[key] = value.strip('\'\"')
+                except ValueError:
+                    pass
+    except:
+        adtlog.warning("Could not load /etc/os-release")
+
+    return os_release
+
+
 class Testbed:
     def __init__(self, vserver_argv, output_dir, user,
                  setup_commands=[], setup_commands_boot=[], add_apt_pockets=[],
-                 copy_files=[], host_distro='debian'):
+                 copy_files=[], host_distro=None):
         self.sp = None
         self.lastsend = None
         self.scratch = None
@@ -89,6 +106,10 @@ class Testbed:
             self.devnull = open(os.devnull, 'rb')
 
 
+        if not host_distro:
+            host_distro = os_release().get('ID')
+            adtlog.info("Tried distro auto-detection, got %r" % host_distro)
+
         if host_distro in SYSTEM_INTERFACES:
             self.system_interface = SYSTEM_INTERFACES[host_distro]()
         else:

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