!2 package init

From: @kang_xiao_qiang
Reviewed-by: 
Signed-off-by:
This commit is contained in:
openeuler-ci-bot 2020-09-18 10:46:20 +08:00 committed by Gitee
commit d74108a11a
15 changed files with 506 additions and 0 deletions

View File

@ -0,0 +1,29 @@
From: Lon Hohberger <lhh@redhat.com>
Date: Tue, 29 Jan 2019 11:36:11 -0500
Subject: [PATCH] force python3
Signed-off-by: Lon Hohberger <lhh@redhat.com>
diff --git a/codegen.py b/codegen.py
index dc4480a..cf93227 100755
--- a/codegen.py
+++ b/codegen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
from __future__ import print_function
diff --git a/development.post.mk b/development.post.mk
index 3f8301a..b7f960a 100644
--- a/development.post.mk
+++ b/development.post.mk
@@ -2,7 +2,7 @@
# Framing sources generation.
# --------------------------------------------------------------------
-PYTHON ?= python
+PYTHON ?= python3
CODEGEN = $(CURDIR)/codegen.py
CODEGEN_DIR ?= $(DEPS_DIR)/rabbitmq_codegen
CODEGEN_AMQP = $(CODEGEN_DIR)/amqp_codegen.py

View File

@ -0,0 +1,32 @@
From: Peter Lemenkov <lemenkov@redhat.com>
Date: Fri, 15 Jul 2016 16:01:08 +0200
Subject: [PATCH] Use proto_dist from command line
Use protocol distribution value from command line when provided instead
of always using default value (inet_tcp) when trying to check epmd.
If provided more than one protocol distribution types, then use the
first one.
Signed-off-by: Peter Lemenkov <lemenkov@redhat.com>
diff --git a/src/rabbit_nodes_common.erl b/src/rabbit_nodes_common.erl
index f06c3d0..63c35ec 100644
--- a/src/rabbit_nodes_common.erl
+++ b/src/rabbit_nodes_common.erl
@@ -80,10 +80,15 @@ do_ensure_epmd(false, Prog) ->
rabbit_log:error("ensure_epmd: unable to find executable '~s' in PATH: '~s'", [Prog, Path]);
do_ensure_epmd(Exe, _) ->
ID = rabbit_misc:random(1000000000),
+ ProtoDist = case init:get_argument(proto_dist) of
+ {ok, [Proto | _Protos]} -> Proto;
+ error -> "inet_tcp"
+ end,
Port = open_port(
{spawn_executable, Exe},
[{args, ["-boot", "no_dot_erlang",
"-sname", rabbit_misc:format("epmd-starter-~b", [ID]),
+ "-proto_dist", rabbit_misc:format("~p", [ProtoDist]),
"-noinput", "-s", "erlang", "halt"]},
exit_status, stderr_to_stdout, use_stdio]),
port_shutdown_loop(Port).

View File

@ -0,0 +1,29 @@
From: Lon Hohberger <lhh@redhat.com>
Date: Tue, 29 Jan 2019 11:36:11 -0500
Subject: [PATCH] force python3
Signed-off-by: Lon Hohberger <lhh@redhat.com>
diff --git a/codegen.py b/codegen.py
index 8b81362..4c0d714 100755
--- a/codegen.py
+++ b/codegen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python3
## The contents of this file are subject to the Mozilla Public License
## Version 1.1 (the "License"); you may not use this file except in
diff --git a/development.post.mk b/development.post.mk
index 65708db..ec905a4 100644
--- a/development.post.mk
+++ b/development.post.mk
@@ -2,7 +2,7 @@
# Framing sources generation.
# --------------------------------------------------------------------
-PYTHON ?= python
+PYTHON ?= python3
CODEGEN = $(CURDIR)/codegen.py
CODEGEN_DIR ?= $(DEPS_DIR)/rabbitmq_codegen
CODEGEN_AMQP = $(CODEGEN_DIR)/amqp_codegen.py

View File

