Skip to content

Commit a2c999f

Browse files
committed
Remove timestamp from .app files to make them determinstic
This removes one more thing causing delta images to be bigger than necessary. Fixed in Elixir for a future release at elixir-lang/elixir#13763.
1 parent e1494e9 commit a2c999f

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

mix.exs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ defmodule NervesLivebook.MixProject do
148148
[
149149
overwrite: true,
150150
include_erts: &Nerves.Release.erts/0,
151-
steps: [&Nerves.Release.init/1, :assemble],
151+
steps: [&Nerves.Release.init/1, :assemble, &deterministic_apps/1],
152152
strip_beams: [keep: ["Docs"]]
153153
]
154154
end
@@ -159,4 +159,22 @@ defmodule NervesLivebook.MixProject do
159159
ignore_warnings: ".dialyzer_ignore.exs"
160160
]
161161
end
162+
163+
# TODO: Remove when Elixir 1.18 is released
164+
defp deterministic_apps(release_config) do
165+
pattern = Path.join([release_config.path, "**", "ebin", "*.app"])
166+
167+
Path.wildcard(pattern)
168+
|> Enum.each(&make_app_deterministic/1)
169+
170+
release_config
171+
end
172+
173+
defp make_app_deterministic(path) do
174+
# Force the config_mtime so that it's not a random timestamp
175+
{:ok, [{:application, app, info}]} = :file.consult(path)
176+
new_info = Keyword.delete(info, :config_mtime)
177+
178+
File.write!(path, :io_lib.format("~tp.~n", [{:application, app, new_info}]))
179+
end
162180
end

0 commit comments

Comments
 (0)