#388 recommend %autosetup over %setup
Closed: Fixed None Opened 8 years ago by sundaram.

That only works for simple packages. In real-world packages, we have patches which need different -p flags, some even need a pushd/popd into some subdirectory. We also have patches that have to be applied conditionally based on some condition (e.g.: use the new API on Fedora ≥ n, the old API otherwise). A simplistic "apply all patches" macro just doesn't cut it.

In many packages, a simplistic macro is all that is needed and there is no reason not to recommend it. Noone claims that it will work for every scenario and a outright replacement is not possible nor suggested

FPC meeting minutes wrote:

ACTION: abadger1999 to CC panu and ask whether we need to add buildrequires if -S VCS is used.

Yes, manual buildrequires are needed with -S VCS in the current macro-only implementation - as geppetto noted, a simple macro in %prep cannot add buildrequires automatically, it'd need deeper integration with rpm. Which will likely happen at some point, but for the time being the macro-only implementation means that %autosetup could trivially be made available to older versions, RHEL-6 at least.

The other angle to this is that the explicit -S VCS should probably be considered a special case to be used only when the package actually relies on that specific VCS - ie fails to build correctly (incompatible patch format or whatever) if some other VCS is used. Other than that, I think the choice of VCS should be a personal, not package level choice: if I need to bisect a problem in a package's patches, I personally would want to use git for the job regardless of what VCS the package maintainer prefers. For "production builds" the used VCS is not interesting, assuming patch application produces identical results.

Advertising %autosetup existence in the guidelines would certainly be a good thing, lots of people simply are not aware of it at all.


As an alternative, %autosetup exists in current versions of Fedora (RPM 4.11+) and (in addition to the normal %setup tasks) will apply all defined Patch# items in the spec automatically. It is also capable of handling VCS formatted patch files, but this will require additional BuildRequires, and assumes that all patch files in the spec are formatted for that single VCS type. For this reason, we do not recommend that you specify a VCS with %autosetup. For more details on proper use of %autosetup, see http://www.rpm.org/wiki/PackagerDocs/Autosetup.

action spot's mini-draft approved (+1:7, 0:1, -1:0)

I'm trying to get some of these old tickets written up and for the life of me I can't figure out where this new section is supposed to go. Does anyone remember if we even discussed that?

Never mind; I added the text (with a very slight rewording) to a new %autosetup subsection under Macros (https://fedoraproject.org/wiki/Packaging:Guidelines#.25autosetup).

Announcement text:

Mention of the %autosetup macro has been added; its use is now permitted in Fedora packages.

Login to comment on this ticket.