Skip to content
mcreenan edited this page Feb 8, 2013 · 60 revisions

Effing Package Management

Overview

% gem install fpm
% fpm -s <source type> -t <target type> [options]

Package source types:

  • "dir" - make a package from directories or files
  • "rpm" - make a package from an RPM
  • "gem" - make a package from a Rubygem
  • "python" - make a package from a python module (via easy_install or local setup.py)

Target package types:

  • "rpm" - produce an RPM
  • "deb" - produce a .deb
  • "solaris" - produce a solaris package (for use with pkgadd). NB Solaris is not yet implemented in the new API - creation of SVR4 packages currently requires use of version 0.3.x
  • "puppet" - produce a puppet module

Examples:

This will produce an rpm package named 'slashbin' containing all files in /bin and /sbin

% fpm -s dir -t rpm -n "slashbin" -v 1.0 /bin /sbin
...
Created /home/jls/slashbin-1.0.x86_64.rpm

% rpm -qp slashbin-1.0.x86_64.rpm -l |head -3
/bin
/bin/bash
/bin/bunzip2

Above, 'x86_64' was automatically chosen as the architecture. If you want to package something as 'noarch' (or 'all' in debian), you use the '-a' flag:

% fpm -s dir -t deb -a all -n cron-init-script -v 1.0 /etc/init.d/cron
...
Created /home/jls/cron-init-script_1.0_all.deb

Use Cases

Usage

Usage:
    fpm [OPTIONS] [ARGS] ...

Parameters:
    [ARGS] ...                    Inputs to the source package type. For the 'dir' type, this is the files and directories you want to include in the package. For others, like 'gem', it specifies the packages to download and use as the gem input