@ -0,0 +1,134 @@
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Thu, 19 May 2016 16:04:56 +0300
Subject: [PATCH] Remove excessive sd_notify code
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 5dc1d2c2d..ec8c68596 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -365,123 +365,9 @@ load_all_apps() ->
broker_start(Apps) ->
start_loaded_apps(Apps),
- maybe_sd_notify(),
ok = rabbit_lager:broker_is_started(),
ok = log_broker_started(rabbit_plugins:strictly_plugins(rabbit_plugins:active())).
-%% Try to send systemd ready notification if it makes sense in the
-%% current environment. standard_error is used intentionally in all
-%% logging statements, so all this messages will end in systemd
-%% journal.
-maybe_sd_notify() ->
- case sd_notify_ready() of
- false ->
- io:format(standard_error, "systemd READY notification failed, beware of timeouts~n", []);
- _ ->
- ok
- end.
-
-sd_notify_ready() ->
- case {os:type(), os:getenv("NOTIFY_SOCKET")} of
- {{win32, _}, _} ->
- true;
- {_, [_|_]} -> %% Non-empty NOTIFY_SOCKET, give it a try
- sd_notify_legacy() orelse sd_notify_socat();
- _ ->
- true
- end.
-
-sd_notify_data() ->
- "READY=1\nSTATUS=Initialized\nMAINPID=" ++ os:getpid() ++ "\n".
-
-sd_notify_legacy() ->
- case code:load_file(sd_notify) of
- {module, sd_notify} ->
- SDNotify = sd_notify,
- SDNotify:sd_notify(0, sd_notify_data()),
- true;
- {error, _} ->
- false
- end.
-
-%% socat(1) is the most portable way the sd_notify could be
-%% implemented in erlang, without introducing some NIF. Currently the
-%% following issues prevent us from implementing it in a more
-%% reasonable way:
-%% - systemd-notify(1) is unstable for non-root users
-%% - erlang doesn't support unix domain sockets.
-%%
-%% Some details on how we ended with such a solution:
-%% https://github.com/rabbitmq/rabbitmq-server/issues/664
-sd_notify_socat() ->
- case sd_current_unit() of
- {ok, Unit} ->
- io:format(standard_error, "systemd unit for activation check: \"~s\"~n", [Unit]),
- sd_notify_socat(Unit);
- _ ->
- false
- end.
-
-socat_socket_arg("@" ++ AbstractUnixSocket) ->
- "abstract-sendto:" ++ AbstractUnixSocket;
-socat_socket_arg(UnixSocket) ->
- "unix-sendto:" ++ UnixSocket.
-
-sd_open_port() ->
- open_port(
- {spawn_executable, os:find_executable("socat")},
- [{args, [socat_socket_arg(os:getenv("NOTIFY_SOCKET")), "STDIO"]},
- use_stdio, out]).
-
-sd_notify_socat(Unit) ->
- try sd_open_port() of
- Port ->
- Port ! {self(), {command, sd_notify_data()}},
- Result = sd_wait_activation(Port, Unit),
- port_close(Port),
- Result
- catch
- Class:Reason ->
- io:format(standard_error, "Failed to start socat ~p:~p~n", [Class, Reason]),
- false
- end.
-
-sd_current_unit() ->
- CmdOut = os:cmd("ps -o unit= -p " ++ os:getpid()),
- case catch re:run(CmdOut, "([-.@0-9a-zA-Z]+)", [unicode, {capture, all_but_first, list}]) of
- {'EXIT', _} ->
- error;
- {match, [Unit]} ->
- {ok, Unit};
- _ ->
- error
- end.
-
-sd_wait_activation(Port, Unit) ->
- case os:find_executable("systemctl") of
- false ->
- io:format(standard_error, "'systemctl' unavailable, falling back to sleep~n", []),
- timer:sleep(5000),
- true;
- _ ->
- sd_wait_activation(Port, Unit, 10)
- end.
-
-sd_wait_activation(_, _, 0) ->
- io:format(standard_error, "Service still in 'activating' state, bailing out~n", []),
- false;
-sd_wait_activation(Port, Unit, AttemptsLeft) ->
- case os:cmd("systemctl show --property=ActiveState -- '" ++ Unit ++ "'") of
- "ActiveState=activating\n" ->
- timer:sleep(1000),
- sd_wait_activation(Port, Unit, AttemptsLeft - 1);
- "ActiveState=" ++ _ ->
- true;
- _ = Err->
- io:format(standard_error, "Unexpected status from systemd ~p~n", [Err]),
- false
- end.
-
start_it(StartFun) ->
Marker = spawn_link(fun() -> receive stop -> ok end end),
case catch register(rabbit_boot, Marker) of

