问题
I have a very straightforward arrangement -- one source tarball, one patch:
Source: http://...../foo-%{version}.tar.gz
Patch: my-patch-for-foo.diff
...
%prep
%autosetup -v -n bar-%{version}
However, when I attempt to use the %autosetup
in the %prep
step, rpmbuild
attempts to patch first -- before extracting:
/bin/cat ..../SOURCES/my-patch-for-foo.diff |
/usr/bin/patch
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.8PV0PY
+ umask 022
+ cd /....
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /....
+ rm -rf bar-0.12.18
+ /bin/tar -xvvf -
+ /usr/bin/gzip -dc ..../SOURCES/foo-0.12.18.tgz
For some reason, there is no error reported by patch
-- but the extracted code ends up unpatched and my build fails later.
Using the ordinary %setup
followed by %patch0
works fine, but what's wrong with %autosetup
?
I'm on CentOS-6.8, if it matters, where RPM is of version 4.8.0. Thank you!
Update, splitting the %autosetup
into %setup
and %autopatch
does not work either -- %autopatch
does not do anything useful. Because my patches are all in default format, I'm going to use my reimplementation of %autopatch
:
%prep
%setup -n bar-%{version}
%{lua:
for i, p in ipairs(patches) do
print("%patch"..i)
end
}
Have I really found a bug, or am I doing something grotesquely wrong?
回答1:
I observed the same issue on CentOS 6.7.
As mentioned above, RPM 4.8 supposedly doesn't support %autosetup
; http://rpm.org/user_doc/autosetup.html also confirms that it's supported starting from 4.11.
However, I found that /usr/lib/rpm/macros
(installed from rpm-4.8.0-55.el6.x86_64
) does actually include a definition of the %autosetup
macro, and rpm -q --changelog rpm
shows that it was backported "recently":
* Mon Feb 08 2016 Lubos Kardos <lkardos@redhat.com> - 4.8.0-52
- Add %autosetup macros (#1265021)
Obviously that implementation seems to be broken, though.
The EPEL packaging guidelines says that "The %autosetup macro is available in all EPEL releases (via epel-rpm-macros for EPEL5 and EPEL6)" (emphasis mine), so I tried installing that package. After installing epel-rpm-macros-6-16.noarch
(instructions for adding the EPEL YUM repository if you haven't already done this), /etc/rpm/macros.zzz-epel-autosetup
contained a different definition of %apply_patch
(which is used by %autopatch
, which is used by %autosetup
). This fixed the issue - patches are now applied after the sources are extracted.
来源:https://stackoverflow.com/questions/40714213/why-does-autosetup-perform-patching-before-extracting-sources