From f66b34e047d2cf19eeac0e314a9fb62095589f8b Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sun, 13 Aug 2023 23:34:04 -0400 Subject: [PATCH] qubes-db-vm: initial import from user-aports --- qubes-db-vm/0001-create_pidfile.patch | 50 +++++++++++++++++++++++++++ qubes-db-vm/0001-musl-build.patch | 37 ++++++++++++++++++++ qubes-db-vm/APKBUILD | 50 +++++++++++++++++++++++++++ qubes-db-vm/qubes-db.openrc | 19 ++++++++++ 4 files changed, 156 insertions(+) create mode 100644 qubes-db-vm/0001-create_pidfile.patch create mode 100644 qubes-db-vm/0001-musl-build.patch create mode 100644 qubes-db-vm/APKBUILD create mode 100644 qubes-db-vm/qubes-db.openrc diff --git a/qubes-db-vm/0001-create_pidfile.patch b/qubes-db-vm/0001-create_pidfile.patch new file mode 100644 index 0000000..947f45c --- /dev/null +++ b/qubes-db-vm/0001-create_pidfile.patch @@ -0,0 +1,50 @@ +From d20a9db122608e0992c9ab6f675920d4bb1ee88f Mon Sep 17 00:00:00 2001 +From: "build@apk-groulx" +Date: Fri, 4 Mar 2022 22:50:19 +0000 +Subject: [PATCH 1/1] create_pidfile + +--- + daemon/db-daemon.c | 11 +++-------- + 1 file changed, 3 insertions(+), 8 deletions(-) + +diff --git a/daemon/db-daemon.c b/daemon/db-daemon.c +index 9934d16..2b28995 100644 +--- a/daemon/db-daemon.c ++++ b/daemon/db-daemon.c +@@ -618,11 +618,8 @@ int create_pidfile(struct db_daemon_data *d) { + mode_t old_umask; + struct stat stat_buf; + +- /* do not create pidfile for VM daemon - service is managed by systemd */ +- if (!d->remote_name) +- return 1; + snprintf(pidfile_name, sizeof(pidfile_name), +- "/var/run/qubes/qubesdb.%s.pid", d->remote_name); ++ "/var/run/qubes/qubes-db.pid"); + + old_umask = umask(0002); + pidfile = fopen(pidfile_name, "w"); +@@ -643,10 +640,8 @@ void remove_pidfile(struct db_daemon_data *d) { + struct stat stat_buf; + + /* no pidfile for VM daemon - service is managed by systemd */ +- if (!d->remote_name) +- return; + snprintf(pidfile_name, sizeof(pidfile_name), +- "/var/run/qubes/qubesdb.%s.pid", d->remote_name); ++ "/var/run/qubes/qubes-db.pid"); + + if (stat(pidfile_name, &stat_buf) == 0) { + /* remove pidfile only if it's the one created this process */ +@@ -754,7 +749,7 @@ int fuzz_main(int argc, char **argv) { + exit(1); + case 0: + close(ready_pipe[0]); +- snprintf(log_path, sizeof(log_path), "/var/log/qubes/qubesdb.%s.log", d.remote_name); ++ snprintf(log_path, sizeof(log_path), "/var/log/qubes/qubes-db.log"); + + close(0); + old_umask = umask(0); +-- +2.34.1 + diff --git a/qubes-db-vm/0001-musl-build.patch b/qubes-db-vm/0001-musl-build.patch new file mode 100644 index 0000000..8619e8e --- /dev/null +++ b/qubes-db-vm/0001-musl-build.patch @@ -0,0 +1,37 @@ +From 24fd21fe10476a83d9dee30cf2ef9dbb8b238730 Mon Sep 17 00:00:00 2001 +From: "build@apk-groulx" +Date: Sat, 26 Feb 2022 21:05:26 +0000 +Subject: [PATCH 1/1] musl-build.patch + +--- + client/qdb-client.c | 1 + + daemon/db-daemon.c | 1 + + 2 files changed, 2 insertions(+) + +diff --git a/client/qdb-client.c b/client/qdb-client.c +index 77f6566..e289019 100644 +--- a/client/qdb-client.c ++++ b/client/qdb-client.c +@@ -17,6 +17,7 @@ + + #include + #include ++#include + + #define MAX_FILE_NAME 256 + +diff --git a/daemon/db-daemon.c b/daemon/db-daemon.c +index 9934d16..2f35f00 100644 +--- a/daemon/db-daemon.c ++++ b/daemon/db-daemon.c +@@ -37,6 +37,7 @@ struct thread_param { + #include "buffer.h" + #include + #include "qubesdb_internal.h" ++#include + + int init_vchan(struct db_daemon_data *d); + +-- +2.35.1 + diff --git a/qubes-db-vm/APKBUILD b/qubes-db-vm/APKBUILD new file mode 100644 index 0000000..eb62b7e --- /dev/null +++ b/qubes-db-vm/APKBUILD @@ -0,0 +1,50 @@ +# Maintainer: Antoine Martin (ayakael) +# Contributor: Antoine Martin (ayakael) + +pkgname=qubes-db-vm +subpackages="$pkgname-openrc" +pkgver=4.1.15 +pkgrel=0 +_gittag="v$pkgver" +pkgdesc="QubesDB libs and daemon service." +arch="x86_64" +url="https://github.com/QubesOS/qubes-core-qubesdb" +license='GPL' +options="!check" # No testsuite +depends="python3" +makedepends=" + python3-dev + qubes-libvchan-xen-dev + qubes-libvchan-xen + " +source=" + $pkgname-$_gittag.tar.gz::https://github.com/QubesOS/qubes-core-qubesdb/archive/refs/tags/$_gittag.tar.gz + 0001-musl-build.patch + 0001-create_pidfile.patch + qubes-db.openrc + " +builddir="$srcdir"/qubes-core-qubesdb-$pkgver +subpackages="$pkgname-dev" + +build() { + # Build all with python bindings + CFLAGS="$CFLAGS -Wno-implicit-function-declaration" make all BACKEND_VMM=xen SYSTEMD=0 + + # replace all shebangs with /bin/sh as qubes expects bash + # shellcheck disable=SC2013 + for i in $(grep '/bin/sh' -Rl .); do + sed -i 's|/bin/sh|/bin/bash|' "$i" + done +} + +package() { + # Install all with python bindings + make install DESTDIR=$pkgdir LIBDIR=/usr/lib BINDIR=/usr/bin SBINDIR=/sbin + install -Dm 755 "$srcdir"/qubes-db.openrc "$pkgdir"/etc/init.d/qubes-db +} +sha512sums=" +13f67292c4ae1f143b2b3b7a3e57727de84b961559a0094f594ff379df27a4e078ab1473062e3ef0662f2174131237890fdaa3d54d041d6f66a901dd516732ec qubes-db-vm-v4.1.15.tar.gz +af86268c264c843b94f9cefb735b9d078dc58819c890fc0a31dd79fa2761d3c2fa87aed73752bca1db07948ba86ecfe16a745b19672ccc10dfb9461df24aa207 0001-musl-build.patch +ffe9ea8f65b4e164c3a0d1c8762d1e3b39de3799ae3e63f825457d52de49c6522820950e6262deaa9235ad97cd7c60bf1c9a077fff716c4ca9dbd688e9a73c91 0001-create_pidfile.patch +3d87f82d3637cf10bf1a3058ebbd2590ab17f65d1b49058f62d892f126635497abd5045f6797bc8069e5de08bb6e08fc6146deb6422090ad02122764cc6d72f0 qubes-db.openrc +" diff --git a/qubes-db-vm/qubes-db.openrc b/qubes-db-vm/qubes-db.openrc new file mode 100644 index 0000000..0d6bf0c --- /dev/null +++ b/qubes-db-vm/qubes-db.openrc @@ -0,0 +1,19 @@ +#!/sbin/openrc-run + +name=$RC_SVCNAME +cfgfile="/etc/qubes/$RC_SVCNAME.conf" +command="/sbin/qubesdb-daemon" +command_args="0" +command_user="root" +pidfile="/run/qubes/$RC_SVCNAME.pid" +start_stop_daemon_args="" +command_background="true" +output_log="/var/log/qubes/$RC_SVCNAME.log" +error_log="/var/log/qubes/$RC_SVCNAME.err" + +start_pre() { + checkpath --directory --owner $command_user:qubes --mode 0775 \ + /run/qubes \ + /var/log/qubes \ + /var/run/qubes +}