Created attachment 1002563 [details] Correct failure of --scm-enable to build binary RPMs from SCM Description of problem: mock --scm-enable --scm-option branch=... --scm-option package=... no longer works produces a complete RPM. This previously worked in 1.1.41. Version-Release number of selected component (if applicable): 1.2.7(+) (tip of master in git How reproducible: use mock to attempt to build from a SCM repository Steps to Reproduce: 1.mock -r ues-5-x86_64 --scm-enable --scm-option branch=UES_201503 --scm-option package=Certs (my apologies for our branch and package being listed, this is a direct cut/paste from my xterms.) 2. 3. Actual results: zonker-> mock -r ues-5-x86_64 --scm-enable --scm-option branch=UES_201503 --scm-option package=Certs INFO: mock.py version 1.2.5.mc0 starting (python version = 2.6.6)... Start: init plugins INFO: selinux enabled Finish: init plugins Start: run INFO: Start(/tmp/tmpeDvFdr.mock-scm.Certs/Certs/Spec.spec) Config(ues-5-x86_64) Start: clean chroot Finish: clean chroot Start: chroot init INFO: calling preinit hooks INFO: enabled root cache Start: unpacking root cache Finish: unpacking root cache Mock Version: 1.2.5.mc0 INFO: Mock Version: 1.2.5.mc0 Start: yum update Not using downloaded repomd.xml because it is older than what we have: Current : Sat Mar 14 22:45:14 2015 Downloaded: Tue Feb 10 09:11:47 2015 Finish: yum update Finish: chroot init Start: buildsrpm Start: rpmbuild -bs Building target platforms: x86_64 Building for target x86_64 Wrote: /builddir/build/SRPMS/UES-Certificate-Generation-1.0.0-1.src.rpm Finish: rpmbuild -bs Finish: buildsrpm INFO: Done(/tmp/tmpeDvFdr.mock-scm.Certs/Certs/Spec.spec) Config(ues-5-x86_64) 0 minutes 6 seconds INFO: Results and/or logs in: /var/local/repos/ues-5-x86_64 INFO: Cleaning up build root ('cleanup_on_success=True') Start: clean chroot Finish: clean chroot CRITICAL: No package specified to rebuild command. Expected results: zonker-> sudo python py/mock.py -r /etc/mock/ues-5-i386.cfg --rebuild --scm-enable --scm-option branch=UES_201503 --scm-option package=Certs INFO: mock.py version unreleased_version starting (python version = 2.6.6)... Start: init plugins INFO: selinux enabled Finish: init plugins Start: run INFO: Start(/tmp/tmpl9gLcm.mock-scm.Certs/Certs/Spec.spec) Config(ues-5-i386) Start: clean chroot Finish: clean chroot Start: chroot init INFO: calling preinit hooks INFO: enabled root cache Start: unpacking root cache Finish: unpacking root cache Mock Version: unreleased_version INFO: Mock Version: unreleased_version Start: yum update Finish: yum update Finish: chroot init Start: buildsrpm Start: rpmbuild -bs Building target platforms: i386 Building for target i386 Wrote: /builddir/build/SRPMS/UES-Certificate-Generation-1.0.0-1.src.rpm Finish: rpmbuild -bs Finish: buildsrpm INFO: Done(/tmp/tmpl9gLcm.mock-scm.Certs/Certs/Spec.spec) Config(ues-5-i386) 0 minutes 6 seconds INFO: Results and/or logs in: /var/local/repos/ues-5-i386 INFO: Cleaning up build root ('cleanup_on_success=True') Start: clean chroot Finish: clean chroot INFO: Start(/var/local/repos/ues-5-i386/UES-Certificate-Generation-1.0.0-1.src.rpm) Config(ues-5-i386) Start: chroot init INFO: calling preinit hooks INFO: enabled root cache Start: unpacking root cache Finish: unpacking root cache Start: yum update Finish: yum update Finish: chroot init Start: build phase for UES-Certificate-Generation-1.0.0-1.src.rpm Start: build setup for UES-Certificate-Generation-1.0.0-1.src.rpm Building target platforms: i386 Building for target i386 Wrote: /builddir/build/SRPMS/UES-Certificate-Generation-1.0.0-1.src.rpm Getting requirements for UES-Certificate-Generation-1.0.0-1.src --> Already installed : 1:make-3.81-3.el5.i386 No uninstalled build requires Finish: build setup for UES-Certificate-Generation-1.0.0-1.src.rpm Start: rpmbuild UES-Certificate-Generation-1.0.0-1.src.rpm Building target platforms: i386 Building for target i386 Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.19882 [...] Finish: rpmbuild UES-Certificate-Generation-1.0.0-1.src.rpm Finish: build phase for UES-Certificate-Generation-1.0.0-1.src.rpm INFO: Done(/var/local/repos/ues-5-i386/UES-Certificate-Generation-1.0.0-1.src.rpm) Config(ues-5-i386) 0 minutes 7 seconds INFO: Results and/or logs in: /var/local/repos/ues-5-i386 INFO: Cleaning up build root ('cleanup_on_success=True') Start: clean chroot Finish: clean chroot INFO: Running createrepo on binary rpms in resultdir Finish: run Additional info: One small change corrects the issue: (patch also attached.) zonker-> git diff py/mock.py diff --git a/py/mock.py b/py/mock.py index aeaca92..461cd3d 100755 --- a/py/mock.py +++ b/py/mock.py @@ -505,9 +505,9 @@ def do_buildsrpm(config_opts, commands, buildroot, options, args): clean = config_opts['clean'] def cmd(spec): - commands.buildsrpm(spec=spec, sources=options.sources, - timeout=config_opts['rpmbuild_timeout'], - follow_links=options.symlink_dereference) + return commands.buildsrpm(spec=spec, sources=options.sources, + timeout=config_opts['rpmbuild_timeout'], + follow_links=options.symlink_dereference) return rebuild_generic([options.spec], commands, buildroot, config_opts, cmd=cmd, post=None, clean=clean)
Bug analysis: in mock.py, the execution block for config.mode="rebuild", when config_opts[scm] is set, expects do_buildsrpm() to return the name of the SRPM built. In investigating do_buildsrpm() (in the same file), it is evident that the return value from commands.buildsrpm() is discarded. Having the return value from buildsrpm() discarded means that rebuild_generic, which (indirectly) calls commands.buildsrpm() returns an undefined/None value. The return of the undefined value from do_buildsrpm() results in the "srpm" having no value, and the SRPM having just been built being effectively lost. Since "srpm" is undefined, it is not added to the argument list for do_rebuild(). Needless to say, do_rebuild() complains because it wasn't given an SRPM to build. Chasing the call stack suggests (and testing confirms) making sure that the return value from commands.buildsrpm is returned from the local function cmd() inside do_buildsrpm() results in the expected behavior.
In browsing bugzilla today, I see that someone else has also encounter this problem. Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1190450
*** This bug has been marked as a duplicate of bug 1190450 ***