$linuxjunkies
>

fpm(1)

fpm is a tool for building packages in multiple formats (deb, rpm, tar, etc.) from source code, directories, or other packages.

UbuntuDebianFedoraArch

Synopsis

fpm [options] -s input_type -t output_type [inputs...]

Description

fpm (Effing Package Management) simplifies package creation by accepting input from various sources—source directories, Python packages, Ruby gems, npm modules, or existing packages—and converting them into distributable formats. It eliminates the need to learn multiple packaging tools and standardizes deployment workflows.

Common workflows include packaging application directories into .deb or .rpm files for distribution, converting between package formats, and automating package builds in CI/CD pipelines. fpm handles file permissions, dependencies, and metadata automatically, reducing boilerplate.

Common options

FlagWhat it does
-s, --input-type TYPEInput type: dir, rpm, deb, gem, python, npm, tar, zip, etc.
-t, --output-type TYPEOutput package type: deb, rpm, tar, zip, osxpkg, etc.
-n, --name NAMEPackage name (defaults to directory name for dir input)
-v, --version VERSIONPackage version number
-d, --depends PACKAGEAdd a package dependency (can be used multiple times)
-m, --maintainer EMAILMaintainer name and email for package metadata
-C, --chdir DIRChange to directory before building package
-p, --package OUTPUTOutput filename or path for the generated package
--prefix PREFIXInstall prefix path (target installation directory)
--after-install SCRIPTScript to run after package installation
--before-remove SCRIPTScript to run before package removal
-a, --architecture ARCHTarget architecture (x86_64, i386, all, etc.)

Examples

Package a directory into a .deb file named myapp version 1.0

fpm -s dir -t deb -n myapp -v 1.0 -C /path/to/app .

Create an RPM with a dependency on nginx, mapping src/ to installation path

fpm -s dir -t rpm -n webserver -v 2.1 -d 'nginx >= 1.10' ./src=/usr/local/webserver

Convert a Ruby gem into a .deb package

fpm -s gem -t deb -n ruby-mylib my_gem_name

Package an npm module into a .deb for system-wide Node.js installation

fpm -s npm -t deb -n node-express express

Create package with post-installation script that runs after install

fpm -s dir -t deb -n app -v 1.0 --after-install post-install.sh ./dist=/opt/app

Convert an existing RPM package into .deb format

fpm -s rpm -t deb firefox-*.rpm

Package a directory into a timestamped tar.gz archive

fpm -s dir -t tar.gz -n backup -v $(date +%Y%m%d) -C /var/www .

Related commands