Skip to content
Elixir lib for creating Debian and RPM packages with Distillery
Branch: master
Clone or download
Latest commit ee1042a Aug 22, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib Upgrade for Elixir 1.7 and Distillery 2 support Aug 22, 2018
templates/debian Add missing 'force-reload' flag to sysvinit Jun 28, 2018
test Debian package naming (#7) Jun 27, 2018
.gitignore First commit Mar 3, 2017
.travis.yml Fix Aug 22, 2018
mix.exs Upgrade for Elixir 1.7 and Distillery 2 support Aug 22, 2018

Distillery Packager

Coverage Status Build Status

Elixir lib for creating Debian and RPM packages with Distillery.


  1. Able to build Debian packages
    1. With control file
    2. With customizable pre/post install/remove scripts
    3. With capability to add custom files/scripts to the package
  2. Able to build RPM packages
  3. Automatically builds init scripts, which are all customizable, for:
    1. Systemd
    2. Upstart
    3. SysVinit

Required OS dependencies

Before using distillery_packager, you'll need the following packages installed and in your path:

  • tar (or gtar if you're on a mac - you can brew install gnu-tar if you don't already have it)
  • ar
  • uname


Add distillery_packager to your list of dependencies in mix.exs:

def deps do
  [{:distillery_packager, "~> 1.0"}]

General configuration

Distillery_packager relies on the following data in the mix.exs file being set:

defmodule Testapp.Mixfile do
   use Mix.Project

   def project do
      [app: :testapp,
      version: "0.0.1",
      elixir: "~> 1.7",
+     description: "Elixir lib for creating linux packages with Distillery",
      build_embedded: Mix.env == :prod,
      start_permanent: Mix.env == :prod,
-     deps: deps()]
+     deps: deps(),
+     deb_package: deb_package()]

Debian package configuration

The deb_package function must be set as:

def deb_package do
      vendor: "18Months S.r.l.",
      maintainers: ["18Months <>"],
      homepage: "",
      base_path: "/opt",
      external_dependencies: [],
      maintainer_scripts: [
         pre_install: "rel/distillery_packager/debian/install_scripts/",
         post_install: "rel/distillery_packager/debian/install_scripts/",
         pre_uninstall: "rel/distillery_packager/debian/install_scripts/"
      config_files: ["/etc/init/.conf"],
      additional_files: [{"configs", "/etc/distillery_packager/configs"}],
      owner: [user: "root", group: "root"]

A list of configuration options you can add to deb_package/0:

  • vendor
    • String
    • The distribution vendor that's creating the debian package. I normally just put my name or company name.
  • maintainers
    • Array of Strings
    • Should be in the format name <email>
  • homepage
    • String
    • Should be in the format
  • base_path
    • String
    • The base path where the package will be installed in the destination host.
  • external_dependencies
    • Array of Strings
    • Should be in the format of package-name (operator version_number) where operator is either <<, <=, =, >=, or >> - read more about this here.
  • maintainer_scripts
    • A keyword list of Strings
    • The keyword should be one of: :pre_install, :post_install, :pre_uninstall, or :post_uninstall
    • The keyword should point to the path of a script you want to run at the moment in question.
  • config_file
    • Array of Strings
    • Should contain the absolute path of the config file to be overwritten.
  • additional_files
    • List of Tuples
    • Should contain the relative path of the source folder in the first position of the tuple. All files present in the source folder will be copied to the destination folder.
    • Should contain the path of the destination folder, relative to the target system where the package will be installed, in the second position of the tuple.
    • Source path here should be specified excluding the base path "rel/distillery_packager/debian/additional_files" in your project. A dedicated generator can be used to setup base path, for further details refer to the section below.
  • owner
    • A keyword list of Strings
    • If set, requires both user and group keys to be set.
    • This is used when building the archive to set the correct user and group
    • Defaults to root for user & group.
  • package_name
    • String
    • Specify a custom .deb package name, overriding the default which is based on the OTP release name

Distillery configuration

You can build a deb by adding plugin DistilleryPackager.Plugin to your rel/config.exs file.

You can also specify target distribution and architecture with plugin DistilleryPackager.Plugin, %{distribution: "xenial", architecture: "amd64"}

The name and version is taken from the rel/config.exs file.


Base path

You can generate the base path for additional files to be added to the package with:

mix release.deb.prepare_base_path

Customising deb config files

You can customise the debs that are being built by copying the template files used and modifying them:

mix release.deb.generate_templates


Packages are build with the mix release command built in Distillery.

You can’t perform that action at this time.