Adding a "source-bundle" target that largely duplicates the "source-dist" target
The main difference is that the "bundle" target does NOT exclude packaging and testing directories, which enables packaging and testing of the source archive. Signed-off-by: Kartik Ganesh <gkart@amazon.com>
This commit is contained in:
parent
f661c1ef9c
commit
54cbb74658
141
Makefile
141
Makefile
|
@ -137,6 +137,7 @@ endef
|
|||
# Distribution.
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
|
||||
.PHONY: source-dist clean-source-dist
|
||||
|
||||
SOURCE_DIST_BASE ?= rabbitmq-server
|
||||
|
@ -152,12 +153,26 @@ SOURCE_DIST_FILES = $(addprefix $(SOURCE_DIST).,$(SOURCE_DIST_SUFFIXES))
|
|||
source-dist: $(SOURCE_DIST_FILES)
|
||||
@:
|
||||
|
||||
.PHONY: source-bundle clean-source-bundle
|
||||
|
||||
SOURCE_BUNDLE_BASE ?= rabbitmq-server-bundle
|
||||
BUNDLE_DIST ?= $(PACKAGES_DIR)/$(SOURCE_BUNDLE_BASE)-$(PROJECT_VERSION)
|
||||
|
||||
BUNDLE_DIST_FILES = $(addprefix $(BUNDLE_DIST).,$(SOURCE_DIST_SUFFIXES))
|
||||
|
||||
.PHONY: $(BUNDLE_DIST_FILES)
|
||||
|
||||
source-bundle: $(BUNDLE_DIST_FILES)
|
||||
@:
|
||||
|
||||
RSYNC ?= rsync
|
||||
RSYNC_V_0 =
|
||||
RSYNC_V_1 = -v
|
||||
RSYNC_V_2 = -v
|
||||
RSYNC_V = $(RSYNC_V_$(V))
|
||||
RSYNC_FLAGS += -a $(RSYNC_V) \
|
||||
BASE_RSYNC_FLAGS += -a $(RSYNC_V) \
|
||||
--delete \
|
||||
--delete-excluded \
|
||||
--exclude '.sw?' --exclude '.*.sw?' \
|
||||
--exclude '*.beam' \
|
||||
--exclude '*.d' \
|
||||
|
@ -188,12 +203,10 @@ RSYNC_FLAGS += -a $(RSYNC_V) \
|
|||
--exclude '$(notdir $(DEPS_DIR))/' \
|
||||
--exclude 'hexer*' \
|
||||
--exclude 'logs/' \
|
||||
--exclude 'packaging' \
|
||||
--exclude 'PKG_*.md' \
|
||||
--exclude '/plugins/' \
|
||||
--include 'cli/plugins' \
|
||||
--exclude '$(notdir $(DIST_DIR))/' \
|
||||
--exclude 'test' \
|
||||
--exclude '/$(notdir $(PACKAGES_DIR))/' \
|
||||
--exclude '/PACKAGES/' \
|
||||
--exclude '/amqp_client/doc/' \
|
||||
|
@ -208,9 +221,21 @@ RSYNC_FLAGS += -a $(RSYNC_V) \
|
|||
--exclude '/ranch/doc/' \
|
||||
--exclude '/ranch/examples/' \
|
||||
--exclude '/sockjs/examples/' \
|
||||
--exclude '/workflow_sources/' \
|
||||
--delete \
|
||||
--delete-excluded
|
||||
--exclude '/workflow_sources/'
|
||||
|
||||
SOURCE_DIST_RSYNC_FLAGS += $(BASE_RSYNC_FLAGS) \
|
||||
--exclude 'packaging' \
|
||||
--exclude 'test'
|
||||
|
||||
# For source-bundle, explicitly include folders that are needed
|
||||
# for tests to execute. These are added before excludes from
|
||||
# the base flags so rsync honors the first match.
|
||||
SOURCE_BUNDLE_RSYNC_FLAGS += \
|
||||
--include 'rabbit_shovel_test/ebin' \
|
||||
--include 'rabbit_shovel_test/ebin/*' \
|
||||
--include 'rabbitmq_ct_helpers/tools' \
|
||||
--include 'rabbitmq_ct_helpers/tools/*' \
|
||||
$(BASE_RSYNC_FLAGS)
|
||||
|
||||
TAR ?= tar
|
||||
TAR_V_0 =
|
||||
|
@ -233,14 +258,14 @@ ZIP_V = $(ZIP_V_$(V))
|
|||
|
||||
$(SOURCE_DIST): $(ERLANG_MK_RECURSIVE_DEPS_LIST)
|
||||
$(verbose) mkdir -p $(dir $@)
|
||||
$(gen_verbose) $(RSYNC) $(RSYNC_FLAGS) ./ $@/
|
||||
$(gen_verbose) $(RSYNC) $(SOURCE_DIST_RSYNC_FLAGS) ./ $@/
|
||||
$(verbose) echo "$(PROJECT_DESCRIPTION) $(PROJECT_VERSION)" > "$@/git-revisions.txt"
|
||||
$(verbose) echo "$(PROJECT) $$(git rev-parse HEAD) $$(git describe --tags --exact-match 2>/dev/null || git symbolic-ref -q --short HEAD)" >> "$@/git-revisions.txt"
|
||||
$(verbose) echo "$$(TZ= git --no-pager log -n 1 --format='%cd' --date='format-local:%Y%m%d%H%M.%S')" > "$@.git-times.txt"
|
||||
$(verbose) cat packaging/common/LICENSE.head > $@/LICENSE
|
||||
$(verbose) mkdir -p $@/deps/licensing
|
||||
$(verbose) set -e; for dep in $$(cat $(ERLANG_MK_RECURSIVE_DEPS_LIST) | LC_COLLATE=C sort); do \
|
||||
$(RSYNC) $(RSYNC_FLAGS) \
|
||||
$(RSYNC) $(SOURCE_DIST_RSYNC_FLAGS) \
|
||||
$$dep \
|
||||
$@/deps; \
|
||||
rm -f \
|
||||
|
@ -287,6 +312,11 @@ $(SOURCE_DIST): $(ERLANG_MK_RECURSIVE_DEPS_LIST)
|
|||
$(verbose) echo "PLUGINS := $(PLUGINS)" > $@/plugins.mk
|
||||
# Remember the latest Git timestamp.
|
||||
$(verbose) sort -r < "$@.git-times.txt" | head -n 1 > "$@.git-time.txt"
|
||||
$(verbose) $(call erlang,$(call dump_hex_cache_to_erl_term,$(call core_native_path,$@),$(call core_native_path,$@.git-time.txt)))
|
||||
# Fix file timestamps to have reproducible source archives.
|
||||
$(verbose) find $@ -print0 | xargs -0 touch -t "$$(cat "$@.git-time.txt")"
|
||||
$(verbose) rm "$@.git-times.txt" "$@.git-time.txt"
|
||||
|
||||
# Mix Hex component requires a cache file, otherwise it refuses to build
|
||||
# offline... That cache is an ETS table with all the applications we
|
||||
# depend on, plus some versioning informations and checksums. There
|
||||
|
@ -300,11 +330,6 @@ $(SOURCE_DIST): $(ERLANG_MK_RECURSIVE_DEPS_LIST)
|
|||
#
|
||||
# The ETS file must be recreated before compiling RabbitMQ. See the
|
||||
# `restore-hex-cache-ets-file` Make target.
|
||||
$(verbose) $(call erlang,$(call dump_hex_cache_to_erl_term,$(call core_native_path,$@),$(call core_native_path,$@.git-time.txt)))
|
||||
# Fix file timestamps to have reproducible source archives.
|
||||
$(verbose) find $@ -print0 | xargs -0 touch -t "$$(cat "$@.git-time.txt")"
|
||||
$(verbose) rm "$@.git-times.txt" "$@.git-time.txt"
|
||||
|
||||
define dump_hex_cache_to_erl_term
|
||||
In = "$(1)/deps/.hex/cache.ets",
|
||||
Out = "$(1)/deps/.hex/cache.erl",
|
||||
|
@ -333,10 +358,77 @@ define dump_hex_cache_to_erl_term
|
|||
init:stop().
|
||||
endef
|
||||
|
||||
.PHONY: $(BUNDLE_DIST)
|
||||
|
||||
$(BUNDLE_DIST): $(ERLANG_MK_RECURSIVE_DEPS_LIST)
|
||||
$(verbose) mkdir -p $(dir $@)
|
||||
$(gen_verbose) $(RSYNC) $(SOURCE_BUNDLE_RSYNC_FLAGS) ./ $@/
|
||||
$(verbose) echo "$(PROJECT_DESCRIPTION) $(PROJECT_VERSION)" > "$@/git-revisions.txt"
|
||||
$(verbose) echo "$(PROJECT) $$(git rev-parse HEAD) $$(git describe --tags --exact-match 2>/dev/null || git symbolic-ref -q --short HEAD)" >> "$@/git-revisions.txt"
|
||||
$(verbose) echo "$$(TZ= git --no-pager log -n 1 --format='%cd' --date='format-local:%Y%m%d%H%M.%S')" > "$@.git-times.txt"
|
||||
$(verbose) cat packaging/common/LICENSE.head > $@/LICENSE
|
||||
$(verbose) mkdir -p $@/deps/licensing
|
||||
$(verbose) set -e; for dep in $$(cat $(ERLANG_MK_RECURSIVE_DEPS_LIST) | LC_COLLATE=C sort); do \
|
||||
$(RSYNC) $(SOURCE_BUNDLE_RSYNC_FLAGS) \
|
||||
$$dep \
|
||||
$@/deps; \
|
||||
rm -f \
|
||||
$@/deps/rabbit_common/rebar.config \
|
||||
$@/deps/rabbit_common/rebar.lock; \
|
||||
if test -f $@/deps/$$(basename $$dep)/erlang.mk && \
|
||||
test "$$(wc -l $@/deps/$$(basename $$dep)/erlang.mk | awk '{print $$1;}')" = "1" && \
|
||||
grep -qs -E "^[[:blank:]]*include[[:blank:]]+(erlang\.mk|.*/erlang\.mk)$$" $@/deps/$$(basename $$dep)/erlang.mk; then \
|
||||
echo "include ../../erlang.mk" > $@/deps/$$(basename $$dep)/erlang.mk; \
|
||||
fi; \
|
||||
sed -E -i.bak "s|^[[:blank:]]*include[[:blank:]]+\.\./.*erlang.mk$$|include ../../erlang.mk|" \
|
||||
$@/deps/$$(basename $$dep)/Makefile && \
|
||||
rm $@/deps/$$(basename $$dep)/Makefile.bak; \
|
||||
mix_exs=$@/deps/$$(basename $$dep)/mix.exs; \
|
||||
if test -f $$mix_exs; then \
|
||||
(cd $$(dirname "$$mix_exs") && \
|
||||
(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) && \
|
||||
env DEPS_DIR=$@/deps MIX_HOME=$@/deps/.mix HEX_HOME=$@/deps/.hex MIX_ENV=prod FILL_HEX_CACHE=yes mix deps.get --only prod && \
|
||||
cp $(CURDIR)/mk/rabbitmq-mix.mk . && \
|
||||
rm -rf _build deps); \
|
||||
fi; \
|
||||
if test -f "$$dep/license_info"; then \
|
||||
cp "$$dep/license_info" "$@/deps/licensing/license_info_$$(basename "$$dep")"; \
|
||||
cat "$$dep/license_info" >> $@/LICENSE; \
|
||||
fi; \
|
||||
find "$$dep" -maxdepth 1 -name 'LICENSE-*' -exec cp '{}' $@/deps/licensing \; ; \
|
||||
(cd $$dep; \
|
||||
echo "$$(basename "$$dep") $$(git rev-parse HEAD) $$(git describe --tags --exact-match 2>/dev/null || git symbolic-ref -q --short HEAD)") \
|
||||
>> "$@/git-revisions.txt"; \
|
||||
! test -d $$dep/.git || (cd $$dep; \
|
||||
echo "$$(env TZ= git --no-pager log -n 1 --format='%cd' --date='format-local:%Y%m%d%H%M.%S')") \
|
||||
>> "$@.git-times.txt"; \
|
||||
done
|
||||
$(verbose) cat packaging/common/LICENSE.tail >> $@/LICENSE
|
||||
$(verbose) find $@/deps/licensing -name 'LICENSE-*' -exec cp '{}' $@ \;
|
||||
$(verbose) rm -rf $@/deps/licensing
|
||||
$(verbose) for file in $$(find $@ -name '*.app.src'); do \
|
||||
sed -E -i.bak \
|
||||
-e 's/[{]vsn[[:blank:]]*,[[:blank:]]*(""|"0.0.0")[[:blank:]]*}/{vsn, "$(PROJECT_VERSION)"}/' \
|
||||
-e 's/[{]broker_version_requirements[[:blank:]]*,[[:blank:]]*\[\][[:blank:]]*}/{broker_version_requirements, ["$(PROJECT_VERSION)"]}/' \
|
||||
$$file; \
|
||||
rm $$file.bak; \
|
||||
done
|
||||
$(verbose) echo "PLUGINS := $(PLUGINS)" > $@/plugins.mk
|
||||
# Remember the latest Git timestamp.
|
||||
$(verbose) sort -r < "$@.git-times.txt" | head -n 1 > "$@.git-time.txt"
|
||||
$(verbose) $(call erlang,$(call dump_hex_cache_to_erl_term,$(call core_native_path,$@),$(call core_native_path,$@.git-time.txt)))
|
||||
# Fix file timestamps to have reproducible source archives.
|
||||
$(verbose) find $@ -print0 | xargs -0 touch -t "$$(cat "$@.git-time.txt")"
|
||||
$(verbose) rm "$@.git-times.txt" "$@.git-time.txt"
|
||||
|
||||
$(SOURCE_DIST).manifest: $(SOURCE_DIST)
|
||||
$(gen_verbose) cd $(dir $(SOURCE_DIST)) && \
|
||||
find $(notdir $(SOURCE_DIST)) | LC_COLLATE=C sort > $@
|
||||
|
||||
$(BUNDLE_DIST).manifest: $(BUNDLE_DIST)
|
||||
$(gen_verbose) cd $(dir $(BUNDLE_DIST)) && \
|
||||
find $(notdir $(BUNDLE_DIST)) | LC_COLLATE=C sort > $@
|
||||
|
||||
ifeq ($(shell tar --version | grep -c "GNU tar"),0)
|
||||
# Skip all flags if this is Darwin (a.k.a. macOS, a.k.a. OS X)
|
||||
ifeq ($(shell uname | grep -c "Darwin"),0)
|
||||
|
@ -373,11 +465,34 @@ $(SOURCE_DIST).zip: $(SOURCE_DIST).manifest
|
|||
$(gen_verbose) cd $(dir $(SOURCE_DIST)) && \
|
||||
$(ZIP) $(ZIP_V) --names-stdin $@ < $(SOURCE_DIST).manifest
|
||||
|
||||
$(BUNDLE_DIST).tar.gz: $(BUNDLE_DIST).manifest
|
||||
$(gen_verbose) cd $(dir $(BUNDLE_DIST)) && \
|
||||
$(TAR) $(TAR_V) $(TAR_FLAGS_FOR_REPRODUCIBLE_BUILDS) --no-recursion -T $(BUNDLE_DIST).manifest -cf - | \
|
||||
$(GZIP) --best > $@
|
||||
|
||||
$(BUNDLE_DIST).tar.bz2: $(BUNDLE_DIST).manifest
|
||||
$(gen_verbose) cd $(dir $(BUNDLE_DIST)) && \
|
||||
$(TAR) $(TAR_V) $(TAR_FLAGS_FOR_REPRODUCIBLE_BUILDS) --no-recursion -T $(BUNDLE_DIST).manifest -cf - | \
|
||||
$(BZIP2) > $@
|
||||
|
||||
$(BUNDLE_DIST).tar.xz: $(BUNDLE_DIST).manifest
|
||||
$(gen_verbose) cd $(dir $(BUNDLE_DIST)) && \
|
||||
$(TAR) $(TAR_V) $(TAR_FLAGS_FOR_REPRODUCIBLE_BUILDS) --no-recursion -T $(BUNDLE_DIST).manifest -cf - | \
|
||||
$(XZ) > $@
|
||||
|
||||
$(BUNDLE_DIST).zip: $(BUNDLE_DIST).manifest
|
||||
$(verbose) rm -f $@
|
||||
$(gen_verbose) cd $(dir $(BUNDLE_DIST)) && \
|
||||
$(ZIP) $(ZIP_V) --names-stdin $@ < $(BUNDLE_DIST).manifest
|
||||
|
||||
clean:: clean-source-dist
|
||||
|
||||
clean-source-dist:
|
||||
$(gen_verbose) rm -rf -- $(SOURCE_DIST_BASE)-*
|
||||
|
||||
clean-source-bundle:
|
||||
$(gen_verbose) rm -rf -- $(SOURCE_BUNDLE_BASE)-*
|
||||
|
||||
distclean:: distclean-packages
|
||||
|
||||
distclean-packages:
|
||||
|
|
Loading…
Reference in New Issue