@@ -45,10 +45,6 @@ XREF_IGNORE = [ \
4545xref : ERL_LIBS := $(ERL_LIBS ) :$(CURDIR ) /apps:$(CURDIR ) /deps:$(dir $(shell elixir --eval ':io.format "~s~n", [:code.lib_dir :elixir ]') )
4646endif
4747
48- ifneq ($(wildcard deps/.hex/cache.erl) ,)
49- deps :: restore-hex-cache-ets-file
50- endif
51-
5248include rabbitmq-components.mk
5349
5450# Set PROJECT_VERSION, calculated in rabbitmq-components.mk,
@@ -81,54 +77,6 @@ ifdef PLUGINS
8177RABBITMQ_ENABLED_PLUGINS ?= $(call comma_list,$(PLUGINS ) )
8278endif
8379
84- # --------------------------------------------------------------------
85- # Mix Hex cache management.
86- # --------------------------------------------------------------------
87-
88- # We restore the initial Hex cache.ets file from an Erlang term created
89- # at the time the source archive was prepared.
90- #
91- # See the `$(SOURCE_DIST)` recipe for the reason behind this step.
92-
93- restore-hex-cache-ets-file : deps/.hex/cache.ets
94-
95- deps/.hex/cache.ets : deps/.hex/cache.erl
96- $(gen_verbose ) $(call erlang,$(call restore_hex_cache_from_erl_term,$< ,$@ ) )
97-
98- define restore_hex_cache_from_erl_term
99- In = "$(1 ) ",
100- Out = "$(2 ) ",
101- {ok, [Props, Entries]} = file:consult(In),
102- Name = proplists:get_value(name, Props),
103- Type = proplists:get_value(type, Props),
104- Access = proplists:get_value(protection, Props),
105- NamedTable = proplists:get_bool(named_table, Props),
106- Keypos = proplists:get_value(keypos, Props),
107- Heir = proplists:get_value(heir, Props),
108- ReadConc = proplists:get_bool(read_concurrency, Props),
109- WriteConc = proplists:get_bool(write_concurrency, Props),
110- Compressed = proplists:get_bool(compressed, Props),
111- Options0 = [
112- Type,
113- Access,
114- {keypos, Keypos},
115- {heir, Heir},
116- {read_concurrency, ReadConc},
117- {write_concurrency, WriteConc}],
118- Options1 = case NamedTable of
119- true -> [named_table | Options0];
120- false -> Options0
121- end,
122- Options2 = case Compressed of
123- true -> [compressed | Options0];
124- false -> Options0
125- end,
126- Tab = ets:new(Name, Options2),
127- [true = ets:insert(Tab, Entry) || Entry <- Entries],
128- ok = ets:tab2file(Tab, Out),
129- init:stop().
130- endef
131-
13280# --------------------------------------------------------------------
13381# Distribution.
13482# --------------------------------------------------------------------
@@ -250,14 +198,6 @@ $(SOURCE_DIST): $(ERLANG_MK_RECURSIVE_DEPS_LIST)
250198 sed -E -i.bak " s|^[[:blank:]]*include[[:blank:]]+\.\./.*erlang.mk$$ |include ../../erlang.mk|" \
251199 $@ /deps/$$(basename $$dep) /Makefile && \
252200 rm $@ /deps/$$(basename $$dep) /Makefile.bak; \
253- mix_exs=$@ /deps/$$(basename $$dep) /mix.exs; \
254- if test -f $$ mix_exs; then \
255- (cd $$ (dirname " $$ mix_exs" ) && \
256- (test -d $@ /deps/.hex || env DEPS_DIR=$@ /deps MIX_HOME=$@ /deps/.mix HEX_HOME=$@ /deps/.hex MIX_ENV=prod FILL_HEX_CACHE=yes mix local.hex --force) && \
257- env DEPS_DIR=$@ /deps MIX_HOME=$@ /deps/.mix HEX_HOME=$@ /deps/.hex MIX_ENV=prod FILL_HEX_CACHE=yes mix deps.get --only prod && \
258- cp $(CURDIR ) /mk/rabbitmq-mix.mk . && \
259- rm -rf _build deps); \
260- fi ; \
261201 if test -f " $$ dep/license_info" ; then \
262202 cp " $$ dep/license_info" " $@ /deps/licensing/license_info_$$ (basename " $$ dep" )" ; \
263203 cat " $$ dep/license_info" >> $@ /LICENSE; \
@@ -283,52 +223,10 @@ $(SOURCE_DIST): $(ERLANG_MK_RECURSIVE_DEPS_LIST)
283223 $(verbose ) echo " PLUGINS := $( PLUGINS) " > $@ /plugins.mk
284224# Remember the latest Git timestamp.
285225 $(verbose) sort -r < "
[email protected] " | head -n 1 > "
[email protected] "
286- # Mix Hex component requires a cache file, otherwise it refuses to build
287- # offline... That cache is an ETS table with all the applications we
288- # depend on, plus some versioning informations and checksums. There
289- # are two problems with that: the table contains a date (`last_update`
290- # field) and `ets:tab2file()` produces a different file each time it's
291- # called.
292- #
293- # To make our source archive reproducible, we fix the time of the
294- # `last_update` field to the last Git commit and dump the content of the
295- # table as an Erlang term to a text file.
296- #
297- # The ETS file must be recreated before compiling RabbitMQ. See the
298- # `restore-hex-cache-ets-file` Make target.
299- $(verbose) $(call erlang,$(call dump_hex_cache_to_erl_term,$(call core_native_path,$@),$(call core_native_path,
[email protected] )))
300226# Fix file timestamps to have reproducible source archives.
301227 $(verbose) find $@ -print0 | xargs -0 touch -t "$$(cat "
[email protected] ")"
302228303229
304- define dump_hex_cache_to_erl_term
305- In = "$(1 ) /deps/.hex/cache.ets",
306- Out = "$(1 ) /deps/.hex/cache.erl",
307- {ok, DateStr} = file:read_file("$(2 ) "),
308- {match, Date} = re:run(DateStr,
309- "^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})\.([0-9]{2})",
310- [{capture, all_but_first, list}]),
311- [Year, Month, Day, Hour, Min, Sec] = [erlang:list_to_integer(V) || V <- Date],
312- {ok, Tab} = ets:file2tab(In),
313- true = ets:insert(Tab, {last_update, {{Year, Month, Day}, {Hour, Min, Sec}}}),
314- Props = [
315- Prop
316- || {Key, _} = Prop <- ets:info(Tab),
317- Key =:= name orelse
318- Key =:= type orelse
319- Key =:= protection orelse
320- Key =:= named_table orelse
321- Key =:= keypos orelse
322- Key =:= heir orelse
323- Key =:= read_concurrency orelse
324- Key =:= write_concurrency orelse
325- Key =:= compressed],
326- Entries = ets:tab2list(Tab),
327- ok = file:write_file(Out, io_lib:format("~w.~n~w.~n", [Props, Entries])),
328- ok = file:delete(In),
329- init:stop().
330- endef
331-
332230$(SOURCE_DIST ) .manifest : $(SOURCE_DIST )
333231 $(gen_verbose ) cd $(dir $(SOURCE_DIST ) ) && \
334232 find $(notdir $(SOURCE_DIST ) ) | LC_COLLATE=C sort > $@
0 commit comments