#281 Add mock-option '--no-bootstrap-chroot' to defaults
Closed 5 years ago by ngompa. Opened 6 years ago by besser82.
besser82/FedoraReview bugfix/mock_no_bootstrap_chroot  into  master

file modified
+3 -3
@@ -117,9 +117,9 @@ 

  /etc/mock/default.cfg

  .TP 4

  .B -o, --mock-options "options..."

- Mock options for the build. Defaults to --no-cleanup-after, you might

- want this along with other options

- you provide.

+ Mock options for the build. Defaults to --no-cleanup-after --no-clean,

+ for use with mock >= 1.4.1 --no-bootstrap-chroot additionally, you might

+ want this along with other options you provide.

  .TP 4

  .B --no-report

  Do not generate the review template.

file modified
+20 -3
@@ -26,9 +26,11 @@ 

  import os

  import os.path

  import re

+ import subprocess

  import sys

  

  import ansi

+ from packaging import version

  from review_error import ReviewError

  from xdg_dirs import XdgDirs

  
@@ -53,6 +55,21 @@ 

          raise ReviewError(mock_msg)

  

  

+ def _check_mock_ver():

+     try:

+         mock_ver = subprocess.check_output(['mock', '--version'])

+     except subprocess.CalledProcessError:

+         mock_ver = '0'

+     return mock_ver

+ 

+ 

+ def _mock_options_default():

+     mock_opts = '--no-cleanup-after --no-clean'

+     if(version.parse(_check_mock_ver()) >= version.parse('1.4.1')):

+         mock_opts = '--no-bootstrap-chroot %s' % mock_opts

+     return mock_opts

+ 

+ 

  def _add_modes(modes):

      ''' Add all mode arguments to the option parser group modes. '''

      modes.add_argument('-b', '--bug', metavar='<bug>',
@@ -111,10 +128,10 @@ 

                            help='Do not rebuild or install the srpm, use last'

                            ' built one in mock. Implies --cache')

      optional.add_argument('-o', '--mock-options', metavar='<mock options>',

-                           default='--no-cleanup-after --no-clean',

+                           default=_mock_options_default(),

                            dest='mock_options',

-                           help='Options to specify to mock for the build,'

-                           ' defaults to --no-cleanup-after --no-clean')

+                           help=('Options to specify to mock for the build,'

+                           ' defaults to %s' % _mock_options_default()))

      optional.add_argument('--other-bz', default=None,

                            metavar='<bugzilla url>', dest='other_bz',

                            help='Alternative bugzilla URL')

This is a temporary fix for mock >= 1.4.1

hm... have you a mock bug link for this? Or something else describing the issue fixed a little more detailed?

If you won't mind, I'll apply this patch to f-r on F25+ and add this to the update of mock-1.4.1 in updates-testing.

I'm worried that this fix will break f-r if mock is < 1.4.1, since the option does not exist then. You probably need to check the mock version in runtime before adding that option, right?

I will add a check for mock being >= 1.4.1

rebased

6 years ago

I've rebased the commit to perform a runtime check for the mock version and change the default mock options based on that.

I've added this commit as a patch to fedora-review to SCM and built on F25+.

Note that no_bootstrap_chroot is now default for mock 1.4.2.

Yes, but the cli switch is still valid for mock 1.4.2… I'd opt in for merging this to prevent any future breakage, if bootstrap chroot is turned on by default again…

Since the patch is already in dist-git I do not see a reason not to merge this PR.

I have upstreamed the patch into the devel branch, yet to be released.

Pull-Request has been closed by ngompa

5 years ago

This patch already exists in devel, so closing.