443188a
From 95c04ed7230671bc813fa1e5df99dc01101f1e85 Mon Sep 17 00:00:00 2001
443188a
From: Björn Esser <besser82@fedoraproject.org>
443188a
Date: Jun 02 2017 21:33:58 +0000
443188a
Subject: Add mock-option '--no-bootstrap-chroot' to defaults
443188a
443188a
This is a temporary fix for mock >= 1.4.1
443188a
443188a
---
443188a
443188a
diff --git a/fedora-review.1 b/fedora-review.1
443188a
index e4389ed..0e7a25f 100644
443188a
--- a/fedora-review.1
443188a
+++ b/fedora-review.1
443188a
@@ -117,9 +117,9 @@ with the .cfg suffix stripped. Defaults to the root defined in
443188a
 /etc/mock/default.cfg
443188a
 .TP 4
443188a
 .B -o, --mock-options "options..."
443188a
-Mock options for the build. Defaults to --no-cleanup-after, you might
443188a
-want this along with other options
443188a
-you provide.
443188a
+Mock options for the build. Defaults to --no-cleanup-after --no-clean,
443188a
+for use with mock >= 1.4.1 --no-bootstrap-chroot additionally, you might
443188a
+want this along with other options you provide.
443188a
 .TP 4
443188a
 .B --no-report
443188a
 Do not generate the review template.
443188a
diff --git a/src/FedoraReview/settings.py b/src/FedoraReview/settings.py
443188a
index 8d22751..c637775 100644
443188a
--- a/src/FedoraReview/settings.py
443188a
+++ b/src/FedoraReview/settings.py
443188a
@@ -26,9 +26,11 @@ import errno
443188a
 import os
443188a
 import os.path
443188a
 import re
443188a
+import subprocess
443188a
 import sys
443188a
 
443188a
 import ansi
443188a
+from packaging import version
443188a
 from review_error import ReviewError
443188a
 from xdg_dirs import XdgDirs
443188a
 
443188a
@@ -53,6 +55,21 @@ def _check_mock_grp():
443188a
         raise ReviewError(mock_msg)
443188a
 
443188a
 
443188a
+def _check_mock_ver():
443188a
+    try:
443188a
+        mock_ver = subprocess.check_output(['mock', '--version'])
443188a
+    except subprocess.CalledProcessError:
443188a
+        mock_ver = '0'
443188a
+    return mock_ver
443188a
+
443188a
+
443188a
+def _mock_options_default():
443188a
+    mock_opts = '--no-cleanup-after --no-clean'
443188a
+    if(version.parse(_check_mock_ver()) >= version.parse('1.4.1')):
443188a
+        mock_opts = '--no-bootstrap-chroot %s' % mock_opts
443188a
+    return mock_opts
443188a
+
443188a
+
443188a
 def _add_modes(modes):
443188a
     ''' Add all mode arguments to the option parser group modes. '''
443188a
     modes.add_argument('-b', '--bug', metavar='<bug>',
443188a
@@ -111,10 +128,10 @@ def _add_optionals(optional):
443188a
                           help='Do not rebuild or install the srpm, use last'
443188a
                           ' built one in mock. Implies --cache')
443188a
     optional.add_argument('-o', '--mock-options', metavar='<mock options>',
443188a
-                          default='--no-cleanup-after --no-clean',
443188a
+                          default=_mock_options_default(),
443188a
                           dest='mock_options',
443188a
-                          help='Options to specify to mock for the build,'
443188a
-                          ' defaults to --no-cleanup-after --no-clean')
443188a
+                          help=('Options to specify to mock for the build,'
443188a
+                          ' defaults to %s' % _mock_options_default()))
443188a
     optional.add_argument('--other-bz', default=None,
443188a
                           metavar='<bugzilla url>', dest='other_bz',
443188a
                           help='Alternative bugzilla URL')
443188a