Using the %autorelease Macro

Fedora’s Versioning Guidelines define the different elements of which a release field consists. They are as follows:

<pkgrel>[.<extraver>][.<snapinfo>]%{?dist}[.<minorbump>]

Each element in square brackets indicates an optional item.

The %autorelease macro accepts these parameters to allow packagers to specify the different portions of the release field:

  • -p <prerelease>: Designates a pre-release, i.e. pkgrel will be prefixed with 0..

  • -e <extraver>: Allows specifying the extraver portion of the release.

  • -s <snapinfo>: Allows specifying the snapinfo portion of the release.

  • -b <baserelease>: Allows specifying a custom base release number (i.e. other than 1).

Important

To date, the %autorelease parameters are ignored in the headers of automatically generated changelog entries.

Note

In the prototype version the macro was named %autorel. To make its purpose more obvious, it is %autorelease now.

Examples

The Simple Case

Summary:    test-autorelease
Name:       test-autorelease
Version:    1.0
Release:    %autorelease
License:    MIT

%description
An example package testing the %%autorelease macro. This package is for
testing the normal release cadence, bumping in the left-most, most significant
place of the release field.

Will generate the following NEVR:

test-autorelease-1.0-1.fc34.x86_64

The Custom Base Release Case

Summary:    test-autorelease-baserelease
Name:       test-autorelease-baserelease
Version:    1.0
Release:    %autorelease -b 100
License:    MIT

%description
An example package for the %%autorelease macro.

This package demonstrates using a base release number which lets release numbers start at other
values than 1 (the default).

Will generate the following NEVR:

test-autorelease-baserelease-1.0-100.fc34.x86_64

The Pre-Release Case

Summary:    test-autorelease-prerelease
Name:       test-autorelease-prerelease
Version:    1.0
Release:    %autorelease -p -e pre1
License:    MIT

%description
An example package testing the %%autorelease macro. This package is for
testing a prerelease with an <extraver> part, when upstream uses unsortable
versions like "1.0pre1".

Will generate the following NEVR:

test-autorelease-prerelease-1.0-0.1.pre1.fc34.x86_64

The Extraver Case

Summary:    test-autorelease-extraver
Name:       test-autorelease-extraver
Version:    1.0
Release:    %autorelease -e pre1
License:    MIT

%description
An example package testing the %%autorelease macro. This package is for
testing with an <extraver> part, when upstream uses unsortable versions like
"1.0pre1".

Will generate the following NEVR:

test-autorelease-extraver-1.0-1.pre1.fc34.x86_64

The Snapshot Case

Summary:    test-autorelease-snapshot
Name:       test-autorelease-snapshot
Version:    1.0
Release:    %autorelease -s 20200317git1234abcd
License:    MIT

%description
An example package testing the %%autorelease macro. This package is for
testing with a <snapinfo> part, for a snapshot between versions from an
upstream repository.

Will generate the following NEVR:

test-autorelease-snapshot-1.0-1.20200317git1234abcd.fc34.x86_64

The Snapshot and Extraver case

Summary:    test-autorelease-extraver-snapshot
Name:       test-autorelease-extraver-snapshot
Version:    1.0
Release:    %autorelease -e pre1 -s 20200317git1234abcd
License:    MIT

%description
An example package testing the %%autorelease macro. This package is for
testing with <extraver> and <snapinfo> parts, when upstream uses unsortable
versions like "1.0pre1" and we package a snapshot after it.

Will generate the following NEVR:

test-autorelease-extraver-snapshot-1.0-1.pre1.20200317git1234abcd.fc34.x86_64