Building from a spec file
The default path, which resolves BuildRequires, fetches remote sources, and publishes every subpackage the spec defines.
This is the path taken when the sources directory holds one or more *.spec files and no .tito
directory. It needs no extra environment variables beyond the mounts from the
quickstart.
Order of operations
For each spec file the entrypoint:
- Copies the non-spec files from the sources directory into the build tree's
%{_sourcedir}. - Enables the repositories requested for this run (see Enabling COPR and custom repositories).
- Installs the spec's
BuildRequires. On adnfsystem this isdnf builddep; onzypperit reads them withrpmspec -q --buildrequiresand installs them in a single transaction. - Fetches remote sources with
spectool --sourcedir --get-files. - Builds the SRPM with
rpmbuild -bs, which fails fast on a bad spec before the slow compile. - Unless
SRPM_ONLYis set, builds the binary RPMs withrpmbuild -ba. - Installs every artifact whose filename begins with one of the spec's
%{name}-%{version}-%{release}prefixes into the output directory.
Steps 3 and 4 run for every spec file before any build starts, so all build dependencies and all remote sources are present before the first compile.
Multiple spec files
Drop several *.spec files in the sources directory and each is built in turn. This is how a
package split into a -base spec and a -devel spec, or a set of related packages, is built in one
run. The artifacts of every spec land in the same output directory.
Subpackages
A spec can define several packages from one build, for example demo, demo-libs, and demo-devel.
The entrypoint reads the full package list from the spec with
rpm --specfile ... --queryformat '%{name}-%{version}-%{release}\n' and matches each prefix against
the built SRPMs and binary RPMs, so every subpackage is published rather than only the main package.
Remote and local sources
spectool downloads anything declared as a full URL:
Source0: https://ftp.gnu.org/gnu/hello/hello-%{version}.tar.gz
A source declared as a bare filename is expected to sit next to the spec in the sources directory.
The copy step moves it into %{_sourcedir} unchanged.
What gets copied
Everything in the sources directory except *.spec files, the output directory, and the run's own
configuration inputs (.copr*, .repos*). Hidden files are not copied by the copy glob. The
copied files are then owned by the build user inside the container.
Restricting to an SRPM
Set SRPM_ONLY to stop after step 5. The run produces the .src.rpm and skips the compile, which is
useful for a fast spec check or the first half of a
strict two-stage build.
podman run --rm -it \
--volume "${PWD}/sources:/sources:z" \
--volume "${PWD}/output:/output:z" \
--env OUTPUT_USER="$(id -u)" \
--env SRPM_ONLY=1 \
quay.io/abn/rpmbuilder:fedora-latest
Next
- Rebuilding from an SRPM compiles an existing
.src.rpmin a clean container. - Building for another architecture changes the target from the image default.
Connections
Local graphLinked from
- What happened“Building from a specfile”
- Next“Building from a spec file”
- How coprctl uses rpmbuilder“spec build”
- Next“Building from a spec file”