Options:
    -t OUTPUT_TYPE                the type of package you want to create (deb, rpm, solaris, etc)
    -s INPUT_TYPE                 the package type to use as input (gem, rpm, python, etc)
    -C CHDIR                      Change directory to here before searching for files
    --prefix PREFIX               A path to prefix files with when building the target package. This may be necessary for all input packages. For example, the 'gem' type willprefix with your gem directory automatically.
    -p, --package OUTPUT          The package file path to output.
    -n, --name NAME               The name to give to the package
    --verbose                     Enable verbose output
    --debug                       Enable debug output
    -v, --version VERSION         The version to give to the package (default: 1.0)
    --iteration ITERATION         The iteration to give to the package. RPM calls this the 'release'. FreeBSD calls it 'PORTREVISION'. Debian calls this 'debian_revision'
    --epoch EPOCH                 The epoch value for this package. RPM and Debian calls this 'epoch'. FreeBSD calls this 'PORTEPOCH'
    --license LICENSE             (optional) license name for this package
    --vendor VENDOR               (optional) vendor name for this package
    --category CATEGORY           (optional) category this package belongs to (default: "none")
    -d, --depends DEPENDENCY      A dependency. This flag can be specified multiple times. Value is usually in the form of: -d 'name' or -d 'name > version' (default: [])
    --provides PROVIDES           What this package provides (usually a name)
    --conflicts CONFLICTS         Other packages/versions this package conflicts with
    --replaces REPLACES           Other packages/versions this package replaces
    --config-files CONFIG_FILES   Mark a file in the package as being a config file. This uses 'conffiles' in debs and %config in rpm.  This argument can occur multiple times, to mark multiple config files.
    --directories DIRECTORIES     Mark a directory as being owned by the package, can be specified more than once, like "--directories=/etc/foo --directories=/usr/share/foo"
    -a, --architecture ARCHITECTURE The architecture name. Usually matches 'uname -m'. For automatic values, you can use '-a all' or '-a native'. These two strings will be translated into the correct value for your platform and target package type.
    -m, --maintainer MAINTAINER   The maintainer of this package. (default: "<root@ip-10-252-60-181>")
    -S, --package-name-suffix PACKAGE_NAME_SUFFIX a name suffix to append to package and dependencies.
    -e, --edit                    Edit the package spec before building. (default: false)
    -x, --exclude EXCLUDE_PATTERN Exclude paths matching pattern (shell wildcard globs valid here). If you have multiple file patterns to exclude, specify this flag multiple times.
    --description DESCRIPTION     Add a description for this package. (default: "no description")
    --url URI                     Add a url for this package. (default: "http://example.com/no-uri-given")
    --inputs INPUTS_PATH          The path to a file containing a newline-separated list of files and dirs to use as input.
    --post-install FILE           (DEPRECATED, use --after-install) a script to be run after package installation
    --pre-install FILE            (DEPRECATED, use --before-install) a script to be run before package installation
    --post-uninstall FILE         (DEPRECATED, use --after-remove) a script to be run after package removal
    --pre-uninstall FILE          (DEPRECATED, use --before-remove) a script to be run before package removal
    --after-install FILE          a script to be run after package installation
    --before-install FILE         a script to be run before package installation
    --after-remove FILE           a script to be run after package removal
    --before-remove FILE          a script to be run before package removal
    --template-scripts            Allow scripts to be templated. This lets you use ERB to template your packaging scripts (for --after-install, etc). For example, you can do things like <%= name %> to get the package name. For more information, see the fpm wiki: https://github.com/jordansissel/fpm/wiki/Script-Templates
    --[no-]deb-ignore-iteration-in-dependencies (deb only) 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
    --deb-pre-depends DEPENDENCY  (deb only) Add DEPENDENCY as a Pre-Depends
    --deb-compression COMPRESSION (deb only) The compression type to use, must be one of gz, bzip2, xz. (default: "gzip")
    --deb-custom-control FILEPATH (deb only) Custom version of the Debian control file.
    --deb-config SCRIPTPATH       (deb only) Add SCRIPTPATH as debconf config file.
    --deb-templates FILEPATH      (deb only) Add FILEPATH as debconf templates file.
    --deb-installed-size KILOBYTES (deb only) The installed size, in kilobytes. If omitted, this will be calculated automatically
    --pear-package-name-prefix PREFIX (pear only) Name prefix for pear package (default: "php-pear")
    --gem-bin-path DIRECTORY      (gem only) The directory to install gem executables (default: "/usr/bin")
    --gem-package-prefix NAMEPREFIX (gem only) (DEPRECATED, use --package-name-prefix) Name to prefix the package name with.
    --gem-package-name-prefix PREFIX (gem only) Name to prefix the package name with. (default: "rubygem")
    --gem-gem PATH_TO_GEM         (gem only) The path to the 'gem' tool (defaults to 'gem' and searches your $PATH) (default: "gem")
    --[no-]gem-fix-name           (gem only) Should the target package name be prefixed? (default: true)
    --[no-]gem-fix-dependencies   (gem only) Should the package dependencies be prefixed? (default: true)
    --rpm-user USER               (rpm only) Set the user to USER in the %files section. (default: "root")
    --rpm-group GROUP             (rpm only) Set the group to GROUP in the %files section. (default: "root")
    --rpm-rpmbuild-define DEFINITION (rpm only) Pass a --define argument to rpmbuild.
    --rpm-digest sha256|sha384|sha1|sha512|md5 (rpm only) Select a digest algorithm. md5 works on the most platforms. (default: "md5")
    --rpm-compression gzip|bzip2|xz (rpm only) Select a compression method. gzip works on the most platforms. (default: "gzip")
    --python-bin PYTHON_EXECUTABLE (python only) The path to the python executable you wish to run. (default: "python")
    --python-easyinstall EASYINSTALL_EXECUTABLE (python only) The path to the easy_install executable tool (default: "easy_install")
    --python-pypi PYPI_URL        (python only) PyPi Server uri for retrieving packages. (default: "http://pypi.python.org/simple")
    --python-package-prefix NAMEPREFIX (python only) (DEPRECATED, use --package-name-prefix) Name to prefix the package name with.
    --python-package-name-prefix PREFIX (python only) Name to prefix the package name with. (default: "python")
    --[no-]python-fix-name        (python only) Should the target package name be prefixed? (default: true)
    --[no-]python-fix-dependencies (python only) Should the package dependencies be prefixed? (default: true)
    --python-install-bin BIN_PATH (python only) The path to where python scripts should be installed to. (default: "/usr/bin")
    --python-install-lib LIB_PATH (python only) The path to where python libs should be installed to (default depends on your python installation). Want to what your target platform is using? Run this: python -c 'from distutils.sysconfig import get_python_lib; print get_python_lib()'
    -h, --help                    print help
Clone this wiki locally