Bug 828677 - mock command line option --scm-option write_tar=False is ignored
Summary: mock command line option --scm-option write_tar=False is ignored
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Clark Williams
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-05 07:54 UTC by Stephan Dühr
Modified: 2013-02-22 22:01 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-02-22 22:01:16 UTC
Type: Bug
Embargoed:


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

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.


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