Effing Package Management (FPM)

repository·main·Indexed 11 days ago

https://github.com/jordansissel/fpm

A tool for quickly building platform-native packages, such as RPMs, DEBs, and OSX packages, from various sources including directories, gems, or tarballs. It provides a unified CLI to manage package metadata, dependencies, and lifecycle scripts across multiple formats including pacman, snap, and FreeBSD packages.

Tokens
22.8K
Snippets
64
Records
127
Agent score
92%

What's inside FPM

  1. Overview of fpm

    main

    fpm is a tool designed to make it easy and quick to build platform-native packages such as deb, rpm, osxpkg, freebsd, and more. It aims to simplify the packaging process by allowing users to specify an installation directory and dependencies, then automatically generating the appropriate package format.

    Key capabilities include:

    • Creating packages easily: Supports various formats like deb, rpm, and freebsd.
    • Tweaking existing packages: Allows for removing files or changing metadata and dependencies.
    • Script manipulation: Enables stripping pre/post/maintainer scripts from existing packages.
  2. Overview of fpm packaging capabilities

    main

    fpm is a command-line tool designed to simplify the creation of packages for multiple operating systems. It acts as a wrapper to help you build packages for existing systems with minimal effort by providing a unified interface.

    Supported target platforms include:

    • Debian
    • Ubuntu
    • Fedora
    • CentOS
    • RHEL
    • Arch Linux
    • FreeBSD
    • macOS
    • and more.
  3. Understand FPM Docker image types and BASE_ENV

    main

    The FPM Dockerfile uses multi-stage builds to provide different levels of dependency coverage via the BASE_ENV argument. This allows you to choose between a smaller footprint or a full environment.

    • minimal: Contains compiled dependencies and Ruby. Use this if you do not need scripting language packages.
    • everything: Includes minimal plus scripting systems like python and perl. This is the default if BASE_ENV is unspecified.

    Use the TARGET argument in the Dockerfile to select which specific container to build (e.g., for runtime vs. testing).

  4. How FPM works: Sources and Targets

    main

    FPM (Effing Package Manager) converts source files or existing packages into various distribution formats. The core command structure is:

    fpm [options] <source_type> <target_type> <sources>

    Supported Source Types (-s)

    • dir: A file or directory containing files to be packaged.
    • npm: A Node.js package.
    • gem: A Ruby gem.
    • python: A Python package (via easy_install or local setup.py).
    • virtualenv: A Python virtual environment.
    • pear: A PEAR package.
    • cpan: A Perl (CPAN) module.
    • deb: An existing .deb package.
    • rpm: An existing .rpm package.
    • pacman: A .pkg.tar.zst package.
    • pkgin: A .pkgin package.
    • empty: A package with no files (useful for meta-packages).

    Supported Target Types (-t)

    • deb: Debian/Ubuntu packages.
    • rpm: RedHat-based packages.
    • solaris: Solaris packages.
    • freebsd: FreeBSD packages.
    • osxpkg: macOS .pkg files.
    • pacman: Arch Linux .pkg.tar.zst packages.
    • puppet: Puppet modules.
    • p5p: P5P modules.
    • sh: Self-extracting installers.
    • tar: Tarfiles for root extraction.
    • zip: Zipfiles for root extraction.
    • dir: A directory that can be copied to the root.
  5. Use tar as an input or output type in FPM

    main

    FPM supports tar (Tape archives) as both an input and output format.

    • As Input: You can provide a .tar file as a source to be converted into a different output type (e.g., converting a tar archive into an rpm or a dir).
    • As Output: You can use FPM to create a .tar package from your source files.
  6. Use Ruby gems as input for package conversion

    main
    FPM supports using gem (Ruby's rubygem packages) exclusively as an input type. You can use this to convert existing Ruby gem packages into other distribution formats such as .deb (Debian/Ubuntu) or .rpm (Red Hat/Fedniora).
  7. Configure the installation prefix for npm packages

    main

    FPM determines where to install files by querying npm prefix -g. By default, this is the global prefix configured in your npm environment (e.g., /usr/local/lib/node_modules).

    You can override this behavior in two ways:

    1. Use the FPM --prefix flag during package creation.
    2. Change the default global prefix in the npm tool itself.
  8. Use Debian (deb) as an input or output type in FPM

    main

    FPM supports the Debian package format (deb) for both input (-s) and output (-t).

    As an output type: You can create a .deb package from various sources like zip, dir, or rpm.

    As an input type: You can read an existing .deb file to convert it into a different format (e.g., converting a .deb to an .rpm or a directory).

    When using deb as an input type, the argument provided to FPM is treated as the path to the Debian package file.

    # Convert a deb package to an rpm package
    fpm -s deb -t rpm file.deb
  9. Use zip files as input or output in FPM

    main

    FPM supports zip files for both input and output operations.

    • As Input: You can provide a .zip file as the source to be converted into a different package format (e.g., converting a zip archive into an rpm or a dir).
    • As Output: You can use FPM to create a .zip package as the final output of your build process.
  10. Use the 'dir' input type to package local files

    main

    In FPM, the dir input type allows you to take local files or directories and include them in a package (such as a Debian or Red Hat package).

    There are two ways to provide arguments when using dir as an input type:

    1. Direct Path: Providing a path to a local file or directory will include it in the output package with its original path, contents, and metadata (owner, modification date, etc.).
    2. Mapping Syntax: Using the syntax localpath=destinationpath allows you to copy a local file to a specific destination path within the output package.

    Important Flags:

    • --chdir: Modifies the local file paths provided as arguments.
    • --prefix: Modifies the destination file paths within the package.
    # Example 1: Include a file as-is (relative to current dir)
    fpm -s dir -t deb -n my-package my-local-file.txt
    
    # Example 2: Map a local file to a specific destination in the package
    fpm -s dir -t deb -n my-package local-file.txt=/usr/bin/destination-name
    
    # Example 3: Using --prefix to change the destination root
    fpm -s dir -t deb -n my-package --prefix=/opt/my-app local-file.txt=/bin/local-file.txt