Create a deb for your elixir release with ease
MIT License
Adds simple Debian Package (DEB) generation to the exrm package manager.
Before using exrm-deb, you'll need the following commands 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
Exrm-deb 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.0",
+ description: "Create a deb for your elixir release with ease",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
- deps: deps]
+ deps: deps,
+ package: package]
end
The package
function must be set as per the hex guidelines, but with some extra lines:
def package do
[
+ external_dependencies: [],
+ codename: lsb_release(),
+ license_file: "LICENSE",
files: [ "lib", "mix.exs", "README*", "LICENSE"],
+ config_files: ["/etc/init/api.conf"],
maintainers: ["John Hamelink <[email protected]>"],
licenses: ["MIT"],
vendor: "John Hamelink",
links: %{
"GitHub" => "https://github.com/johnhamelink/testapp",
"Docs" => "hexdocs.pm/testapp",
+ "Homepage" => "https://github.com/johnhamelink/testapp"
}
]
end
def lsb_release do
{release, _} = System.cmd("lsb_release", ["-c", "-s"])
String.replace(release, "\n", "")
end
A list of configuration options you can add to package/0
:
config_file
licenses
["Copyright <date> <company_name>"]
if you are building private packages.maintainers
name <email>
external_dependencies
package-name (operator version_number)
where operator is either <<
, <=
, =
, >=
, or >>
- read more about this here.
maintainer_scripts
:pre_install
, :post_install
, :pre_uninstall
, or :post_uninstall
vendor
owner
user
and group
keys to be set.codename
This configuration can be very useful in case you want to package the same version of the app for different distributions dynamically, without modifying the version in Distillery configuration.
A typical use case can be an environment where you have different Docker containers, and a different OS: each container compiles and packages the application in the running OS, in order to avoid startup problems in production.
With codename, at the end of the process, you obtain a package in the form myapp-1.2.1~xenial_amd64.deb
.
Also the control script in the deb file is packaged with the correct version like 1.2.1~xenial
.
At this point, it's easier to manage the packages loaded in a repository, because they are versioned also by distribution.
You can build a deb by adding plugin ExrmDeb.Distillery
to your rel/config.exs
file. With distillery, the name and version is taken from the rel/config.exs
file as opposed to the mix.exs
file.
You can build a deb at the same time as building a release by adding the --deb option to release.
mix release --deb
This task first constructs the release using exrm, then generates a deb file
for the release. The deb is built from scratch, retrieving default values such
as the name, version, etc using the mix.exs
file.
The _build/deb
directory tree, along with the rest of the release can be removed with mix release.clean
Please visit exrm for additional information.
You can customise the debs that are being built by copying the template files used and modifying them:
mix release.deb.generate_templates
When you next run mix release --deb
, your custom templates will be used instead of the defaults inside the plugin.
The package can be installed as:
Add exrm_deb to your list of dependencies in mix.exs
:
def deps do [{:exrm_deb, "~> 0.0.1"}] end
Ensure exrm_deb is started before your application:
def application do [applications: [:exrm_deb]] end