Skip to content
RPM and autospec

RPM and autospec

openmamba Linux packages are RPM packages, built from a spec file that says where to get the sources, how to build them and which files go in each package. autospec is the tool openmamba uses to work on spec files: it creates them from a source archive or a Git repository, updates them to new versions, downloads the sources, builds with rpmbuild, works out the build dependencies, checks the packages and uploads them to the repositories.

This page explains how to set up your machine and use autospec by hand from the command line. The automatic autodist queues use the same commands.

Setting up the machine

Install the tools

# dnf install rpm-build autospec

Join the packager group

The rpm working directory, /usr/src/RPM, belongs to the packager group. Add your user to the group and log in again:

# usermod -aG packager <user>

Set your name

Create the file ~/.autospec with the name and address that will appear in the Packager: field and in the changelog of your packages:

packager_fullname="Jane Doe"
packager_email="jane.doe@example.org"

Check that autospec reads them:

$ autospec --eval packager_fullname

The working directory

autospec and rpmbuild work in the %_topdir directory, which on openmamba is /usr/src/RPM:

DirectoryContent
SPECS/The spec files, <package>.spec
SOURCES/Source archives, patches and other files referenced by the spec
BUILD/Extracted and built sources, one directory per package
RPMS/<arch>/The binary packages produced
SRPMS/The source packages (.src.rpm) produced

To use another directory, redefine %_topdir in ~/.rpmmacros: autospec takes its paths from rpm.

autospec configuration

