Skip to main content

Source RPM

Build source RPMs (.src.rpm) from your project

Anodizer can build source RPM packages (.src.rpm) using rpmbuild.

Classification

Packager — creates source RPM packages from your project. Required: not a publisher; disabled by default.

Minimal config

srpm:
  enabled: true

Full config reference

srpm:
  enabled: false                     # required; opt-in (disabled by default)
  package_name: ""                   # optional; RPM package name (default: project name)
  file_name_template: ""             # optional; output filename template
  spec_file: ""                      # optional; path to .spec template (auto-generated if omitted)
  epoch: ""                          # optional; RPM epoch
  section: ""                        # optional; RPM section
  maintainer: ""                     # optional
  vendor: ""                         # optional
  summary: ""                        # optional
  group: ""                          # optional
  description: ""                    # optional
  license: MIT                       # optional; license identifier
  license_file_name: ""              # optional; license file to include
  url: ""                            # optional; homepage URL
  packager: ""                       # optional; RPM packager field
  compression: ""                    # optional; gzip | xz | zstd | none
  docs: []                           # optional; documentation files to include
  contents: []                       # optional; additional contents
  signature:                         # optional; RPM signing config
    key_file: ""
    key_passphrase: ""               # optional; falls back to SRPM_PASSPHRASE env var
  skip: false                        # optional

Authentication

VariableDescription
SRPM_PASSPHRASEGPG passphrase for signing (or set signature.key_passphrase in config)

No authentication is required when signature is not configured.

Common gotchas

  • rpmbuild must be on PATH: install via sudo dnf install rpm-build or sudo apt-get install rpm.
  • Exactly one source archive required: the stage errors if zero or more than one source archive artifact exists. Ensure the archive stage runs first with a compatible format.
  • Signing: signature requires a GPG key on the build machine. Ensure the key is imported before releasing.

Republish / update behavior

Not applicable — this is a local packaging stage, not a publisher.

SRPM config fields

FieldTypeDefaultDescription
enabledboolfalseEnable SRPM generation
package_namestringproject nameRPM package name
file_name_templatestring{{ PackageName }}-{{ Version }}.src.rpmOutput filename (template)
spec_filestringauto-generatedPath to RPM spec file template
epochstringnoneRPM epoch
sectionstringnoneRPM section
maintainerstringpackage namePackage maintainer
vendorstringnonePackage vendor
summarystringpackage nameSummary line
groupstringnoneRPM group
descriptionstringpackage namePackage description
licensestringMITLicense identifier
license_file_namestringnoneLicense file to include
urlstring""Homepage URL
packagerstringnoneRPM packager field
compressionstringnoneCompression: gzip, xz, zstd, none
docslistnoneDocumentation files to include
contentslistnoneAdditional contents (same format as nFPM contents)
signatureobjectnoneRPM signing configuration
skipstring/boolnoneSkip this config (accepts bool or template string)

Signature config

FieldTypeDescription
key_filestringPath to GPG key file
key_passphrasestringGPG passphrase (falls back to SRPM_PASSPHRASE env var).

Prerequisites

  • rpmbuild must be installed and available on PATH
  • Exactly one source archive artifact must exist (from the archive stage with format: tar.gz or similar)

Auto-generated spec

When no spec_file is provided, Anodizer generates a minimal RPM spec with %autosetup, %build, %install, %files, and %changelog sections.

The %prep step is prefix-aware: it emits %autosetup -n {{ SourcePrefix }} to enter the source archive's top-level directory, or %autosetup -c when the archive has no prefix directory (source.prefix_template unset). This keeps the produced .src.rpm rebuildable for snapshot and prerelease versions, whose RPM Version: is sanitized but whose tarball prefix is the raw version.

Custom spec file

Provide your own .spec template for full control:

srpm:
  enabled: true
  spec_file: rpm/myapp.spec

The spec file is rendered through the template engine with additional variables:

VariableDescription
{{ PackageName }}RPM package name
{{ Source }}Source archive filename (reconciled with the RPM Version:; always matches the file in SOURCES/)
{{ SourcePrefix }}Source archive top-level directory (empty for a flat archive)
{{ Summary }}Package summary
{{ License }}License identifier
{{ URL }}Homepage URL
{{ Description }}Package description

Use %autosetup -n {{ SourcePrefix }} only when the source archive has a directory prefix (a source.prefix_template ending in /). For a flat archive (SourcePrefix empty), use %autosetup -c instead, which creates the build directory and extracts the flat sources into it.

Behavior

  • The .src.rpm extension is auto-appended if not present
  • Respects global --skip-sign — signature config is cleared when signing is skipped
  • Skippable with --skip srpm

Full example

srpm:
  enabled: true
  package_name: myapp
  summary: "A fast CLI tool"
  description: "My application does great things"
  license: Apache-2.0
  url: "https://example.com/myapp"
  vendor: "My Org"
  maintainer: "Alice <alice@example.com>"
  compression: xz
  docs:
    - README.md
    - CHANGELOG.md
  signature:
    key_file: /path/to/gpg-key.asc