Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distillery v1 compatibility #29

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/distillery.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@ defmodule ExrmDeb.Distillery do
[Distillery](https://github.com/bitwalker/distillery)'s plugin system.
"""
use Mix.Releases.Plugin
alias ExrmDeb.Config

def before_assembly(release), do: release
def after_assembly(release = %Release{}) do
def before_assembly(release, _options), do: release
def after_assembly(release = %Release{}, _options) do
info "Building Deb Package"
case ExrmDeb.Config.build_config(:distillery, release) do
case Config.build_config(:distillery, release) do
{:ok, config} ->
ExrmDeb.start_build(config)
release
_ -> nil
end
end
def after_assembly(release), do: release
def after_assembly(release, _options), do: release

def before_package(release), do: release
def after_package(release), do: release
def before_package(release, _options), do: release
def after_package(release, _options), do: release

def before_release(release), do: release
def after_release(release), do: release
def before_release(release, _options), do: release
def after_release(release, _options), do: release

def after_cleanup(_args) do
def after_cleanup(_args, _options) do
ExrmDeb.remove_deb_dir
:ok
end
Expand Down
15 changes: 9 additions & 6 deletions lib/exrm_deb/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ defmodule ExrmDeb.Config do
"""

defstruct name: nil, version: nil, licenses: nil, maintainers: nil,
external_dependencies: nil, maintainer_scripts: [], config_files: [],
homepage: nil, description: nil, vendor: nil,
arch: nil, owner: [user: "root", group: "root"]
external_dependencies: nil, maintainer_scripts: [],
config_files: [], homepage: nil, description: nil,
vendor: nil, arch: nil, distillery: false,
owner: [user: "root", group: "root"]

use Vex.Struct
alias ReleaseManager.Utils.Logger
alias ExrmDeb.Utils
alias Mix.Project
import Logger, only: [debug: 1, error: 1]

Expand All @@ -35,9 +37,10 @@ defmodule ExrmDeb.Config do
[
{:name, Atom.to_string(release.name)},
{:version, release.version},
{:description, Mix.Project.config[:description]},
{:arch, ExrmDeb.Utils.Config.detect_arch}
] ++ config_from_package(Mix.Project.config[:package])
{:description, Project.config[:description]},
{:arch, Utils.Config.detect_arch},
{:distillery, true}
] ++ config_from_package(Project.config[:package])

base_config =
base_config
Expand Down
3 changes: 2 additions & 1 deletion lib/exrm_deb/control.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ defmodule ExrmDeb.Control do
debug "Marking config files"
config_files = Map.get(config, :config_files, [])
:ok =
Path.join([control_dir, "conffiles"])
[control_dir, "conffiles"]
|> Path.join()
|> File.write(Enum.join(config_files, "\n"))
end

