#824 Add internal_dev_setup option to runroot config
Merged 4 years ago by mikem. Opened 4 years ago by mikem.

file modified
+5 -1
@@ -181,7 +181,8 @@ 

          self.config = self.session.getBuildConfig(self.tag_id, event=self.event_id)

  

      def _new(self, tag, arch, task_id, repo_id=None, install_group='build',

-              setup_dns=False, bind_opts=None, maven_opts=None, maven_envs=None, deps=None):

+              setup_dns=False, bind_opts=None, maven_opts=None, maven_envs=None,

+              deps=None, internal_dev_setup=None):

          """Create a brand new repo"""

          if not repo_id:

              raise koji.BuildrootError("A repo id must be provided")
@@ -223,6 +224,7 @@ 

          self.maven_opts = maven_opts

          self.maven_envs = maven_envs

          self.deps = deps

+         self.internal_dev_setup = internal_dev_setup

          self._writeMockConfig()

  

      def _writeMockConfig(self):
@@ -247,6 +249,8 @@ 

          opts['target_arch'] = self.target_arch

          if 'mock.package_manager' in self.config['extra']:

              opts['package_manager'] = self.config['extra']['mock.package_manager']

+         if self.internal_dev_setup is not None:

+             opts['internal_dev_setup'] = bool(self.internal_dev_setup)

          output = koji.genMockConfig(self.name, self.br_arch, managed=True, **opts)

  

          #write config