View File

@ -0,0 +1,21 @@
From: John Eckersberg <jeckersb@redhat.com>
Date: Wed, 18 Feb 2015 16:11:12 -0500
Subject: [PATCH] Add systemd notification support
diff --git a/src/rabbit.erl b/src/rabbit.erl
index ec8c68596..ccec8b688 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -365,6 +365,11 @@ load_all_apps() ->
broker_start(Apps) ->
start_loaded_apps(Apps),
+ case code:load_file(sd_notify) of
+ {module, sd_notify} -> SDNotify = sd_notify,
+ SDNotify:sd_notify(0, "READY=1\nSTATUS=Initialized\nMAINPID=" ++ os:getpid() ++ "\n");
+ {error, _} -> ok
+ end,
ok = rabbit_lager:broker_is_started(),
ok = log_broker_started(rabbit_plugins:strictly_plugins(rabbit_plugins:active())).

View File

@ -0,0 +1,18 @@
From: John Eckersberg <jeckersb@redhat.com>
Date: Thu, 30 Oct 2014 14:01:08 -0400
Subject: [PATCH] Allow guest login from non-loopback connections
diff --git a/Makefile b/Makefile
index ad73ff5de..d6631f326 100644
--- a/Makefile
+++ b/Makefile
@@ -38,7 +38,7 @@ define PROJECT_ENV
{default_user_tags, [administrator]},
{default_vhost, <<"/">>},
{default_permissions, [<<".*">>, <<".*">>, <<".*">>]},
- {loopback_users, [<<"guest">>]},
+ {loopback_users, []},
{password_hashing_module, rabbit_password_hashing_sha256},
{server_properties, []},
{collect_statistics, none},

View File

@ -0,0 +1,18 @@
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Sun, 17 Jul 2016 18:42:06 +0300
Subject: [PATCH] rabbit_prelaunch must use RABBITMQ_SERVER_ERL_ARGS
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
diff --git a/scripts/rabbitmq-server b/scripts/rabbitmq-server
index 0c040b95e..6ad81afd2 100755
--- a/scripts/rabbitmq-server
+++ b/scripts/rabbitmq-server
@@ -193,6 +193,7 @@ RABBITMQ_DIST_PORT=$RABBITMQ_DIST_PORT \
-boot "${CLEAN_BOOT_FILE}" \
-noinput \
-hidden \
+ ${RABBITMQ_SERVER_ERL_ARGS} \
-s rabbit_prelaunch \
${RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS} \
${RABBITMQ_NAME_TYPE} ${RABBITMQ_PRELAUNCH_NODENAME} \

View File

