4

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?

Mikhail T.
  • 3,043
  • 3
  • 29
  • 46
  • 1
    [This Fedora page](https://fedoraproject.org/wiki/Autosetup_packaging_draft) says that it was added in 4.11 - I wonder if 4.8 has a buggy/preliminary version. I've never used it myself, sorry. – Aaron D. Marasco Nov 21 '16 at 13:32

1 Answers1

4

I observed the same issue on CentOS 6.7.

As mentioned above, RPM 4.8 supposedly doesn't support %autosetup; autosetup documentation 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.

Marius_Couet
  • 190
  • 7
doshea
  • 1,567
  • 1
  • 11
  • 12
  • copying `/etc/rpm` from https://centos.pkgs.org/5/epel-x86_64/epel-rpm-macros-5-7.noarch.rpm.html also solved "`fg: no job control`" due to missing `%autosetup` in a legacy `rpm` distribution – Stuart Cardall Mar 27 '18 at 14:00