-
Notifications
You must be signed in to change notification settings - Fork 221
/
Copy pathpackages.mk
95 lines (86 loc) · 3.08 KB
/
packages.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/make -f
# -*- makefile -*-
PROFILES := emqx emqx-edge
PKG_PROFILES := emqx-pkg emqx-edge-pkg
ifeq ($(shell uname -s),Darwin)
SYSTEM := macos
else ifeq ($(shell uname -s),Linux)
ifneq ($(shell cat /etc/*-release |grep -o -i centos),)
ID := centos
VERSION_ID := $(shell rpm --eval '%{centos_ver}')
else
ID := $(shell sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g' )
VERSION_ID := $(shell sed -n '/^VERSION_ID=/p' /etc/os-release | sed -r 's/VERSION_ID=(.*)/\1/g' | sed 's/"//g')
endif
SYSTEM := $(shell echo $(ID)$(VERSION_ID) | sed -r "s/([a-zA-Z]*)-.*/\1/g")
##
## Support RPM and Debian based linux systems
##
ifeq ($(ID),ubuntu)
PKGERDIR := deb
else ifeq ($(ID),debian)
PKGERDIR := deb
else ifeq ($(ID),raspbian)
PKGERDIR := deb
else
PKGERDIR := rpm
endif
endif
.PHONY: relup-emqx
relup-emqx: $(REBAR)
ifneq ($(OS),Windows_NT)
@ln -snf _build/$(@:relup-%=%)/lib ./_checkouts
@if [ ! -z $$(ls | grep -E "$(@:relup-%=%)-$(SYSTEM)-(.*)-$$(uname -m).zip" | head -1 ) ]; then \
mkdir -p tmp/relup_packages/$(@:relup-%=%); \
cp $(@:relup-%=%)-$(SYSTEM)-*-$$(uname -m).zip tmp/relup_packages/$(@:relup-%=%); \
fi
EMQX_DESC="EMQ X Broker" $(REBAR) as $(@:relup-%=%) relup
endif
.PHONY: relup-emqx-edge
relup-emqx-edge: $(REBAR)
ifneq ($(OS),Windows_NT)
@ln -snf _build/$(@:relup-%=%)/lib ./_checkouts
@if [ ! -z $$(ls | grep -E "$(@:relup-%=%)-$(SYSTEM)-(.*)-$$(uname -m).zip" | head -1 ) ]; then \
mkdir -p tmp/relup_packages/$(@:relup-%=%); \
cp $(@:relup-%=%)-$(SYSTEM)-*-$$(uname -m).zip tmp/relup_packages/$(@:relup-%=%); \
fi
EMQX_DESC="EMQ X Edge" $(REBAR) as $(@:relup-%=%) relup
endif
.PHONY: emqx-tar emqx-pkg-tar
emqx-tar emqx-pkg-tar: $(REBAR)
ifneq ($(OS),Windows_NT)
@ln -snf _build/$(subst -tar,,$(@))/lib ./_checkouts
endif
EMQX_DESC="EMQ X Broker" $(REBAR) as $(subst -tar,,$(@)) tar
.PHONY: emqx-edge-tar emqx-edge-pkg-tar
emqx-edge-tar emqx-edge-pkg-tar: $(REBAR)
ifneq ($(OS),Windows_NT)
@ln -snf _build/$(subst -tar,,$(@))/lib ./_checkouts
endif
EMQX_DESC="EMQ X Edge" $(REBAR) as $(subst -tar,,$(@)) tar
.PHONY: $(PROFILES:%=%-zip)
$(PROFILES:%=%-zip): $(REBAR)
ifneq ($(shell echo $(PKG_VSN) | grep -oE "^[0-9]+\.[0-9]+\.[1-9]+?"),)
make relup-$(subst -zip,,$(@))
endif
make $(subst -zip,,$(@))-tar
@tard="/tmp/emqx_untar_$(PKG_VSN)" \
&& rm -rf "$${tard}" && mkdir -p "$${tard}/emqx" \
&& prof="$(subst -zip,,$(@))" \
&& relpath="$$(pwd)/_build/$${prof}/rel/emqx" \
&& pkgpath="$$(pwd)/_packages/$${prof}" \
&& mkdir -p $${pkgpath} \
&& tarball="$${relpath}/emqx-$(PKG_VSN).tar.gz" \
&& zipball="$${pkgpath}/$${prof}-$(SYSTEM)-$(PKG_VSN)-$$(uname -m).zip" \
&& tar zxf "$${tarball}" -C "$${tard}/emqx" \
&& cd "$${tard}" && zip -q -r "$${zipball}" ./emqx && cd -
.PHONY: $(PKG_PROFILES)
$(PKG_PROFILES:%=%): $(REBAR)
ifneq ($(PKGERDIR),)
make $(subst -pkg,,$(@))-zip
make $(@)-tar
make -C deploy/packages/$(PKGERDIR) clean
EMQX_REL=$$(pwd) EMQX_BUILD=$(@) PKG_VSN=$(PKG_VSN) SYSTEM=$(SYSTEM) make -C deploy/packages/$(PKGERDIR)
else
make $(subst -pkg,,$(@))-zip
endif