From bdc0d0a2a6a19ee5bc4a6c2c40932ffd35f52fd8 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Mon, 3 Jun 2019 11:24:16 +0200 Subject: [PATCH] Add custom rabbitmq-server build --- _build/build-all.sh | 4 + apk/rabbitmq-server/APKBUILD | 82 +++++++++++++++++++ apk/rabbitmq-server/rabbitmq-server.initd | 42 ++++++++++ apk/rabbitmq-server/rabbitmq-server.logrotate | 12 +++ .../rabbitmq-server.post-deinstall | 5 ++ .../rabbitmq-server.pre-install | 6 ++ 6 files changed, 151 insertions(+) create mode 100644 apk/rabbitmq-server/APKBUILD create mode 100644 apk/rabbitmq-server/rabbitmq-server.initd create mode 100644 apk/rabbitmq-server/rabbitmq-server.logrotate create mode 100644 apk/rabbitmq-server/rabbitmq-server.post-deinstall create mode 100644 apk/rabbitmq-server/rabbitmq-server.pre-install diff --git a/_build/build-all.sh b/_build/build-all.sh index 49db7e3..844d9e7 100755 --- a/_build/build-all.sh +++ b/_build/build-all.sh @@ -27,6 +27,10 @@ abuild -F cd ${ROOT}/apk/proj4 abuild -F +cd ${ROOT}/apk/rabbitmq-server +apk add erlang-dev python2 py2-simplejson xmlto libxslt rsync zip gawk grep erlang-compiler erlang-erl-docgen erlang-edoc socat elixir +abuild -F + cd ${ROOT}/apk/postgis apk add postgresql-dev libxml2-dev perl-dev json-c-dev pcre-dev postgresql perl apk add --repository /srv/build/apk geos-dev gdal-dev proj4-dev diff --git a/apk/rabbitmq-server/APKBUILD b/apk/rabbitmq-server/APKBUILD new file mode 100644 index 0000000..035729e --- /dev/null +++ b/apk/rabbitmq-server/APKBUILD @@ -0,0 +1,82 @@ +# Contributor: Nathan Johnson +# Maintainer: Nathan Johnson +pkgname=rabbitmq-server +pkgver=3.7.11 +pkgrel=0 +pkgdesc="RabbitMQ is an open source multi-protocol messaging broker." +url="https://www.rabbitmq.com/" +arch="noarch !s390x" +license="MPL-1.1" +depends="erlang erlang-tools erlang-runtime-tools erlang-stdlib + logrotate erlang-ssl erlang-crypto erlang-parsetools + erlang-mnesia erlang-sasl erlang-inets erlang-syntax-tools + erlang-eldap erlang-xmerl erlang-os-mon erlang-asn1 erlang-public-key" +depends_dev="" +makedepends="$depends_dev erlang-dev python2 py2-simplejson xmlto libxslt + rsync zip gawk grep erlang-compiler erlang-erl-docgen + erlang-edoc socat elixir" +install="$pkgname.pre-install $pkgname.post-deinstall" +pkgusers="rabbitmq" +pkggroups="rabbitmq" +subpackages="$pkgname-doc" +source=" + rabbitmq-server.initd + rabbitmq-server.logrotate + https://github.com/rabbitmq/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.xz +" + +builddir="$srcdir/${pkgname}-${pkgver}" +build() { + cd "$builddir" + make dist manpages +} + +package() { + cd "$builddir" + + make install install-bin install-man DESTDIR="$pkgdir" PREFIX=/usr \ + RMQ_ROOTDIR="/usr/lib/rabbitmq" MANDIR=/usr/share/man + + mkdir -p "$pkgdir"/var/lib/rabbitmq/mnesia + mkdir -p "$pkgdir"/var/log/rabbitmq + + #Copy all necessary lib files etc. + install -p -m755 -D "$builddir"/scripts/rabbitmq-server.ocf \ + "$pkgdir"/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server || return 1 + install -p -m755 -D "$builddir"/scripts/rabbitmq-server-ha.ocf \ + "$pkgdir"/usr/lib/ocf/resource.d/rabbitmq/rabbitmq-server-ha \ + || return 1 + install -p -m644 -D "$srcdir/"$pkgname.logrotate \ + "$pkgdir"/etc/logrotate.d/rabbitmq-server || return 1 + install -m755 -D "$srcdir"/$pkgname.initd \ + "$pkgdir"/etc/init.d/$pkgname || return 1 + mkdir -p "$pkgdir"/usr/sbin + + # This is lifted / adapted from the official upstream spec file. + # I'd prefer a patch file, but this is probably a little easier + # to manage since this is how they do it upstream. inb4eww + sed -e 's|@SU_RABBITMQ_SH_C@|su rabbitmq -s /bin/sh -c|' \ + -e 's|@STDOUT_STDERR_REDIRECTION@||' \ + < "$builddir"/scripts/rabbitmq-script-wrapper \ + > "$pkgdir"/usr/sbin/rabbitmqctl + + chmod 0755 "$pkgdir"/usr/sbin/rabbitmqctl + for script in rabbitmq-server rabbitmq-plugins; do + cp -a "$pkgdir"/usr/sbin/rabbitmqctl \ + "$pkgdir"/usr/sbin/$script; + done + + mkdir -p "$pkgdir"/usr/share/doc/"$pkgname" + cp -a "$builddir"/LICENSE* "$pkgdir"/usr/share/doc/"$pkgname"/ + cp -a "$builddir"/deps/rabbit/docs/* "$pkgdir"/usr/share/doc/"$pkgname"/ + cp -a "$builddir"/deps/rabbitmq_sharding/docs/* "$pkgdir"/usr/share/doc/"$pkgname"/ + chmod 755 "$pkgdir"/var/lib/rabbitmq + chmod 750 "$pkgdir"/var/lib/rabbitmq/mnesia + chmod 755 "$pkgdir"/var/log/rabbitmq + chown -R $pkgusers:$pkggroups "$pkgdir"/var/lib/rabbitmq + chown -R $pkgusers:$pkggroups "$pkgdir"/var/log/rabbitmq +} + +sha512sums="a8bb02a7cae1f8720e5c7aaabfe6a2c0e731cffbe0d8f99bdcb6597daa654dc49e6d41943974601435700cf469eaa8286dc91a3255a6b9023754c3861fbb5cd9 rabbitmq-server.initd +b8655cb048ab3b32001d4e6920bb5366696f3a5da75c053605e9b270e771c548e36858dca8338813d34376534515bba00af5e6dd7b4b1754a0e64a8fb756e3f3 rabbitmq-server.logrotate +a54034ebc919be0c6f58832ea5d47f8e3964e30ca9185c59bf882c3dc17d1df5b6e1ab0460f75e8cf0cc325504cc3a674f7cb44a5d7613e16a5ad8b721a286a4 rabbitmq-server-3.7.11.tar.xz" diff --git a/apk/rabbitmq-server/rabbitmq-server.initd b/apk/rabbitmq-server/rabbitmq-server.initd new file mode 100644 index 0000000..caca994 --- /dev/null +++ b/apk/rabbitmq-server/rabbitmq-server.initd @@ -0,0 +1,42 @@ +#!/sbin/openrc-run + +pidfile=/run/rabbitmq/rabbitmq.pid +name=rabbitmq +daemon=/usr/sbin/rabbitmq-server + +startup_log=/var/log/rabbitmq/startup_log +startup_err=/var/log/rabbitmq/startup_err +shutdown_log=/var/log/rabbitmq/shutdown_log +shutdown_err=/var/log/rabbitmq/shutdown_err + +depend() { + need net localmount + after firewall +} + +start() { + ebegin "Starting ${name}" + # We need to test if /var/run/rabbitmq exists, since scirpt will fail if it does not + checkpath -m 700 -o rabbitmq:rabbitmq -d "$(dirname "$pidfile")" + checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $startup_log + checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $startup_err + start-stop-daemon --start \ + --env RABBITMQ_PID_FILE=$pidfile \ + --pidfile $pidfile \ + --stdout $startup_log \ + --stderr $startup_err \ + --background $daemon + eend $? +} + +stop() { + ebegin "Stopping ${name}" + checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $shutdown_log + checkpath -m 644 -o rabbitmq:rabbitmq --file-truncate -f $shutdown_err + start-stop-daemon --stop --quiet --pidfile $pidfile \ + --exec /bin/sh -- -c "/usr/sbin/rabbitmqctl \ + --stop $pidfile > $shutdown_log \ + 2> $shutdown_err" + eend $? +} + diff --git a/apk/rabbitmq-server/rabbitmq-server.logrotate b/apk/rabbitmq-server/rabbitmq-server.logrotate new file mode 100644 index 0000000..f902ed1 --- /dev/null +++ b/apk/rabbitmq-server/rabbitmq-server.logrotate @@ -0,0 +1,12 @@ +/var/log/rabbitmq/*.log { + weekly + missingok + rotate 20 + compress + delaycompress + notifempty + sharedscripts + postrotate + /usr/sbin/rabbitmqctl rotate_logs > /dev/null + endscript +} diff --git a/apk/rabbitmq-server/rabbitmq-server.post-deinstall b/apk/rabbitmq-server/rabbitmq-server.post-deinstall new file mode 100644 index 0000000..9c9ef7c --- /dev/null +++ b/apk/rabbitmq-server/rabbitmq-server.post-deinstall @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "Please manually remove the 'rabbitmq' user and group if no longer needed" >&2 + +exit 0 diff --git a/apk/rabbitmq-server/rabbitmq-server.pre-install b/apk/rabbitmq-server/rabbitmq-server.pre-install new file mode 100644 index 0000000..8e0b7ab --- /dev/null +++ b/apk/rabbitmq-server/rabbitmq-server.pre-install @@ -0,0 +1,6 @@ +#!/bin/sh + +addgroup -S rabbitmq 2>/dev/null +adduser -S -D -H -s /sbin/nologin -h /usr/lib/rabbitmq -G rabbitmq \ + -g 'RabbitMQ Server' rabbitmq 2>/dev/null +exit 0