The %autosetup and %setup macros
Use the %autosetup macro to unpack the source archives and apply patches automatically instead of manually specifying each patch by using the %patch directive.
%autosetup applies patches in the order they appear in the spec file. Always consider keeping sources and patches sorted by their number in spec to avoid unexpected actions. Alternatively, avoid the numbering entirely by using %patchlist or non-numbered Patch entries.You can also use the %setup macro to unpack the source archives for building RPM packages.
%autosetup macro whenever possible, instead of the %setup macro.The %autosetup macro options Copy linkLink copied!
Use the following %autosetup macro options to control its behavior. %autosetup also accepts all %setup macro options.
%autosetup macro options.For more information, see the patch(1) man page on your system.
| Macro option | Description |
|---|---|
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
The %autopatch macro options Copy linkLink copied!
The %autopatch macro applies all patches in the order stated in a spec file. Use the following %autopatch macro options to control its behavior.
%autopatch macro options.For more information, see the patch(1) man page on your system.
| Macro option | Description |
|---|---|
|
|
Use the |
|
|
Use the |
|
|
Use the |
|
|
Use the |
The %setup macro options Copy linkLink copied!
Use the following %setup macro options for controlling the unpacking of source archives.
%setup macro options.| Macro option | Description |
|---|---|
|
|
Use the |
|
|
Use the For example, you can use this option when the directory from the expanded source code archive has a different name from what is expected ( Name: cello
Source0: https://example.com/%{name}/release/hello-%{version}.tar.gz
...
%prep
%setup -n hello
|
|
|
Use the /usr/bin/mkdir -p cello-1.0
cd 'cello-1.0'
The directory is not changed after archive expansion. |
|
|
Use the rm -rf 'cello-1.0'
|
|
|
Use the /usr/bin/gzip -dc '/builddir/build/SOURCES/cello-1.0.tar.gz' | /usr/bin/tar -xvvof -
|
|
|
Use the For example, examples are provided in a separate Source0: https://example.com/%{name}/release/%{name}-%{version}.tar.gz
Source1: %{name}-%{version}-examples.tar.gz
...
%prep
%setup -b 1
|
|
|
Use the For example, the Source0: https://example.com/%{name}/release/%{name}-%{version}.tar.gz
Source1: examples.tar.gz
...
%prep
%setup -a 1
|