file modified
+15 -6
@@ -1529,26 +1529,35 @@ 

  # Koji tag: %(tag_name)s

  """ % locals())

  

+     if bind_opts:

+         # disable internal_dev_setup unless opts explicitly say otherwise

+         opts.setdefault('internal_dev_setup', False)

+ 

+     if 'internal_dev_setup' in opts:

+         config_opts['internal_dev_setup'] = opts['internal_dev_setup']

+ 

      parts.append("\n")

-     for key, value in six.iteritems(config_opts):

+     for key in sorted(config_opts):

+         value = config_opts[key]

          parts.append("config_opts[%r] = %r\n" % (key, value))

      parts.append("\n")

-     for key, value in six.iteritems(plugin_conf):

+     for key in sorted(plugin_conf):

+         value = plugin_conf[key]

          parts.append("config_opts['plugin_conf'][%r] = %r\n" % (key, value))

      parts.append("\n")

  

      if bind_opts:

-         # This line is REQUIRED for mock to work if bind_opts defined.

-         parts.append("config_opts['internal_dev_setup'] = False\n")

          for key in bind_opts.keys():

              for mnt_src, mnt_dest in six.iteritems(bind_opts.get(key)):

                  parts.append("config_opts['plugin_conf']['bind_mount_opts'][%r].append((%r, %r))\n" % (key, mnt_src, mnt_dest))

          parts.append("\n")

  

-     for key, value in six.iteritems(macros):

+     for key in sorted(macros):

+         value = macros[key]

          parts.append("config_opts['macros'][%r] = %r\n" % (key, value))

      parts.append("\n")

-     for key, value in six.iteritems(files):

+     for key in sorted(files):

+         value = files[key]

          parts.append("config_opts['files'][%r] = %r\n" % (key, value))

  

      return ''.join(parts)

file modified
+9 -1
@@ -55,8 +55,14 @@ 

             'safe_roots': [],

             'path_subs': [],

             'paths': [],

+            'internal_dev_setup': None,

          }

  

+         # main options

+         if cp.has_option('runroot', 'internal_dev_setup'):

+             self.config['internal_dev_setup'] = cp.getboolean('runroot', 'internal_dev_setup')

+ 

+         # path options

          if cp.has_option('paths', 'default_mounts'):

              self.config['default_mounts'] = cp.get('paths', 'default_mounts').split(',')

          if cp.has_option('paths', 'safe_roots'):
@@ -149,7 +155,9 @@ 

                                             arglist=[root, None, None],

                                             parent=self.id)

              repo_info = self.wait(task_id)[task_id]

-         broot = BuildRoot(self.session, self.options, root, br_arch, self.id, repo_id=repo_info['id'], setup_dns=True)

+         broot = BuildRoot(self.session, self.options, root, br_arch, self.id,

+                 repo_id=repo_info['id'], setup_dns=True,

+                 internal_dev_setup=self.config['internal_dev_setup'])

          broot.workdir = self.workdir

          broot.init()

          rootdir = broot.rootdir()

empty or binary file added
@@ -0,0 +1,8 @@ 

+ {

+     "name": "ROOTNAME",

+     "arch": "x86_64",

+     "managed": False,

+     "repoid": 99,

+     "tag_name": "TAG",

+     "internal_dev_setup": False

+ }

@@ -0,0 +1,24 @@ 

+ # Auto-generated by the Koji build system

+ 

+ config_opts['basedir'] = '/var/lib/mock'

+ config_opts['chroot_setup_cmd'] = 'groupinstall build'

+ config_opts['chroothome'] = '/builddir'

+ config_opts['internal_dev_setup'] = False

+ config_opts['root'] = 'ROOTNAME'

+ config_opts['rpmbuild_timeout'] = 86400

+ config_opts['target_arch'] = 'x86_64'

+ config_opts['use_host_resolv'] = False

+ config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'

+ 

+ config_opts['plugin_conf']['ccache_enable'] = False

+ config_opts['plugin_conf']['root_cache_enable'] = False

+ config_opts['plugin_conf']['yum_cache_enable'] = False

+ 

+ config_opts['macros']['%_host'] = 'x86_64-koji-linux-gnu'

+ config_opts['macros']['%_host_cpu'] = 'x86_64'

+ config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'

+ config_opts['macros']['%_topdir'] = '/builddir/build'

+ config_opts['macros']['%distribution'] = 'Unknown'

+ config_opts['macros']['%packager'] = 'Koji'

+ config_opts['macros']['%vendor'] = 'Koji'

+ 

@@ -0,0 +1,8 @@ 

+ {

+     "name": "ROOTNAME",

+     "arch": "x86_64",

+     "managed": False,

+     "repoid": 99,

+     "tag_name": "TAG",

+     "internal_dev_setup": True

+ }

@@ -0,0 +1,24 @@ 

+ # Auto-generated by the Koji build system

+ 

+ config_opts['basedir'] = '/var/lib/mock'

+ config_opts['chroot_setup_cmd'] = 'groupinstall build'

+ config_opts['chroothome'] = '/builddir'

+ config_opts['internal_dev_setup'] = True

+ config_opts['root'] = 'ROOTNAME'

+ config_opts['rpmbuild_timeout'] = 86400

+ config_opts['target_arch'] = 'x86_64'

+ config_opts['use_host_resolv'] = False

+ config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'

+ 

+ config_opts['plugin_conf']['ccache_enable'] = False

+ config_opts['plugin_conf']['root_cache_enable'] = False

+ config_opts['plugin_conf']['yum_cache_enable'] = False

+ 

+ config_opts['macros']['%_host'] = 'x86_64-koji-linux-gnu'

+ config_opts['macros']['%_host_cpu'] = 'x86_64'

+ config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'

+ config_opts['macros']['%_topdir'] = '/builddir/build'

+ config_opts['macros']['%distribution'] = 'Unknown'

+ config_opts['macros']['%packager'] = 'Koji'

+ config_opts['macros']['%vendor'] = 'Koji'

+ 

@@ -0,0 +1,7 @@ 

+ {

+     "name": "ROOTNAME",

+     "arch": "x86_64",

+     "managed": False,

+     "repoid": 99,

+     "tag_name": "TAG"

+ }

@@ -0,0 +1,23 @@ 

+ # Auto-generated by the Koji build system

+ 

+ config_opts['basedir'] = '/var/lib/mock'

+ config_opts['chroot_setup_cmd'] = 'groupinstall build'

+ config_opts['chroothome'] = '/builddir'

+ config_opts['root'] = 'ROOTNAME'

+ config_opts['rpmbuild_timeout'] = 86400

+ config_opts['target_arch'] = 'x86_64'

+ config_opts['use_host_resolv'] = False

+ config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'

+ 

+ config_opts['plugin_conf']['ccache_enable'] = False

+ config_opts['plugin_conf']['root_cache_enable'] = False

+ config_opts['plugin_conf']['yum_cache_enable'] = False

+ 

+ config_opts['macros']['%_host'] = 'x86_64-koji-linux-gnu'

+ config_opts['macros']['%_host_cpu'] = 'x86_64'

+ config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'

+ config_opts['macros']['%_topdir'] = '/builddir/build'

+ config_opts['macros']['%distribution'] = 'Unknown'

+ config_opts['macros']['%packager'] = 'Koji'

+ config_opts['macros']['%vendor'] = 'Koji'

+ 

@@ -0,0 +1,30 @@ 

+ import ast

+ import os

+ import os.path

+ import unittest

+ 

+ import koji

+ 

+ 

+ class TestGenMockConfig(unittest.TestCase):

+ 

+     maxDiff = None

+ 

+     def test_gen_mock_config(self):

+         datadir = os.path.join(os.path.dirname(__file__), 'data/mock')

+         count = 0

+         for fn in os.listdir(datadir):

+             if not fn.endswith('.data'):

+                 continue

+             path = os.path.join(datadir, fn)

+             with open(path) as fo:

+                 s = fo.read()

+                 params = ast.literal_eval(s)

+             with open(path[:-5] + '.out') as fo:

+                 expected = fo.read()

+             output = koji.genMockConfig(**params)

+             self.assertMultiLineEqual(output, expected)

+             count += 1

+         if not count:

+             raise Exception('no test data found')

+ 

@@ -327,6 +327,7 @@ 

          options.topurls = None

          self.t = runroot.RunRootTask(123, 'runroot', {}, self.session, options)

          self.t.config['default_mounts'] = ['default_mount']

+         self.t.config['internal_dev_setup'] = None

          self.t.do_mounts = mock.MagicMock()

          self.t.do_extra_mounts = mock.MagicMock()

          self.t.undo_mounts = mock.MagicMock()
@@ -370,7 +371,8 @@ 

          self.session.repoInfo.assert_called_once_with(1, strict=True)

          self.session.host.subtask.assert_not_called()

          runroot.BuildRoot.assert_called_once_with(self.session, self.t.options,

-                 'tag_name', 'x86_64', self.t.id, repo_id=1, setup_dns=True)

+                 'tag_name', 'x86_64', self.t.id, repo_id=1, setup_dns=True,

+                 internal_dev_setup=None)

          os_system.assert_called_once()

          self.session.host.setBuildRootState.assert_called_once_with(678, 'BUILDING')

          self.br.mock.assert_has_calls([