Ticket #176 (assigned defect)

Opened 1 year ago

Last modified 1 year ago

"rpmbuild -bp --force" silently skips all %patch directives

Reported by: kjd@duda.org Assigned to: pmatilai (accepted)
Priority: minor Milestone:
Component: rpm Version: RPM Development
Keywords: Cc:

Description

In rpm 4.8.1 (and 4.7.2 and probably other versions), if you call parseSpec() with force=1 (as python/spec-py.c is inclined to do), parsePrep.c's doPatch code always returns the empty string. This is because of this line in parsePrep.c:

/* On non-build parse's, file cannot be stat'd or read. */

if (spec->force checkOwners(fn)) goto exit;

This code seems to be clearly not as intended. It should instead read:

if (!spec->force && checkOwners(fn)) goto exit;

This is really screwing up my ability to execute steps of rpmbuilding from python scripts.

Change History

08/13/10 04:41:39 changed by kjd@duda.org

  • summary changed from parsePrep.c %patch expansion fails when spec->force==1 to "rpmbuild -bp --force" silently skips all %patch directives.

Here is a great demonstration of why this is important to fix. "rpmbuild -bp --force" fails to apply any patches because of this bug! Note how the first invocation below applies no patch, but the second one does.

=============================================

% rpmbuild -bp --force pylibpcap.spec Executing(%prep): /bin/sh -e /tmp/rpm-tmp.yuBvzO + umask 022 + cd /./././././././bld/pylibpcap + LANG=C + export LANG + unset DISPLAY + cd /bld/pylibpcap + rm -rf pylibpcap-0.5.1 + /bin/tar -xf /src/pylibpcap/pylibpcap-0.5.1.tar.gz + cd pylibpcap-0.5.1 + /bin/chmod -Rf a+rX,u+w,g-w,o-w . + exit 0

=============================================

% rpmbuild -bp pylibpcap.spec Executing(%prep): /bin/sh -e /tmp/rpm-tmp.1Cj8ez + umask 022 + cd /./././././././bld/pylibpcap + LANG=C + export LANG + unset DISPLAY + cd /bld/pylibpcap + rm -rf pylibpcap-0.5.1 + /bin/tar -xf - + /usr/bin/gzip -dc /src/pylibpcap/pylibpcap-0.5.1.tar.gz + STATUS=0 + ' 0 -ne 0 ?' + cd pylibpcap-0.5.1 + /bin/chmod -Rf a+rX,u+w,g-w,o-w . + echo 'Patch #0 (skip-swig.patch):' Patch #0 (skip-swig.patch): + /usr/bin/patch -s -p0 --fuzz=0 + /bin/cat /src/pylibpcap/skip-swig.patch + exit 0

08/18/10 12:03:56 changed by pmatilai

  • owner changed from RpmTickets to pmatilai.
  • status changed from new to assigned.

There are several bugs here actually:

The python spec bindings are nothing but a query toy currently, partly because it always calls parseSpec() with force == 1 which is only really meaningful with 'rpm --specfile' queries.

The hidden and undocumented --force option to rpmbuild is broken in more than one way - if you look carefully at the output, it doesn't correctly handle sources either. It only "works" for sources because tar nowadays automatically detects compressed tarballs. And then if you look at the hidden --force definition, even the hidden documentation disagrees with what it actually does:

 { "force", '\0', POPT_ARGFLAG_DOC_HIDDEN, &rpmBTArgs.force, RPMCLI_POPT_FORCE,
        N_("ignore ExcludeArch: directives from spec file"), NULL},

So... python spec objects need to have a way to pass those extra args in, and it needs a method to call the rpm build functionality too. I think I might even have beginnings of a patch for that somewhere. And the force option/argument needs a sane definition of what it means and then actually fixing the code to do that. The --force argument to rpmbuild might just as well die as it's not useful for anything at all really.

08/18/10 12:17:54 changed by pmatilai

Oh, forgot to comment on the suggested fix: that's the way it used to be but it breaks --specfile queries (see RhBug:487855). Both the %prep and %patch need a bit of love for consistent behavior.