rpm - RedHat Package Manager — fpm (2024)

rpm is the package format used on RedHat Enterprise (RHEL), Fedora, CentOS, anda 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 nginxCreated 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 -iName : exampleVersion : 1.0Release : 1Architecture: x86_64Install Date: (not installed)Group : defaultSize : 0License : unknownSignature : (none)Source RPM : example-1.0-1.src.rpmBuild Date : Wed 20 Oct 2021 09:43:25 PM PDTBuild Host : snickerdoodle.localdomainRelocations : /Packager : <jls@snickerdoodle>Vendor : noneURL : http://example.com/no-uri-givenSummary : no description givenDescription :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 exampleCreated 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.rpmCreated 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.rpmCreated 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'
  • --rpm-trigger-after-target-uninstall '[OPT]PACKAGE: FILEPATH'
  • --rpm-trigger-before-install '[OPT]PACKAGE: FILEPATH'
  • --rpm-trigger-before-uninstall '[OPT]PACKAGE: FILEPATH'
  • --[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
rpm - RedHat Package Manager — fpm (2024)
Top Articles
Latest Posts
Article information

Author: Lidia Grady

Last Updated:

Views: 6486

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.