From 3f8eff27faa4b2668f72b63500cbf0a5e6ab7911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Mon, 8 Jan 2018 10:56:32 +0100 Subject: [PATCH 1/3] Refactor code for installing binaries --- Makefile.in | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile.in b/Makefile.in index 301e8be50..ce67e2f80 100644 --- a/Makefile.in +++ b/Makefile.in @@ -136,7 +136,10 @@ ifeq ($(MAKECMDGOALS),copy-files-sub) DEPS:=$(sort $(shell $(REBAR) -q list-deps|$(SED) -ne '/ TAG / s/ .*// p; / REV / s/ .*// p; / BRANCH / s/ .*// p')) DEPS_FILES=$(call FILES_WILDCARD,$(foreach DEP,$(DEPS),deps/$(DEP)/ebin/*.beam deps/$(DEP)/ebin/*.app deps/$(DEP)/priv/* deps/$(DEP)/priv/lib/* deps/$(DEP)/priv/bin/* deps/$(DEP)/include/*.hrl deps/$(DEP)/COPY* deps/$(DEP)/LICENSE* deps/$(DEP)/lib/*/ebin/*.beam deps/$(DEP)/lib/*/ebin/*.app)) -DEPS_FILES_FILTERED=$(filter-out %/epam %/eimp %/mac_listener deps/elixir/ebin/elixir.app,$(DEPS_FILES)) + +BINARIES=deps/epam/priv/bin/epam deps/eimp/priv/bin/eimp deps/fs/priv/mac_listener + +DEPS_FILES_FILTERED=$(filter-out $(BINARIES) deps/elixir/ebin/elixir.app,$(DEPS_FILES)) DEPS_DIRS=$(sort deps/ $(foreach DEP,$(DEPS),deps/$(DEP)/) $(dir $(DEPS_FILES))) MAIN_FILES=$(filter-out %/configure.beam,$(call FILES_WILDCARD,ebin/*.beam ebin/*.app priv/msgs/*.msg priv/css/*.css priv/img/*.png priv/js/*.js priv/lib/* include/*.hrl COPYING)) @@ -153,20 +156,17 @@ define COPY_template $(call TO_DEST,$(1)): $(1) $(call TO_DEST,$(dir $(1))) ; $$(INSTALL) -m 644 $(1) $(call TO_DEST,$(1)) endef +define COPY_BINARY_template +$(call TO_DEST,$(1)): $(1) $(call TO_DEST,$(dir $(1))) ; $$(INSTALL) -m 755 $$(O_USER) $(1) $(call TO_DEST,$(1)) +endef + $(foreach file,$(DEPS_FILES_FILTERED) $(MAIN_FILES),$(eval $(call COPY_template,$(file)))) +$(foreach file,$(BINARIES),$(eval $(call COPY_BINARY_template,$(file)))) + $(sort $(call TO_DEST,$(MAIN_DIRS) $(DEPS_DIRS))): $(INSTALL) -d $@ -$(call TO_DEST,deps/epam/priv/bin/epam): $(LIBDIR)/%: deps/epam/priv/bin/epam $(call TO_DEST,deps/epam/priv/bin/) - $(INSTALL) -m 750 $(O_USER) $< $@ - -$(call TO_DEST,deps/eimp/priv/bin/eimp): $(LIBDIR)/%: deps/eimp/priv/bin/eimp $(call TO_DEST,deps/eimp/priv/bin/) - $(INSTALL) -m 755 $(O_USER) $< $@ - -$(call TO_DEST,deps/fs/priv/mac_listener): $(LIBDIR)/%: deps/fs/priv/mac_listener $(call TO_DEST,deps/fs/priv/) - $(INSTALL) -m 755 $(O_USER) $< $@ - $(call TO_DEST,priv/sql/lite.sql): sql/lite.sql $(call TO_DEST,priv/sql) $(INSTALL) -m 644 $< $@ From 2b0cc2ddb424554baf276d03bf5af0cbb91d5160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Mon, 8 Jan 2018 10:56:53 +0100 Subject: [PATCH 2/3] Make all install target rules as .PHONY --- Makefile.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.in b/Makefile.in index ce67e2f80..afc4d4ff9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -175,6 +175,8 @@ $(call TO_DEST,priv/bin/captcha.sh): tools/captcha.sh $(call TO_DEST,priv/bin) copy-files-sub2: $(call TO_DEST,$(DEPS_FILES) $(MAIN_FILES) priv/bin/captcha.sh priv/sql/lite.sql) +.PHONY: $(call TO_DEST,$(DEPS_FILES) $(MAIN_DIRS) $(DEPS_DIRS)) + endif copy-files: From c5a4f67935356e35745c1571ffda5619175ddda8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Mon, 8 Jan 2018 11:11:42 +0100 Subject: [PATCH 3/3] Delete old .so and executable files before installing new one This fixes crash for people who have live ejabberd installed in make install target directory, by ensuring that loaded binaries aren't replaced in memory with new content. --- Makefile.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.in b/Makefile.in index afc4d4ff9..8006e074c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -149,15 +149,17 @@ define DEP_VERSION_template DEP_$(1)_VERSION:=$(shell $(SED) -e '/vsn/!d;s/.*, *"/$(1)-/;s/".*//' $(2) 2>/dev/null) endef +DELETE_TARGET_SO=$(if $(subst X.soX,,X$(suffix $(1))X),,rm $(call TO_DEST,$(1));) + $(foreach DEP,$(DEPS),$(eval $(call DEP_VERSION_template,$(DEP),deps/$(DEP)/ebin/$(DEP).app))) $(eval $(call DEP_VERSION_template,ejabberd,ebin/ejabberd.app)) define COPY_template -$(call TO_DEST,$(1)): $(1) $(call TO_DEST,$(dir $(1))) ; $$(INSTALL) -m 644 $(1) $(call TO_DEST,$(1)) +$(call TO_DEST,$(1)): $(1) $(call TO_DEST,$(dir $(1))) ; $(call DELETE_TARGET_SO, $(1)) $$(INSTALL) -m 644 $(1) $(call TO_DEST,$(1)) endef define COPY_BINARY_template -$(call TO_DEST,$(1)): $(1) $(call TO_DEST,$(dir $(1))) ; $$(INSTALL) -m 755 $$(O_USER) $(1) $(call TO_DEST,$(1)) +$(call TO_DEST,$(1)): $(1) $(call TO_DEST,$(dir $(1))) ; rm $(call TO_DEST,$(1)); $$(INSTALL) -m 755 $$(O_USER) $(1) $(call TO_DEST,$(1)) endef $(foreach file,$(DEPS_FILES_FILTERED) $(MAIN_FILES),$(eval $(call COPY_template,$(file))))