dgiot/deploy/packages/rpm/Makefile

63 lines
1.9 KiB
Makefile
Raw Normal View History

2021-02-23 13:49:34 +08:00
# Keep this short to avoid bloating beam files with long file path info
TOPDIR := /tmp/emqx
SRCDIR := $(TOPDIR)/$(PKG_VSN)
BUILT := $(SRCDIR)/BUILT
dash := -
none :=
space := $(none) $(none)
RPM_VSN ?= $(shell echo $(PKG_VSN) | grep -oE "[0-9]+\.[0-9]+(\.[0-9]+)?")
RPM_REL ?= $(shell echo $(PKG_VSN) | grep -oE "(alpha|beta|rc)\.[0-9]")
2021-05-18 14:54:48 +08:00
ARCH ?= amd64
2021-05-14 07:28:48 +08:00
ifeq ($(ARCH),mips64)
ARCH:=mips64el
endif
2021-05-18 14:54:48 +08:00
EMQX_NAME=$(subst -pkg,,$(EMQX_BUILD))
2021-05-14 07:28:48 +08:00
2021-05-18 14:54:48 +08:00
TAR_PKG := $(EMQX_REL)/_build/$(EMQX_BUILD)/rel/emqx/emqx-$(PKG_VSN).tar.gz
TARGET_PKG := $(EMQX_NAME)-$(SYSTEM)-$(PKG_VSN)-$(ARCH)
2021-02-23 13:49:34 +08:00
ifeq ($(RPM_REL),)
# no tail
RPM_REL := 1
endif
2021-05-18 14:54:48 +08:00
SOURCE_PKG := emqx-$(SYSTEM)-$(RPM_VSN)-$(RPM_REL).$(shell uname -m)
2021-02-23 13:49:34 +08:00
SYSTEMD := $(shell if command -v systemctl >/dev/null 2>&1; then echo yes; fi)
# Not $(PWD) as it does not work for make -C
CURDIR := $(shell pwd)
SERVICE_SRC := $(if $(SYSTEMD),$(CURDIR)/emqx.service,$(CURDIR)/init.script)
SERVICE_DST := $(if $(SYSTEMD),%{_unitdir}/emqx.service,%{_initddir}/emqx)
POST_ADDITION := $(if $(SYSTEMD),%systemd_post %{_name}.service,echo post)
PREUN_ADDITION := $(if $(SYSTEMD),%systemd_preun %{_name}.service,echo preun)
.PHONY: all
all: | $(BUILT)
2021-05-18 14:54:48 +08:00
cd $(SRCDIR)
2021-02-23 13:49:34 +08:00
rpmbuild -v -bb \
--define "_package_name $(EMQX_NAME)" \
--define "_name emqx" \
--define "_topdir $(TOPDIR)" \
--define "_version $(RPM_VSN)" \
2021-05-18 14:54:48 +08:00
--define "_reldir $(SRCDIR)" \
2021-02-23 13:49:34 +08:00
--define "_release $(RPM_REL)" \
--define "_service_src $(SERVICE_SRC)" \
--define "_service_dst $(SERVICE_DST)" \
--define "_post_addition $(POST_ADDITION)" \
--define "_preun_addition $(PREUN_ADDITION)" \
--define "_ostype -$(SYSTEM)" \
--define "_sharedstatedir /var/lib" \
emqx.spec
mkdir -p $(EMQX_REL)/_packages/$(EMQX_NAME)
2021-05-18 14:54:48 +08:00
cp $(TOPDIR)/RPMS/$(shell uname -m)/$(SOURCE_PKG).rpm $(EMQX_REL)/_packages/$(EMQX_NAME)/$(TARGET_PKG).rpm
2021-02-23 13:49:34 +08:00
$(BUILT):
2021-05-18 14:54:48 +08:00
mkdir -p $(TOPDIR) $(SRCDIR) $(SRCDIR)/BUILT
tar zxf $(TAR_PKG) -C $(SRCDIR)
2021-02-23 13:49:34 +08:00
clean:
rm -rf $(SRCDIR)