diff --git a/deploy/packages/deb/debian/rules b/deploy/packages/deb/debian/rules index 9ca6c8e17..7d28be282 100755 --- a/deploy/packages/deb/debian/rules +++ b/deploy/packages/deb/debian/rules @@ -33,23 +33,16 @@ install: build mkdir -p debian/emqx/var/lib/emqx mkdir -p debian/emqx/var/run/emqx mkdir -p debian/emqx/var/log/emqx - mkdir -p debian/emqx/usr/lib/emqx/bin - mkdir -p debian/emqx/etc/emqx - mkdir -p debian/emqx/etc/init.d - cp bin/* debian/emqx/usr/lib/emqx/bin - cp -R lib debian/emqx/usr/lib/emqx cp -R erts* debian/emqx/usr/lib/emqx cp -R releases debian/emqx/usr/lib/emqx cp -R etc/* debian/emqx/etc/emqx cp -R data/* debian/emqx/var/lib/emqx - install -d debian/emqx/lib/systemd/system install -p -m0644 debian/emqx.service debian/emqx/lib/systemd/system/emqx.service - dh_shlibdeps # We have nothing to do by default. diff --git a/deploy/packages/rpm/Makefile b/deploy/packages/rpm/Makefile index 72170dc4a..15de40627 100644 --- a/deploy/packages/rpm/Makefile +++ b/deploy/packages/rpm/Makefile @@ -20,9 +20,6 @@ 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) @@ -36,8 +33,6 @@ all: | $(BUILT) --define "_version $(RPM_VSN)" \ --define "_reldir $(SRCDIR)" \ --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 "_sharedstatedir /var/lib" \ diff --git a/deploy/packages/rpm/emqx.spec b/deploy/packages/rpm/emqx.spec index 461c3024c..26a223b88 100644 --- a/deploy/packages/rpm/emqx.spec +++ b/deploy/packages/rpm/emqx.spec @@ -19,10 +19,11 @@ BuildRoot: %{_tmppath}/%{_name}-%{_version}-root Provides: %{_name} AutoReq: 0 -%if "%{_arch} %{?rhel}" == "amd64 7" -Requires: openssl11 libatomic +# package name openssl11 is from epel-release, and only applicable for rhel 7 +%if "%{_arch} %{?rhel}" == "x86_64 7" +Requires: openssl11 libatomic procps which findutils %else -Requires: libatomic +Requires: libatomic procps which findutils %endif %description @@ -39,7 +40,6 @@ mkdir -p %{buildroot}%{_unitdir} mkdir -p %{buildroot}%{_conf_dir} mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_var_home} -mkdir -p %{buildroot}%{_initddir} cp -R %{_reldir}/lib %{buildroot}%{_lib_home}/ cp -R %{_reldir}/erts-* %{buildroot}%{_lib_home}/ @@ -47,7 +47,6 @@ cp -R %{_reldir}/releases %{buildroot}%{_lib_home}/ cp -R %{_reldir}/bin %{buildroot}%{_lib_home}/ cp -R %{_reldir}/etc/* %{buildroot}%{_conf_dir}/ cp -R %{_reldir}/data/* %{buildroot}%{_var_home}/ -install -m644 %{_service_src} %{buildroot}%{_service_dst} %pre if [ $1 = 1 ]; then @@ -64,23 +63,14 @@ if [ $1 = 1 ]; then ln -s %{_lib_home}/bin/emqx_ctl %{_bindir}/emqx_ctl fi %{_post_addition} -if [ -e %{_initddir}/%{_name} ] ; then - /sbin/chkconfig --add %{_name} -else - systemctl enable %{_name}.service -fi +systemctl enable %{_name}.service chown -R %{_user}:%{_group} %{_lib_home} %preun %{_preun_addition} # Only on uninstall, not upgrades if [ $1 = 0 ]; then - if [ -e %{_initddir}/%{_name} ] ; then - /sbin/service %{_name} stop > /dev/null 2>&1 - /sbin/chkconfig --del %{_name} - else - systemctl disable %{_name}.service - fi + systemctl disable %{_name}.service rm -f %{_bindir}/emqx rm -f %{_bindir}/emqx_ctl fi @@ -94,7 +84,6 @@ exit 0 %files %defattr(-,root,root) -%{_service_dst} %attr(-,%{_user},%{_group}) %{_lib_home}/* %attr(-,%{_user},%{_group}) %dir %{_var_home} %attr(-,%{_user},%{_group}) %config(noreplace) %{_var_home}/* @@ -105,4 +94,3 @@ exit 0 rm -rf %{buildroot} %changelog - diff --git a/deploy/packages/rpm/init.script b/deploy/packages/rpm/init.script deleted file mode 100755 index a2656be82..000000000 --- a/deploy/packages/rpm/init.script +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env bash -# -# emqx -# -# chkconfig: 2345 80 30 -# description: EMQX, a distributed, massively scalable, highly extensible MQTT message broker written in Erlang/OTP -# processname: beam -# - -# Source function library. -# shellcheck disable=SC1091 -. /etc/rc.d/init.d/functions - -RETVAL=0 -PATH=/sbin:/usr/sbin:/bin:/usr/bin -NAME=emqx -DAEMON=/usr/bin/$NAME -lockfile=/var/lock/subsys/$NAME -mkdir -p /var/run/$NAME -pidfile=/var/run/$NAME/$NAME.pid - -# Check for script, config and data dirs -[ -x /usr/bin/$NAME ] || exit 0 -[ -d /etc/$NAME ] || exit 0 -[ -d /var/lib/$NAME ] || exit 0 - -# Read configuration variable file if it is present and readable -# shellcheck disable=SC1090 -[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME - -# `service` strips all environmental VARS so -# if no HOME was set in /etc/sysconfig/$NAME then set one here -# to the data directory for erlexec's sake -if [ -z "$HOME" ]; then - export HOME= -fi - -status -p $pidfile -l "$(basename $lockfile)" $NAME >/dev/null 2>&1 -running=$? - -find_pid() { - # shellcheck disable=SC2009 # pgrep does not support Extended Regular Expressions - ps ax | grep -E "\-progname\s+$NAME\s" | awk '{print $1}' -} - -check_pid_status() { - local pid - pid="$(find_pid)" - if [ "$pid" = "" ]; then - # prog not running? - return 1 - else - # running - return 0 - fi -} - -start() { - # Start daemons. - echo -n $"Starting emqx: " - $DAEMON start - RETVAL=$? - if [ $RETVAL -eq 0 ]; then - touch $lockfile - find_pid > $pidfile - success - else - failure $"$NAME start" - fi - echo - return $RETVAL -} - -stop() { - # Stop daemon. - echo -n $"Shutting down emqx: " - $DAEMON stop 2>/dev/null - for _ in $(seq 1 10); do - sleep 1 - check_pid_status - RETVAL=$? - if [ $RETVAL -eq 1 ]; then - break - fi - done - if [ $RETVAL -eq 1 ]; then - rm -f $lockfile $pidfile - success - echo && return 0 - else - failure $"$NAME stop" - echo && return 1 - fi -} - -hardstop() { - echo -n $"Shutting down $NAME: " - su - emqx -c "ps -ef | grep -E '\-progname\s+$NAME\s' | awk '{print \$2}' | xargs kill -9" - for _ in $(seq 1 10); do - sleep 1 - check_pid_status - RETVAL=$? - if [ $RETVAL -eq 1 ]; then - break - fi - done - if [ $RETVAL -eq 1 ]; then - rm -f $lockfile $pidfile - success - echo && return 0 - else - failure $"$NAME hardstop" - echo && return 1 - fi -} - -# See how we were called. -case "$1" in - start) - [ $running -eq 0 ] && exit 0 - start - ;; - stop) - stop - ;; - restart|force-reload) - [ $running -eq 0 ] && stop - start - ;; - hardstop) - [ $running -eq 0 ] || exit 0 - hardstop - ;; - condrestart|try-restart) - [ $running -eq 0 ] || exit 0 - restart - ;; - status) - status -p $pidfile -l "$(basename $lockfile)" $NAME - ;; - ping) - $DAEMON ping || exit $? - ;; - *) - echo $"Usage: $0 {start|stop|restart|force-reload|hardstop|condrestart|try-restart|status|ping}" - exit 1 -esac - -exit $? diff --git a/git-blame-ignore-revs b/git-blame-ignore-revs index aa78ef23b..ddc77e18e 100644 --- a/git-blame-ignore-revs +++ b/git-blame-ignore-revs @@ -24,5 +24,6 @@ f1acfece6b79ed69b491da03783a7adaa7627b96 # reformat apps/emqx_management aa7807baebfa5d8678025e43f386bcd9b3259d6a bf54f571fb8b27e76ada4ca75137d96ce4211d60 +628f0bf57909f26208d45a02e33a7fbae8443249 # reformat apps/emqx_slow_subs 83511f8a4c1570a2c89d9c6c5b6f462520199ed8 diff --git a/scripts/buildx.sh b/scripts/buildx.sh index 127d316e8..358c72fee 100755 --- a/scripts/buildx.sh +++ b/scripts/buildx.sh @@ -25,9 +25,6 @@ help() { echo "--src_dir : EMQX source ode in this dir, default to PWD" echo "--builder : Builder image to pull" echo " E.g. ghcr.io/emqx/emqx-builder/5.0-10:1.13.3-24.2.1-1-debian10" - echo "--otp : OTP version being used in the builder" - echo "--elixir-vsn : Elixir version being used in the builder" - echo "--system : OS used in the builder image" } while [ "$#" -gt 0 ]; do @@ -56,14 +53,6 @@ while [ "$#" -gt 0 ]; do ARCH="$2" shift 2 ;; - --otp) - OTP_VSN="$2" - shift 2 - ;; - --elixir-vsn) - ELIXIR_VSN="$2" - shift 2 - ;; --elixir) shift 1 case ${1:-novalue} in @@ -84,10 +73,6 @@ while [ "$#" -gt 0 ]; do ;; esac ;; - --system) - SYSTEM="$2" - shift 2 - ;; *) echo "WARN: Unknown arg (ignored): $1" shift @@ -99,10 +84,7 @@ done if [ -z "${PROFILE:-}" ] || [ -z "${PKGTYPE:-}" ] || [ -z "${BUILDER:-}" ] || - [ -z "${ARCH:-}" ] || - [ -z "${OTP_VSN:-}" ] || - [ -z "${ELIXIR_VSN:-}" ] || - [ -z "${SYSTEM:-}" ]; then + [ -z "${ARCH:-}" ]; then help exit 1 fi @@ -135,25 +117,41 @@ else MAKE_TARGET="${PROFILE}-${PKGTYPE}" fi +HOST_SYSTEM="$(./scripts/get-distro.sh)" +BUILDER_SYSTEM="$(docker run --rm -v "$(pwd)":/emqx "$BUILDER" /emqx/scripts/get-distro.sh)" + CMD_RUN="make ${MAKE_TARGET} && ./scripts/pkg-tests.sh ${MAKE_TARGET}" -if [[ $(uname -m) = "x86_64" && "$ARCH" = "amd64" ]]; then - eval "$CMD_RUN" -elif [[ $(uname -m) = "aarch64" && "$ARCH" = "arm64" ]]; then - eval "$CMD_RUN" -elif [[ $(uname -m) = "arm64" && "$ARCH" = "arm64" ]]; then - eval "$CMD_RUN" -elif [[ $(uname -m) = "armv7l" && "$ARCH" = "arm64" ]]; then +IS_NATIVE_SYSTEM='no' +if [[ "$HOST_SYSTEM" = "$BUILDER_SYSTEM" ]]; then + IS_NATIVE_SYSTEM='yes' +fi + +IS_NATIVE_ARCH='no' +if [[ $(uname -m) == "x86_64" && "$ARCH" == "amd64" ]]; then + IS_NATIVE_ARCH='yes' +elif [[ $(uname -m) == "aarch64" && "$ARCH" == "arm64" ]]; then + IS_NATIVE_ARCH='yes' +elif [[ $(uname -m) == "arm64" && "$ARCH" == "arm64" ]]; then + IS_NATIVE_ARCH='yes' +elif [[ $(uname -m) == "armv7l" && "$ARCH" == "arm64" ]]; then + IS_NATIVE_ARCH='yes' +fi + + +if [[ "${IS_NATIVE_SYSTEM}" == 'yes' && "${IS_NATIVE_ARCH}" == 'yes' ]]; then eval "$CMD_RUN" elif docker info; then - docker run --rm --privileged tonistiigi/binfmt:latest --install "${ARCH}" - docker run -i --rm \ - -v "$(pwd)":/emqx \ - --workdir /emqx \ - --platform="linux/$ARCH" \ - "$BUILDER" \ - bash -euc "$CMD_RUN" + if [[ "${IS_NATIVE_ARCH}" == 'no' ]]; then + docker run --rm --privileged tonistiigi/binfmt:latest --install "${ARCH}" + fi + docker run -i --rm \ + -v "$(pwd)":/emqx \ + --workdir /emqx \ + --platform="linux/$ARCH" \ + "$BUILDER" \ + bash -euc "$CMD_RUN" else - echo "Error: Docker not available on unsupported platform" - exit 1; + echo "Error: Docker not available on unsupported platform" + exit 1; fi