Expand Down
19 changes: 14 additions & 5 deletions lib/exrm_deb/data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ defmodule ExrmDeb.Data do
This module houses the logic required to build the data payload portion of the
debian package.
"""
alias ReleaseManager.Utils.Logger
alias ReleaseManager.Utils
alias ExrmDeb.Utils.Compression
alias ReleaseManager.Utils.Logger
alias ReleaseManager.Utils
alias ExrmDeb.Utils.Compression
alias ExrmDeb.Generators.{Changelog, Upstart, Systemd}
alias Mix.Project
import Logger, only: [debug: 1]

def build(dir, config) do
Expand Down Expand Up @@ -35,7 +36,7 @@ defmodule ExrmDeb.Data do
end


# We don't use/need the .tar.gz file built be exrm, so
# We don't use/need the .tar.gz file built by exrm, so
# remove it from the data dir to reduce filesize.
defp remove_targz_file(data_dir, config) do
[data_dir, "opt", config.name, "#{config.name}-#{config.version}.tar.gz"]
Expand All @@ -54,11 +55,19 @@ defmodule ExrmDeb.Data do

defp copy_release(data_dir, config) do
dest = Path.join([data_dir, "opt", config.name])
src = Path.join(Utils.rel_dest_path, config.name)
src = src_path(config)

debug("Copying #{src} into #{dest} directory")
{:ok, _} = File.cp_r(src, dest)

dest
end

defp src_path(%ExrmDeb.Config{distillery: true} = config) do
Path.join([Project.build_path, "rel", config.name])
end

defp src_path(config) do
Path.join([Utils.rel_dest_path, config.name])
end
end
2 changes: 2 additions & 0 deletions lib/exrm_deb/deb.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ defmodule ExrmDeb.Deb do
"#{config.sanitized_name}-#{config.version}.deb"
])

File.rm out

args = [
"-qc",
out,
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ defmodule ExrmDeb.Mixfile do
defp deps(_) do
[
{:exrm, "~> 1.0"},
{:distillery, "~> 0.10"},
{:distillery, "~> 1.0"},
{:timex, "~> 3.0"},
{:vex, "~> 0.5"},
{:swab, github: "crownedgrouse/swab", branch: "master"},
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"certifi": {:hex, :certifi, "0.4.0", "a7966efb868b179023618d29a407548f70c52466bf1849b9e8ebd0e34b7ea11f", [:rebar3], []},
"cf": {:hex, :cf, "0.2.1", "69d0b1349fd4d7d4dc55b7f407d29d7a840bf9a1ef5af529f1ebe0ce153fc2ab", [:rebar3], []},
"combine": {:hex, :combine, "0.9.2", "cd3c8721f378ebe032487d8a4fa2ced3181a456a3c21b16464da8c46904bb552", [:mix], []},
"credo": {:hex, :credo, "0.4.12", "f5e1973405ea25c6e64959fb0b6bf92950147a0278cc2a002a491b45f78f7b87", [:mix], [{:bunt, "~> 0.1.6", [hex: :bunt, optional: false]}]},
"distillery": {:hex, :distillery, "1.0.0", "a866a72bf2a3a5f078f5a249017ed951acda88a760d200512f91f585d74db1ec", [:mix], []},
"credo": {:hex, :credo, "0.5.3", "0c405b36e7651245a8ed63c09e2d52c2e2b89b6d02b1570c4d611e0fcbecf4a2", [:mix], [{:bunt, "~> 0.1.6", [hex: :bunt, optional: false]}]},
"dogma": {:hex, :dogma, "0.1.8", "1ee856ed64f3ad635a4b2127beea427ea1b9bc271b8731679a97938e1827730f", [:mix], [{:poison, ">= 1.0.0", [hex: :poison, optional: false]}]},
"distillery": {:hex, :distillery, "0.10.0", "4404b8e7b524de3649b3135a39921ace31f0f6216bba51964c836e83b29efe94", [:mix], []},
"earmark": {:hex, :earmark, "1.0.1", "2c2cd903bfdc3de3f189bd9a8d4569a075b88a8981ded9a0d95672f6e2b63141", [:mix], []},
"erlware_commons": {:hex, :erlware_commons, "0.21.0", "a04433071ad7d112edefc75ac77719dd3e6753e697ac09428fc83d7564b80b15", [:rebar3], [{:cf, "0.2.1", [hex: :cf, optional: false]}]},
"ex_doc": {:hex, :ex_doc, "0.14.1", "bfed8d4e93c755e2b150be925ad2cfa6af7c3bfcacc3b609f45f6048c9d623d6", [:mix], [{:earmark, "~> 1.0", [hex: :earmark, optional: false]}]},
Expand All @@ -24,7 +24,7 @@
"poison": {:hex, :poison, "2.1.0", "f583218ced822675e484648fa26c933d621373f01c6c76bd00005d7bd4b82e27", [:mix], []},
"providers": {:hex, :providers, "1.6.0", "db0e2f9043ae60c0155205fcd238d68516331d0e5146155e33d1e79dc452964a", [:rebar3], [{:getopt, "0.8.2", [hex: :getopt, optional: false]}]},
"relx": {:hex, :relx, "3.21.0", "91e1ea9f09b4edfda8461901f4b5c5e0226e43ec161e147eeab29f7761df6eb5", [:rebar3], [{:bbmustache, "1.0.4", [hex: :bbmustache, optional: false]}, {:cf, "0.2.1", [hex: :cf, optional: false]}, {:erlware_commons, "0.21.0", [hex: :erlware_commons, optional: false]}, {:getopt, "0.8.2", [hex: :getopt, optional: false]}, {:providers, "1.6.0", [hex: :providers, optional: false]}]},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:rebar, :make], []},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:make, :rebar], []},
"ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.5", "2e73e068cd6393526f9fa6d399353d7c9477d6886ba005f323b592d389fb47be", [:make], []},
"swab": {:git, "https://github.com/crownedgrouse/swab.git", "796460142133da5360c64faa3e7fa78f40af09b9", [branch: "master"]},
"timex": {:hex, :timex, "3.0.8", "71d5ebafcdc557c6c866cdc196c5054f587e7cd1118ad8937e2293d51fc85608", [:mix], [{:combine, "~> 0.7", [hex: :combine, optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}]},
Expand Down
3 changes: 1 addition & 2 deletions test/exrm_deb/config_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ defmodule ExrmDebTest.ConfigTest do
[:owner, :group],
:presence,
"must be present"}]} =
ExrmDeb.Config.build_config(%{owner: [user: "root"]})
ExrmDeb.Config.build_config(:exrm, %{owner: [user: "root"]})
end

end