Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1160765 - empty and single values for rpm macros in mock cfg file and cmd option
Summary: empty and single values for rpm macros in mock cfg file and cmd option
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-05 15:03 UTC by Mikhail Campos
Modified: 2015-01-06 02:06 UTC (History)
6 users (show)

Fixed In Version: mock-1.2.3-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-12-12 04:07:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
fix for macros on mock cfg (1.59 KB, application/mbox)
2014-11-05 15:03 UTC, Mikhail Campos
no flags Details
fix fot --define command line option (731 bytes, patch)
2014-11-05 15:05 UTC, Mikhail Campos
no flags Details | Diff

Description Mikhail Campos 2014-11-05 15:03:39 UTC
Created attachment 954078 [details]
fix for macros on mock cfg

Description of problem:
Whenever we set config_opts['macros'] in cfg improperly, mock builds without errors and warning messages about invalid arguments. In particularly, this consist of passing empty/one-word macros to mock. But using [-D] command line option we have at least error message if we try to write one-word macros (which is also invalid). 

Version-Release number of selected component (if applicable):
1.2.0-1

How reproducible:
Write it to *.cfg file:

1. Empty macros name:
    config_opts['macros'][''] = '%this_macros_name this_is_macros_body!'
2. Empty value (single macros name):  
    config_opts['macros']['%macros_name_only'] = ''
3. Empty all:  
    config_opts['macros'][''] = ''

Additional info:
Actually, this works and successfully added to .rpmmacros in chroot. Cons are:

1. less readable *.cfg
2. if'll try to get self.config['macros']['name'], we can get result in empty string

Proposed patch:
Fixed with fix-config-macros.patch which disables invalid args.

Comment 1 Mikhail Campos 2014-11-05 15:05:33 UTC
Created attachment 954079 [details]
fix fot --define command line option

Additional patch fix-cmd-macros.patch fixes one-word macros with whitespace chars: 
* -D "%macros_name" -> error
* -D " %macros_name      " -> no error

Comment 2 Miroslav Suchý 2014-11-07 10:56:17 UTC
Commited as 79d380a and 9a86fdb.
Thanks for contribution.

Comment 3 Miroslav Suchý 2014-11-07 11:00:08 UTC
For the record I changed in your patch:
  k = '%%%s' % k
to:
  k = '{0}'.format(k)
for better readability.

And one fix to previos comment: Those commits are:
79d380a and 97abcbc

Comment 4 Michael Simacek 2014-11-11 15:21:03 UTC
FYI, the config generated by fedpkg mock-config contains such item (the %distribution):

# Auto-generated by the Koji build system

config_opts['chroothome'] = '/builddir'
config_opts['use_host_resolv'] = False
config_opts['basedir'] = '/var/lib/mock'
config_opts['rpmbuild_timeout'] = 86400
config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\n\n# repos\n\n[build]\nname=build\nbaseurl=http://kojipkgs.fedoraproject.org//repos/f22-build/432475/x86_64\n'
config_opts['chroot_setup_cmd'] = 'groupinstall build'
config_opts['target_arch'] = 'x86_64'
config_opts['root'] = 'rawhide-x86_64'

config_opts['plugin_conf']['root_cache_enable'] = False
config_opts['plugin_conf']['yum_cache_enable'] = False
config_opts['plugin_conf']['ccache_enable'] = False

config_opts['macros']['%_host'] = 'x86_64-koji-linux-gnu'
config_opts['macros']['%_host_cpu'] = 'x86_64'
config_opts['macros']['%vendor'] = 'Koji'
config_opts['macros']['%distribution'] = None
config_opts['macros']['%_topdir'] = '/builddir/build'
config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
config_opts['macros']['%packager'] = 'Koji'

Comment 5 Mikhail Campos 2014-11-11 16:11:00 UTC
If it really needs, it's still possible to write something like this:

config_opts['macros']['%distribution'] = '%{nil}'

Comment 6 Michael Simacek 2014-11-11 16:32:36 UTC
The problem is not whether they need it. It's that the config is returned by koji. And we cannot easily change Koji. I assume the reason why you implemented this is because it's easy to make such mistake when entering macro defines on commandline. But in the config this doesn't seem to be possible to happen by accident. One doesn't simply type None by accident. Therefore I'd suggest to apply this check only to arguments passed on the commandline.

Comment 7 Fedora Update System 2014-11-16 17:37:14 UTC
mock-1.2.1-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/mock-1.2.1-1.fc21

Comment 8 Fedora Update System 2014-11-16 17:38:38 UTC
mock-1.2.1-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.2.1-1.fc20

Comment 9 Fedora Update System 2014-11-16 17:39:29 UTC
mock-1.2.1-1.el7 has been submitted as an update for Fedora EPEL 7.
https://admin.fedoraproject.org/updates/mock-1.2.1-1.el7

Comment 10 Fedora Update System 2014-11-16 17:40:28 UTC
mock-1.2.1-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.2.1-1.el6

Comment 11 Fedora Update System 2014-11-17 06:29:33 UTC
Package mock-1.2.1-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing mock-1.2.1-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-15217/mock-1.2.1-1.fc20
then log in and leave karma (feedback).

Comment 12 Fedora Update System 2014-12-04 12:06:52 UTC
mock-1.2.3-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/mock-1.2.3-1.fc21

Comment 13 Fedora Update System 2014-12-04 12:10:21 UTC
mock-1.2.3-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.2.3-1.fc20

Comment 14 Fedora Update System 2014-12-04 12:11:19 UTC
mock-1.2.3-1.el7 has been submitted as an update for Fedora EPEL 7.
https://admin.fedoraproject.org/updates/mock-1.2.3-1.el7

Comment 15 Fedora Update System 2014-12-12 04:07:47 UTC
mock-1.2.3-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 16 Fedora Update System 2014-12-17 04:42:51 UTC
mock-1.2.3-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 17 Fedora Update System 2015-01-06 02:06:35 UTC
mock-1.2.3-1.el7 has been pushed to the Fedora EPEL 7 stable repository.  If problems still persist, please make note of it in this bug report.


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