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 ATTRFILESet the attribute for a file (%attr), e.g. –rpm-attr 750,user1,group1:/some/file
--[no-]rpm-auto-add-directoriesAuto add directories not part of filesystem
--rpm-auto-add-exclude-directories DIRECTORIESAdditional directories ignored by ‘–rpm-auto-add-directories’ flag
--[no-]rpm-autoprovEnable RPM’s AutoProv option
--[no-]rpm-autoreqEnable RPM’s AutoReq option
--[no-]rpm-autoreqprovEnable RPM’s AutoReqProv option
--rpm-changelog FILEPATHAdd changelog from FILEPATH contents
--rpm-compression none|xz|xzmt|gzip|bzip2Select 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 ATTRSet the default dir mode (%defattr).
--rpm-defattrfile ATTRSet the default file mode (%defattr).
--rpm-digest md5|sha1|sha256|sha384|sha512Select a digest algorithm. md5 works on the most platforms.
--rpm-dist DIST-TAGSet the rpm distribution.
--rpm-filter-from-provides REGEXSet %filter_from_provides to the supplied REGEX.
--rpm-filter-from-requires REGEXSet %filter_from_requires to the supplied REGEX.
--rpm-group GROUPSet the group to GROUP in the %files section. Overrides the group when used with use-file-permissions setting.
--[no-]rpm-ignore-iteration-in-dependenciesFor ‘=’ (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 FILEPATHAdd FILEPATH as an init script
--[no-]rpm-macro-expansioninstall-time macro expansion in %pre %post %preun %postun scripts (see: https://rpm-software-management.github.io/rpm/manual/scriptlet_expansion.html)
--[no-]rpm-old-perl-dependency-nameUse older ‘perl’ depdency name. Newer Red Hat (and derivatives) use a dependency named ‘perl-interpreter’.
--rpm-os OSThe 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 FILEposttrans script
--rpm-pretrans FILEpretrans script
--rpm-rpmbuild-define DEFINITIONPass a –define argument to rpmbuild.
--[no-]rpm-signPass –sign to rpmbuild
--rpm-summary SUMMARYSet the RPM summary. Overrides the first line on the description if set
--rpm-tag TAGAdds 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: https://rpm-software-management.github.io/rpm/manual/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: https://rpm-software-management.github.io/rpm/manual/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: https://rpm-software-management.github.io/rpm/manual/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: https://rpm-software-management.github.io/rpm/manual/triggers.html
--[no-]rpm-use-file-permissionsUse existing file permissions when defining ownership and modes.
--rpm-user USERSet the user to USER in the %files section. Overrides the user when used with use-file-permissions setting.
--[no-]rpm-verbatim-gem-dependenciesWhen 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 FILEa script to be run on verification