rpm - RedHat Package Manager

rpm is the package format used on RedHat Enterprise (RHEL), Fedora, CentOS, and a number of other Linux distributions.

You may be familiar with tools such as dnf and yum for installing packages from repositories. The package files that these tools install are rpms.

Supported Uses in FPM

fpm supports input and output for rpms. This means you can read an rpm and convert it to a different output type (such as a dir or deb). It also means you can write an rpm.

Arguments when used as input type

For the sample command reading an rpm as input and outputting a debian package:

fpm -s rpm -t deb file.rpm

The the argument is used as a file and read as an rpm.

Sample Usage

Create a package with no files but having dependencies:

% fpm -s empty -t rpm -n example --depends nginx
Created package {:path=>"example-1.0-1.x86_64.rpm"}

We can now inspect the package with rpm’s tools if you wish:

% rpm -qp example-1.0-1.x86_64.rpm -i
Name        : example
Version     : 1.0
Release     : 1
Architecture: x86_64
Install Date: (not installed)
Group       : default
Size        : 0
License     : unknown
Signature   : (none)
Source RPM  : example-1.0-1.src.rpm
Build Date  : Wed 20 Oct 2021 09:43:25 PM PDT
Build Host  : snickerdoodle.localdomain
Relocations : /
Packager    : <jls@snickerdoodle>
Vendor      : none
URL         : http://example.com/no-uri-given
Summary     : no description given
Description :
no description given

Fun Examples

Changing an existing RPM

fpm supports rpm as both an input and output type (-s and -t flags), so you can use this to modify an existing rpm.

For example, let’s create an rpm to use for our example:

% fpm -s empty -t rpm -n example
Created package {:path=>"example-1.0-1.x86_64.rpm"}

Lets say we made a mistake and want to rename the package:

% fpm -s rpm -t rpm -n newname example-1.0-1.x86_64.rpm
Created package {:path=>"newname-1.0-1.x86_64.rpm"}

And maybe the architecture is wrong. fpm defaulted to x86_64 (what fpm calls “native”), and we really want what rpm calls “noarch”:

% fpm -s rpm -t rpm -a noarch newname-1.0-1.x86_64.rpm
Created package {:path=>"newname-1.0-1.noarch.rpm"}

RPM-specific command line flags

  • --rpm-attr ATTRFILE
    • Set the attribute for a file (%attr), e.g. –rpm-attr 750,user1,group1:/some/file
  • --[no-]rpm-auto-add-directories
    • Auto add directories not part of filesystem
  • --rpm-auto-add-exclude-directories DIRECTORIES
    • Additional directories ignored by ‘–rpm-auto-add-directories’ flag
  • --[no-]rpm-autoprov
    • Enable RPM’s AutoProv option
  • --[no-]rpm-autoreq
    • Enable RPM’s AutoReq option
  • --[no-]rpm-autoreqprov
    • Enable RPM’s AutoReqProv option
  • --rpm-changelog FILEPATH
    • Add changelog from FILEPATH contents
  • --rpm-compression none|xz|xzmt|gzip|bzip2
    • Select a compression method. gzip works on the most platforms.
  • --rpm-compression-level [0-9]
    • Select a compression level. 0 is store-only. 9 is max compression.
  • --rpm-defattrdir ATTR
    • Set the default dir mode (%defattr).
  • --rpm-defattrfile ATTR
    • Set the default file mode (%defattr).
  • --rpm-digest md5|sha1|sha256|sha384|sha512
    • Select a digest algorithm. md5 works on the most platforms.
  • --rpm-dist DIST-TAG
    • Set the rpm distribution.
  • --rpm-filter-from-provides REGEX
    • Set %filter_from_provides to the supplied REGEX.
  • --rpm-filter-from-requires REGEX
    • Set %filter_from_requires to the supplied REGEX.
  • --rpm-group GROUP
    • Set the group to GROUP in the %files section. Overrides the group when used with use-file-permissions setting.
  • --[no-]rpm-ignore-iteration-in-dependencies
    • For ‘=’ (equal) dependencies, allow iterations on the specified version. Default is to be specific. This option allows the same version of a package but any iteration is permitted
  • --rpm-init FILEPATH
    • Add FILEPATH as an init script
  • --[no-]rpm-macro-expansion
  • --rpm-os OS
    • The operating system to target this rpm for. You want to set this to ‘linux’ if you are using fpm on OS X, for example
  • --rpm-posttrans FILE
    • posttrans script
  • --rpm-pretrans FILE
    • pretrans script
  • --rpm-rpmbuild-define DEFINITION
    • Pass a –define argument to rpmbuild.
  • --[no-]rpm-sign
    • Pass –sign to rpmbuild
  • --rpm-summary SUMMARY
    • Set the RPM summary. Overrides the first line on the description if set
  • --rpm-tag TAG
    • Adds a custom tag in the spec file as is. Example: –rpm-tag ‘Requires(post): /usr/sbin/alternatives’
  • --rpm-trigger-after-install '[OPT]PACKAGE: FILEPATH'
    • Adds a rpm trigger script located in FILEPATH, having ‘OPT’ options and linking to ‘PACKAGE’. PACKAGE can be a comma seperated list of packages. See: http://rpm.org/api/4.4.2.2/triggers.html
  • --rpm-trigger-after-target-uninstall '[OPT]PACKAGE: FILEPATH'
    • Adds a rpm trigger script located in FILEPATH, having ‘OPT’ options and linking to ‘PACKAGE’. PACKAGE can be a comma seperated list of packages. See: http://rpm.org/api/4.4.2.2/triggers.html
  • --rpm-trigger-before-install '[OPT]PACKAGE: FILEPATH'
    • Adds a rpm trigger script located in FILEPATH, having ‘OPT’ options and linking to ‘PACKAGE’. PACKAGE can be a comma seperated list of packages. See: http://rpm.org/api/4.4.2.2/triggers.html
  • --rpm-trigger-before-uninstall '[OPT]PACKAGE: FILEPATH'
    • Adds a rpm trigger script located in FILEPATH, having ‘OPT’ options and linking to ‘PACKAGE’. PACKAGE can be a comma seperated list of packages. See: http://rpm.org/api/4.4.2.2/triggers.html
  • --[no-]rpm-use-file-permissions
    • Use existing file permissions when defining ownership and modes.
  • --rpm-user USER
    • Set the user to USER in the %files section. Overrides the user when used with use-file-permissions setting.
  • --[no-]rpm-verbatim-gem-dependencies
    • When converting from a gem, leave the old (fpm 0.4.x) style dependency names. This flag will use the old ‘rubygem-foo’ names in rpm requires instead of the redhat style rubygem(foo).
  • --rpm-verifyscript FILE
    • a script to be run on verification