autospec reads, in order:

  1. /etc/autospec.conf and /etc/autospec.d/*.conf, the system configuration: distribution, repositories, allowed groups and licenses, spec formatting rules;
  2. ~/.autospec and ~/.autospec.d/*.conf, the personal configuration, which overrides the system one;
  3. the file given with -C <file>, instead of the personal one.

autospec --eval <variable> prints the value of a variable.

Repositories are defined in /etc/autospec.d/01-repositories.conf as numbered arrays: index 0 is base, from which published source packages are downloaded; index 1, contrib, is the devel-contrib repository where contributors upload their packages. Uploading needs credentials, issued by the administrators: they go in ~/.autospec, which must not be readable by other users.

ftp_rw_user[1]="<user>"
ftp_rw_passwd[1]="<password>"
$ chmod 600 ~/.autospec

The openmamba spec file

An openmamba spec file always has the same field order, with values aligned at the sixteenth column:

Name:          foo
Version:       1.2.3
Release:       1mamba
Summary:       Short description of foo
Group:         Applications/System
Vendor:        openmamba
Distribution:  openmamba
Packager:      Jane Doe <jane.doe@example.org>
URL:           https://foo.example.org/
Source:        https://github.com/example/foo.git/v%{version}/foo-%{version}.tar.bz2
License:       MIT
## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel
## AUTOBUILDREQ-END
BuildRequires: cmake

%description
Foo is a tool that does something useful.

%prep
%autosetup

%build
%cmake

%cmake_build

%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%cmake_install

%files
%defattr(-,root,root)
%{_bindir}/foo
%{_mandir}/man1/foo.1*
%doc LICENSE

%changelog
* Thu Nov 26 2026 Jane Doe <jane.doe@example.org> 1.2.3-1mamba
- package created

The main rules:

  • Release has the mamba suffix (1mamba, 2mamba…) and goes back to 1mamba with every new version.
  • Group and License must be entries of the lists /etc/autospec.d/02-specfile-rpm-groups.conf and /etc/autospec.d/02-specfile-approved-licenses.conf; licenses use the short SPDX name.
  • URL is the project home page, without redirects.
  • BuildRequires: the block between AUTOBUILDREQ-BEGIN and AUTOBUILDREQ-END is written by autospec after the build and must not be edited by hand. Dependencies autospec cannot detect (cmake, python3, …) go right after AUTOBUILDREQ-END.
  • Sources from Git: Source: in the form <repository>.git/<ref>/<name>-<version>.tar.bz2, with the ref always derived from a macro (v%{version}, %{version}): autospec clones the repository at that tag and creates the archive.
  • Patches: files in SOURCES/ named <package>-<version>-<description>.patch, declared with Patch0:, Patch1:… and applied with %patch 0 -p1.
  • usr-merge: binaries always go in %{_bindir} and libraries in %{_libdir}.
  • Every %files section starts with %defattr(-,root,root); shared libraries are listed with a glob (%{_libdir}/libfoo.so.*), man pages without the compression extension (foo.1*).
  • No %post -p /sbin/ldconfig is needed: ldconfig runs by itself when libraries are installed.
  • Translations use %find_lang %{name} and %files -f %{name}.lang.

The specs of existing packages, on src.openmamba.org/rpms, are the best reference for the style.

Creating a new package

autospec -s creates a spec file from a source archive, which it downloads to SOURCES/:

$ autospec -s https://example.org/foo/foo-1.2.3.tar.gz -o foo.spec

or from a Git repository, with the tag or branch to use:

$ autospec -s https://github.com/fastfetch-cli/fastfetch.git \
    --git-branch="2.59.0" -o fastfetch.spec

-t picks the spec file template (the full list is in /usr/share/autospec/templates/):

TemplateFor
standardApplications (default)
libraryLibraries, with the lib<name> and lib<name>-devel packages
standard-daemonDaemons and system services
python, python-setuptoolsPython modules
perl, perl-buildPerl modules
gnome, kde5, kf6GNOME and KDE applications and libraries
ghcHaskell packages
ocaml-libsOCaml libraries
webWeb applications

The new spec has placeholders (... package summary, ... package description) to fill in by hand, then it is built as described below.

Before creating a package check that it doesn’t already exist, maybe under another name or archived: https://api.openmamba.org/search?q=<name> searches all repositories, and src.openmamba.org keeps the history of removed packages.

autospec actions

On an existing package you work with autospec -u <package> -a<actions>: actions are numbers, separated by commas or given as ranges (-a3,4, -a5:6, -a1,4-8), and always run in order.

ActionWhat it does
0Shows the versions of the package available in the repositories
1Downloads the source package from the repository and installs it: spec in SPECS/, sources in SOURCES/
2Checks whether a newer version is available upstream
3Downloads the sources of the new version
4Updates the spec: version, release, changelog, syntax checks
5Builds the binary and source packages (the whole build, not just %prep)
6Works out the build dependencies; with -b rewrites the AUTOBUILDREQ block
7Simulates the installation of the packages produced
8Quality and security checks on the packages
9Computes the md5/sha1 hashes
10Uploads the packages to the repository and removes the previous versions
11Installs the packages produced

The most used options:

OptionEffect
--server <n or name>Repository for download and upload (--server-download, --server-upload for just one of them)
--changelog "text"Text of the changelog entry added by action 4
-R, --rebuildAction 4: only increments the release, for a rebuild
-bAction 6: updates the AUTOBUILDREQ block
-p, --noprepAction 5: skips %prep and resumes from the sources already extracted in BUILD/
--list-checkAction 5: lists the files installed but missing from %files
--force-buildRebuilds even if packages of this version and release already exist
--force-downloadDownloads the sources again even if they are already in SOURCES/
--forceTries to go on despite errors; implies --force-download
--nosrpm, --norpmBuilds or uploads only the binary packages, or only the source one
-d name=valueDefines an rpm macro for the build
-A <arch>Forces the architecture

Recipes

Building a package

$ autospec -u foo -a5,6 -b

builds the spec SPECS/foo.spec and updates its build dependencies. If the last build succeeded and the spec hasn’t changed version or release, autospec doesn’t build again: after changing the spec use --force-build.

If the build fails in %install or %files, after the fix you can restart without extracting and compiling everything again:

$ autospec -u foo -a5,6 -b --noprep --force-build

To see the installed files missing from %files:

$ autospec -u foo -a5 --list-check

Exploring the sources or testing patches

$ rpmbuild -bp /usr/src/RPM/SPECS/foo.spec --nodeps

runs only %prep: it extracts the sources in BUILD/ and applies the patches. That’s the right place to study the code and prepare new patches, with diff -u between the original and the modified files. Beware: -bp extracts from scratch and deletes a build already done in that directory.

Rebuilding a published package

$ autospec -u foo -a1 --server-download 0
$ autospec -u foo -a4 --rebuild --changelog "rebuilt with libbar 2.0"
$ autospec -u foo -a5,6 -b

Action 1 downloads the spec published in base (repository 0) and overwrites the one in SPECS/: it’s the right way to start from the latest version instead of an old local copy. If you have already edited the spec by hand, skip action 1.

Updating to a new version

$ autospec -u foo -a2
$ autospec -u foo -a3,4 1.3.0 --changelog "update to 1.3.0"
$ autospec -u foo -a5,6 -b

Action 2 tells whether a new version is available upstream; 3,4 download the sources of the given version and update the spec, with release 1mamba and a changelog entry. Patches that no longer apply must be fixed or removed before building.

Checking, uploading, installing

$ autospec -u foo -a7,8          # installation test and checks
$ autospec -u foo -a10           # upload to the default repository
$ sudo rpm -Uvh /usr/src/RPM/RPMS/x86_64/foo-1.3.0-1mamba.x86_64.rpm

The default upload repository is ftp_rw_server_num_default, that is devel-contrib in the system configuration. Uploaded packages show up in the API and in the web interface after the repository metadata is refreshed.

Other commands

# extract files from a source package without installing it
$ autospec -x foo-1.3.0-1mamba.src.rpm -F '*.spec' --destdir=/tmp/foo

# verbose output, to see what autospec is doing
$ autospec -D -u foo -a4

# log to file, in /var/tmp/autospec
$ autospec -L -u foo -a5

autospec -u -h, autospec -s -h and autospec -x -h show all the options of each mode.

Last updated on