Bug 828677

Summary: mock command line option --scm-option write_tar=False is ignored
Product: [Fedora] Fedora Reporter: Stephan Dühr <stephan.duehr>
Component: mockAssignee: Clark Williams <williams>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: mebrown, myllynen, williams
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-22 22:01:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
[PATCH] Fix write_tar check in scm.py none

Description Stephan Dühr 2012-06-05 07:54:46 UTC
Description of problem:
When using mock with command line option --scm-option write_tar=False
it is ignored, the tar is written anyway

Version-Release number of selected component (if applicable):
mock-1.1.21-1.el6

How reproducible:
run mock and add --scm-option write_tar=False

Steps to Reproduce:
1. 
2.
3.
  
Actual results:
writes tar from SCM checkout

Expected results:
don't write tar and use tar file provided in SCM instead

Additional info:
In /usr/bin/mock, all --scm-option options are converted into strings:

    parser.add_option("--scm-option", action="append", dest="scm_opts",
                      default=[], type="string",
                      help="define an SCM option (may be used more than once)")

but /usr/lib/python2.6/site-packages/mockbuild/scm.py expects a boolean in line 128:
         if self.write_tar:

For debugging, I added some lines around that:
        self.log.debug("in scmWorker.prepare_sources(): self.write_tar value is %s" % self.write_tar)
        self.log.debug("in scmWorker.prepare_sources(): type of self.write_tar is %s" % type(self.write_tar))
        if self.write_tar:
            self.log.debug("self.write_tar should be True here, but value is %s" % self.write_tar)
            self.log.debug("type of self.write_tar is %s" % type(self.write_tar))

The output when using --scm-option write_tar=False then looks like this:

DEBUG: in scmWorker.prepare_sources(): self.write_tar value is False
DEBUG: in scmWorker.prepare_sources(): type of self.write_tar is <type 'str'>
DEBUG: self.write_tar should be True here, but value is False
DEBUG: type of self.write_tar is <type 'str'>
DEBUG: Writing /tmp/tmp_je5wI.mock-scm.hallo/hallo/hallo-1.0.tar.gz...

because any non-empty string is True in boolean evaluation.

It works correctly when used in config file:
config_opts['scm_opts']['write_tar'] = False
In that case the output is
DEBUG: in scmWorker.prepare_sources(): self.write_tar value is False
DEBUG: in scmWorker.prepare_sources(): type of self.write_tar is <type 'bool'>
DEBUG: Prepared sources for building src.rpm

Comment 1 Marko Myllynen 2012-06-08 09:51:58 UTC
Created attachment 590391 [details]
[PATCH] Fix write_tar check in scm.py

Good catch - the attached patch should fix this.

Comment 2 Clark Williams 2012-06-09 15:41:35 UTC
Applied for 1.1.23 build

Comment 3 Marko Myllynen 2012-06-11 08:37:31 UTC
Thanks, Clark.

Stephan, FWIW, it could be noted that using the repo/.write_tar "magic" file to initiate tar ball creation for selected packages might often be more feasible method than passing lenghty command line options around.