The %autorelease
Macro¶
The contents of the Release
field¶
Fedora’s Versioning Guidelines define the different elements of which a release field consists. They are as follows:
<pkgrel>%{?dist}[.<minorbump>]
Square brackets indicate an optional item.
The %autorelease
macro accepts these parameters to allow packagers to specify
the different portions of the release field:
-b <baserelease>
: Allows specifying a custom base release number (the default is 1).For instance, this can be used to keep release numbers on older Fedora releases way lower than on newer ones for the same package version.
-n
: Don’t render the dist tag, e.g. for use in macros, if the dist tag is added later.
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.
One-off bumping release numbers¶
You can bump the release to a higher value in a commit by adding a magic comment like this to the commit log (one its own line):
[bump release: <number>]
This would ensure that the release number is at minimum the specified number (if it were higher anyway, it would not change anything).
One use case for this would be, if a sub-package is split out into its own component and its release
number sequence should not be reset. E.g. if the last release number while it was still a
sub-package was 4, add [bump release: 5]
to the commit log to let the sequence continue
seamlessly.
You don’t have to undo this later, when the version changes, the release will be reset to 1 (or the
value specified by %autorelease -b …
).
Examples¶
Example: 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
Example: 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
Traditional versioning with part of the upstream version information in the release field¶
Additional parameters are available to support an older form of package versioning. This form is recommended for packages with complex versioning requirements when support for RHEL7 and other systems with old rpm versions is required. See Traditional Versioning in the Packaging Guidelines for details.
The release field is extended:
<pkgrel>[.<extraver>][.<snapinfo>]%{?dist}[.<minorbump>]
Square brackets indicate an optional item.
The %autorelease
macro accepts these parameters to allow packagers to specify
those added fields:
-p
: Designates a pre-release, i.e.pkgrel
will be prefixed with0.
.-e <extraver>
: Allows specifying theextraver
portion of the release.-s <snapinfo>
: Allows specifying thesnapinfo
portion of the release.
In the modern versioning, those fields are embedded in the package Version instead.
Example: 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
Example: 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
Example: 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
Example: 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