Bug 828677 - mock command line option --scm-option write_tar=False is ignored
mock command line option --scm-option write_tar=False is ignored
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
rawhide
Unspecified Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Clark Williams
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-05 03:54 EDT by Stephan Dühr
Modified: 2013-02-22 17:01 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-22 17:01:16 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
[PATCH] Fix write_tar check in scm.py (918 bytes, patch)
2012-06-08 05:51 EDT, Marko Myllynen
no flags Details | Diff

  None (edit)
Description Stephan Dühr 2012-06-05 03:54:46 EDT
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 05:51:58 EDT
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 11:41:35 EDT
Applied for 1.1.23 build
Comment 3 Marko Myllynen 2012-06-11 04:37:31 EDT
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.

Note You need to log in before you can comment on or make changes to this bug.