#26 quote scm_option_get output
Closed 7 years ago by clime. Opened 7 years ago by immanetize.
copr/ immanetize/copr git_get  into  master

@@ -334,9 +334,9 @@ 

  

      def scm_option_get(self, package_name, branch):

          return {

-             "git": branch and "git_get=git clone --depth 1 --branch {branch} {0} {1}" or \

-                    "git_get=git clone --depth 1 {0} {1}",

-             "svn": "git_get=git svn clone {0} {1}"

+             "git": branch and "'git_get=git clone --depth 1 --branch {branch} {0} {1}'" or \

+                    "'git_get=git clone --depth 1 {0} {1}'",

+             "svn": "'git_get=git svn clone {0} {1}'"

          }[self.task.mock_scm_type].format(self.task.mock_scm_url, package_name, branch=branch)

  

  

The entirety of scm_option_get's output is an argument to an option for mock, but missing quotes left mock trying to interpret arguments intended for the scm backend. Affected builds reported at https://ask.fedoraproject.org/en/question/100066/ . Here's a rough test:

>>> def go(package_name, branch):
...     return {
...             "git": branch and "'git_get=git clone --depth 1 --branch {branch} {0} {1}'" or \                      
...                     "'git_get=git clone --depth 1 {0} {1}'",
...             "svn": "'git_get=git svn clone {0} {1}'"
...             }['git'].format('https://github.com/Tendrl/commons tendrl-commons', package_name, branch=branch)
... 
>>> arg = go('tendril-commons', 'master')                                                                             
>>> print arg
'git_get=git clone --depth 1 --branch master https://github.com/Tendrl/commons tendrl-commons tendril-commons'

Actually, the command output in the import log is not right in quoting. The command git_get=... is in fact quoted when executed because it is one of the elements of the list that is passed to Popen ( https://pagure.io/copr/copr/blob/master/f/dist-git/dist_git/dist_git_importer.py#_724). The log omits quotes around individual elements, that are effectively there when the import command is executed, because it is created by " ".join(dcmd). The reason for epel7 imports occasionally failing is something else.

I improved command logging in https://pagure.io/copr/copr/c/d6e231a305b9123f8ddc6170fc494b19a2d4ae9b?branch=master. The actual import failure was caused by the importing process being killed by OOM killer as a result of system overload.

Pull-Request has been closed by clime

7 years ago
Metadata