Created
October 23, 2014 09:26
-
-
Save wico/d21d2532985815ed2a4e to your computer and use it in GitHub Desktop.
If set to true and if the scm-method is "git", mock does a "git submodule update --init --recursive" as a final step after code checkout and possibly branch-switches. Without "git submodule update --init --recursive" but with cloned submodules, all the submodules are master-branch-only. Thus, you can't point to a submodule's non-master-branch wi…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/etc/mock/site-defaults.cfg b/etc/mock/site-defaults.cfg | |
index 32472e4..c5ecfd3 100644 | |
--- a/etc/mock/site-defaults.cfg | |
+++ b/etc/mock/site-defaults.cfg | |
@@ -118,6 +118,7 @@ | |
# config_opts['scm_opts']['cvs_get'] = 'cvs -d /srv/cvs co SCM_BRN SCM_PKG' | |
# config_opts['scm_opts']['git_get'] = 'git clone SCM_BRN git://localhost/SCM_PKG.git SCM_PKG' | |
# config_opts['scm_opts']['svn_get'] = 'svn co file:///srv/svn/SCM_PKG/SCM_BRN SCM_PKG' | |
+# config_opts['scm_opts']['update_submodules'] = False | |
# config_opts['scm_opts']['spec'] = 'SCM_PKG.spec' | |
# config_opts['scm_opts']['ext_src_dir'] = '/dev/null' | |
# config_opts['scm_opts']['write_tar'] = True | |
diff --git a/py/mockbuild/scm.py b/py/mockbuild/scm.py | |
index fe110d6..1d1ecee 100644 | |
--- a/py/mockbuild/scm.py | |
+++ b/py/mockbuild/scm.py | |
@@ -55,6 +55,19 @@ class scmWorker(object): | |
self.get = self.get.replace("SCM_BRN", "trunk") | |
self.get = self.get.replace("SCM_BRN", "") | |
+ self.submoduleupdatecommand = None | |
+ self.update_submodules = None | |
+ if 'update_submodules' in opts: | |
+ self.update_submodules = opts['update_submodules'] | |
+ if self.update_submodules: | |
+ if str(self.update_submodules).lower() == "true": | |
+ # We only support git here. All other SCM methodes are unsupported if update_submodules is set to True. | |
+ if self.method == "git": | |
+ self.submoduleupdatecommand = "git submodule update --init --recursive" | |
+ else: | |
+ self.log.error("Unsupported SCM method: " + self.method) | |
+ sys.exit(5) | |
+ | |
if 'package' in opts: | |
self.pkg = opts['package'] | |
else: | |
@@ -73,6 +86,7 @@ class scmWorker(object): | |
self.log.debug("SCM checkout command: " + self.get) | |
self.log.debug("SCM checkout post command: " + str(self.postget)) | |
+ self.log.debug("SCM submodule update command: " + str(self.submoduleupdatecommand)) | |
self.environ = os.environ.copy() | |
# Set HOME properly while checking out from SCM since tools like | |
# Subversion might have there settings needed to carry out checkout | |
@@ -90,6 +104,8 @@ class scmWorker(object): | |
mockbuild.util.do(shlex.split(self.get), shell=False, cwd=self.wrk_dir, env=self.environ) | |
if self.postget: | |
mockbuild.util.do(shlex.split(self.postget), shell=False, cwd=self.src_dir, env=self.environ) | |
+ if self.submoduleupdatecommand: | |
+ mockbuild.util.do(shlex.split(self.submoduleupdatecommand), shell=False, cwd=self.src_dir, env=self.environ) | |
self.log.debug("Fetched sources from SCM") | |
decorate(traceLog()) | |
diff --git a/py/mockbuild/util.py b/py/mockbuild/util.py | |
index ebbecb6..44b9113 100644 | |
--- a/py/mockbuild/util.py | |
+++ b/py/mockbuild/util.py | |
@@ -579,6 +579,7 @@ def setup_default_config_opts(unprivUid, version, pkgpythondir): | |
'cvs_get': 'cvs -d /srv/cvs co SCM_BRN SCM_PKG', | |
'git_get': 'git clone SCM_BRN git://localhost/SCM_PKG.git SCM_PKG', | |
'svn_get': 'svn co file:///srv/svn/SCM_PKG/SCM_BRN SCM_PKG', | |
+ 'update_submodules': False, | |
'spec': 'SCM_PKG.spec', | |
'ext_src_dir': '/dev/null', | |
'write_tar': False, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This patch never made it into fedoras mock. So I keep it here ...