@ -0,0 +1,19 @@
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Thu, 8 Feb 2018 17:06:41 +0300
Subject: [PATCH] Don't use templates
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
diff --git a/scripts/rabbitmq-script-wrapper b/scripts/rabbitmq-script-wrapper
index 9aae4f3..f658e26 100644
--- a/scripts/rabbitmq-script-wrapper
+++ b/scripts/rabbitmq-script-wrapper
@@ -79,7 +79,7 @@ exec_rabbitmq_server() {
# shellcheck source=/dev/null
. "$RABBITMQ_ENV"
- exec /usr/lib/rabbitmq/bin/rabbitmq-server "$@" @STDOUT_STDERR_REDIRECTION@
+ exec /usr/lib/rabbitmq/bin/rabbitmq-server "$@"
}
run_script_as_rabbitmq() {

View File

@ -0,0 +1,20 @@
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Tue, 7 Jan 2020 00:19:51 +0300
Subject: [PATCH] Revert "Use template in rabbitmq-script-wrapper for RabbitMQ
user and group"
This reverts commit ad99cb2524ebc5750a13c3c12203390926f7b5cb.
diff --git a/scripts/rabbitmq-script-wrapper b/scripts/rabbitmq-script-wrapper
index ad023e7..d1cffb9 100644
--- a/scripts/rabbitmq-script-wrapper
+++ b/scripts/rabbitmq-script-wrapper
@@ -45,7 +45,7 @@ maybe_fixup_erlang_cookie() {
_erlang_cookie="$_rabbitmq_home/.erlang.cookie"
if [ -f "$_erlang_cookie" ]
then
- chown @RABBITMQ_USER@:@RABBITMQ_GROUP@ "$_erlang_cookie"
+ chown rabbitmq:rabbitmq "$_erlang_cookie"
chmod 400 "$_erlang_cookie"
fi
}

12
rabbitmq-server.logrotate Normal file
View File

@ -0,0 +1,12 @@
/var/log/rabbitmq/*.log {
weekly
missingok
rotate 20
compress
delaycompress
notifempty
sharedscripts
postrotate
/usr/sbin/rabbitmqctl -q rotate_logs
endscript
}

152
rabbitmq-server.spec Normal file
View File

@ -0,0 +1,152 @@
%global erlang_minver 20
%global _rabbit_libdir %{_exec_prefix}/lib/rabbitmq
%global debug_package %{nil}
Name: rabbitmq-server
Version: 3.7.23
Release: 1
License: MPLv1.1
Source0: https://github.com/rabbitmq/rabbitmq-server/releases/download/v%{version}/rabbitmq-server_%{version}.orig.tar.xz
Source1: https://github.com/rabbitmq/rabbitmq-server/releases/download/v%{version}/rabbitmq-server_%{version}.orig.tar.xz.asc
# curl -O https://raw.githubusercontent.com/lemenkov/rabbitmq-server/cdfc661/packaging/RPMS/Fedora/rabbitmq-server.logrotate
Source3: rabbitmq-server.logrotate
# curl -O https://raw.githubusercontent.com/rabbitmq/rabbitmq-server-release/rabbitmq_v3_6_16/packaging/RPMS/Fedora/rabbitmq-server.tmpfiles
Source5: rabbitmq-server.tmpfiles
Patch1: rabbitmq-server-0001-Remove-excessive-sd_notify-code.patch
Patch2: rabbitmq-server-0002-Add-systemd-notification-support.patch
Patch3: rabbitmq-server-0003-Allow-guest-login-from-non-loopback-connections.patch
Patch4: rabbitmq-server-0004-rabbit_prelaunch-must-use-RABBITMQ_SERVER_ERL_ARGS.patch
Patch101: rabbitmq-common-0001-Use-proto_dist-from-command-line.patch
Patch102: rabbitmq-common-0002-force-python3.patch
Patch201: rabbitmq-server-release-0001-Don-t-use-templates.patch
Patch202: rabbitmq-server-release-0002-Revert-Use-template-in-rabbitmq-script-wrapper-for-R.patch
Patch301: rabbitmq-amqp1.0-common-0001-force-python3.patch
URL: https://www.rabbitmq.com/
BuildRequires: elixir erlang >= %{erlang_minver} libxslt python3 python3-simplejson rsync
BuildRequires: systemd xmlto zip
Requires: logrotate erlang-erts%{?_isa} >= %{erlang_minver}
Requires: erlang-kernel%{?_isa} >= %{erlang_minver}
Requires: erlang-eldap%{?_isa} >= %{erlang_minver}
Requires: erlang-mnesia%{?_isa} >= %{erlang_minver}
Requires: erlang-os_mon%{?_isa} >= %{erlang_minver}
Requires: erlang-public_key%{?_isa} >= %{erlang_minver}
Requires: erlang-sasl%{?_isa} >= %{erlang_minver} erlang-sd_notify%{?_isa}
Requires: erlang-ssl%{?_isa} >= %{erlang_minver}
Requires: erlang-stdlib%{?_isa} >= %{erlang_minver}
Requires: erlang-tools%{?_isa} >= %{erlang_minver}
Requires: erlang-xmerl%{?_isa} >= %{erlang_minver}
Summary: The RabbitMQ server
Requires(pre): shadow-utils
Requires(pre): systemd
Requires(post): systemd
Requires(preun): systemd
%description
RabbitMQ is an implementation of AMQP, the emerging standard for high
performance enterprise messaging. The RabbitMQ server is a robust and
scalable implementation of an AMQP broker.
%prep
%setup -q
cd deps/rabbit
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
cd ../..
cd deps/rabbit_common
%patch101 -p1
%patch102 -p1
cd ../..
%patch201 -p1
%patch202 -p1
cd deps/amqp10_common
%patch301 -p1
cd ../..
rm -f \
deps/amqp_client/src/rabbit_ct_client_helpers.erl \
deps/rabbit_common/src/rabbit_ct_broker_helpers.erl \
deps/rabbit_common/src/rabbit_ct_helpers.erl
%build
make %{?_smp_mflags} VERSION="%{version}" V=1
%install
make install \
VERSION="%{version}" \
DESTDIR=%{buildroot} \
PREFIX=%{_prefix} \
RMQ_ROOTDIR=%{_rabbit_libdir}
make install-man \
VERSION="%{version}" \
DESTDIR=%{buildroot} \
PREFIX=%{_prefix} \
RMQ_ROOTDIR=%{_rabbit_libdir}
mkdir -p %{buildroot}%{_localstatedir}/lib/rabbitmq/mnesia
mkdir -p %{buildroot}%{_localstatedir}/log/rabbitmq
install -p -D -m 0644 ./deps/rabbit/docs/rabbitmq-server.service.example %{buildroot}%{_unitdir}/%{name}.service
install -p -D -m 0755 ./scripts/rabbitmq-script-wrapper %{buildroot}%{_sbindir}/rabbitmqctl
install -p -D -m 0755 ./scripts/rabbitmq-script-wrapper %{buildroot}%{_sbindir}/rabbitmq-server
install -p -D -m 0755 ./scripts/rabbitmq-script-wrapper %{buildroot}%{_sbindir}/rabbitmq-plugins
mkdir -p %{buildroot}%{_rabbit_libdir}/bin
for app in rabbitmq-defaults rabbitmq-env rabbitmq-plugins rabbitmq-server rabbitmqctl ; do
ln -s %{_rabbit_libdir}/lib/rabbitmq_server-%{version}/sbin/${app} %{buildroot}%{_rabbit_libdir}/bin/${app}
done
install -p -D -m 0755 scripts/rabbitmq-server.ocf %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server
install -p -D -m 0755 scripts/rabbitmq-server-ha.ocf %{buildroot}%{_exec_prefix}/lib/ocf/resource.d/rabbitmq/rabbitmq-server-ha
install -p -D -m 0644 %{S:3} %{buildroot}%{_sysconfdir}/logrotate.d/rabbitmq-server
install -p -D -m 0644 ./deps/rabbit/docs/rabbitmq.config.example %{buildroot}%{_sysconfdir}/rabbitmq/rabbitmq.config
install -d %{buildroot}%{_localstatedir}/run/rabbitmq
install -p -D -m 0644 %{SOURCE5} %{buildroot}%{_prefix}/lib/tmpfiles.d/%{name}.conf
%check
%pre
if ! getent group rabbitmq >/dev/null; then
groupadd -r rabbitmq
fi
if ! getent passwd rabbitmq >/dev/null; then
useradd -r -g rabbitmq -d %{_localstatedir}/lib/rabbitmq rabbitmq \
-s /sbin/nologin -c "RabbitMQ messaging server"
fi
%post
%systemd_post %{name}.service
/bin/systemctl daemon-reload
%preun
%systemd_preun %{name}.service
rm -rf %{_localstatedir}/lib/rabbitmq/plugins
for ext in rel script boot ; do
rm -f %{_rabbit_libdir}/lib/rabbitmq_server-%{version}/ebin/rabbit.$ext
done
%postun
%systemd_postun_with_restart %{name}.service
%files
%dir %attr(0755, rabbitmq, rabbitmq) %{_sysconfdir}/rabbitmq
%config(noreplace) %attr(0644, rabbitmq, rabbitmq) %{_sysconfdir}/rabbitmq/rabbitmq.config
%config(noreplace) %{_sysconfdir}/logrotate.d/rabbitmq-server
%{_sbindir}/rabbitmqctl
%{_sbindir}/rabbitmq-server
%{_sbindir}/rabbitmq-plugins
%{_rabbit_libdir}/
%{_unitdir}/%{name}.service
%dir /usr/lib/ocf/resource.d/rabbitmq/
/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server
/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server-ha
%{_tmpfilesdir}/%{name}.conf
%dir %attr(0750, rabbitmq, rabbitmq) %{_localstatedir}/lib/rabbitmq
%dir %attr(0750, rabbitmq, rabbitmq) %{_localstatedir}/log/rabbitmq
%dir %attr(0755, rabbitmq, rabbitmq) %{_localstatedir}/run/rabbitmq
%license LICENSE LICENSE-*
%{_mandir}/man5/rabbitmq-env.conf.5*
%{_mandir}/man8/rabbitmq-diagnostics.8*
%{_mandir}/man8/rabbitmq-echopid.8*
%{_mandir}/man8/rabbitmq-plugins.8*
%{_mandir}/man8/rabbitmq-server.8*
%{_mandir}/man8/rabbitmq-service.8*
%{_mandir}/man8/rabbitmqctl.8*
%changelog
* Thu Sep 3 2020 shaoqiang kang <kangshaoqiang1@huawei.com> - 3.7.23-1
- Package init

1
rabbitmq-server.tmpfiles Normal file
View File

@ -0,0 +1 @@
D /var/run/rabbitmq 0755 rabbitmq rabbitmq -

4
rabbitmq-server.yaml Normal file
View File

@ -0,0 +1,4 @@
version_control: github
src_repo: rabbitmq/rabbitmq-server
tag_prefix: "v"
seperator: "."

Binary file not shown.

View File

@ -0,0 +1,17 @@
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABAgAGBQJd6JfNAAoJEGtzo25gJt/Kj4MP/AuPKqamP46clQrYkATFjXYj
iKaGhxO4Uls5HBYF7B1JT/SswWEMKHse5PZzg0ijn5eo+TVgG3SHpvlJWoZnB2Ig
Wss1vEsGJYetIxNH14U3uqMcl9keEe1CAA6HExkCZAXB1iDIv/Y6X2APzRN5TC7t
+5u2I61IBEpD5a4JebQbLt0IX40ITMAsaLRDcQ2+5voK034G3aQx2/5RnOdNezxn
PZY+A4ajghn6SARqiRGqKdCoqQVxC7hs+4tMGJJLDugYDvUXEFbUy1l813vEh24d
eMhe1PyzxO+eftEzxo0V/aUF2FvS9VdI2lKay2Uj27viiu8IaO/2INc478Tqybg7
lr6anz5aHq1JN9Zrniq+EeL4uPIvTnrDeAE4W3XzctMscYRNeKwvVPxSL4A4Oa+G
dTjANDRIyorJSLf5PayZh0GtKyhfGWjDmbhs6GIBLLA7cs5LAwd78+aP2NZdVyPU
6nTS4kDJ2+23ACczXiP9nyJaiAUCSFPQRnHU5X8VKlXTYtaKl7KlR8TuTii0ppi5
UWlMGUADiEkO8F1Px+C+yXrU1FXZhu3//BzQxh1NLzLTO4O4reWTHUegycyOFGfg
Bz0DxkcA2jqZzzdJ03/CEBeU5zt5VNa9DP4Pqeu3u/em0EyL48j3APYurdo7flLG
oqs3gaeRAxF1qzVaEUBD
=1rQe
-----END PGP SIGNATURE-----