From 2e43c8fa731fb30536447887463495bdf8942059 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 3 Feb 2024 12:48:06 -0500 Subject: [PATCH] backports/thelounge: new aport --- backports/thelounge/APKBUILD | 81 ++++++++++++++++++++++ backports/thelounge/no-version-test.patch | 19 +++++ backports/thelounge/thelounge.initd | 14 ++++ backports/thelounge/thelounge.post-install | 13 ++++ backports/thelounge/thelounge.pre-install | 6 ++ 5 files changed, 133 insertions(+) create mode 100644 backports/thelounge/APKBUILD create mode 100644 backports/thelounge/no-version-test.patch create mode 100644 backports/thelounge/thelounge.initd create mode 100644 backports/thelounge/thelounge.post-install create mode 100644 backports/thelounge/thelounge.pre-install diff --git a/backports/thelounge/APKBUILD b/backports/thelounge/APKBUILD new file mode 100644 index 0000000..a08de3a --- /dev/null +++ b/backports/thelounge/APKBUILD @@ -0,0 +1,81 @@ +# Contributor: Kay Thomas +# Maintainer: Kay Thomas +pkgname=thelounge +pkgver=4.4.1 +pkgrel=0 +pkgdesc="Modern, responsive, cross-platform, self-hosted web IRC client" +url="https://thelounge.chat" +# x86: textrels +# s390x: fails to check +# riscv64: fails to build +arch="all !x86 !s390x !riscv64" +license="MIT" +depends="nodejs" +makedepends="yarn npm python3" +subpackages="$pkgname-openrc" +pkgusers="thelounge" +pkggroups="thelounge" +install="$pkgname.pre-install $pkgname.post-install" +source="$pkgname-$pkgver.tar.gz::https://github.com/thelounge/thelounge/archive/v$pkgver.tar.gz + no-version-test.patch + thelounge.initd + " +options="net" # npm + +prepare() { + default_prepare + + yarn install --frozen-lockfile +} + +build() { + NODE_ENV=production yarn run build +} + +check() { + CI=yes yarn run test:mocha +} + +package() { + yarn install --production --ignore-scripts --prefer-offline + NODE_ENV=production npm install --unsafe-perm -g --prefix "$pkgdir"/usr + + # Remove incorrect symlink, copy correct files + rm "$pkgdir"/usr/lib/node_modules/thelounge + mkdir -p "$pkgdir"/usr/lib/node_modules/thelounge + cp -a index.js client public node_modules dist package.json "$pkgdir"/usr/lib/node_modules/thelounge/ + + # cleanup unused files + find "$pkgdir" -type f -a \( \ + -name "*.ts" \ + -o -name "webpack*" \ + -o -name "tsconfig*" \ + -o -name "babel.config*" \ + -o -name "README*" \ + -o -name "CHANGELOG*" \ + -o -name "*.map" \ + -o -name "LICENSE" \ + \) \ + -delete + + # Set home location + echo /var/lib/thelounge > \ + "$pkgdir"/usr/lib/node_modules/$pkgname/.thelounge_home + + # Add default config + # this is only read from 'home' so we have to just put everything in var/lib + install -dm755 -o thelounge -g thelounge \ + "$pkgdir"/var/lib/thelounge + install -m644 -o thelounge -g thelounge \ + "$pkgdir"/usr/lib/node_modules/$pkgname/dist/defaults/config.js \ + "$pkgdir"/var/lib/thelounge/config.js + + install -Dm755 "$srcdir"/$pkgname.initd \ + "$pkgdir"/etc/init.d/$pkgname +} + +sha512sums=" +7695121a713a23688bc6f52dae2574bab1288eea930fd50d4dd85037233e9f23bd8e460980c69cdd14ea8648da4720d84e8196547b6a18e69d2f478b43d6e29a thelounge-4.4.1.tar.gz +cbf80e23b0af8f0185699d6b03816c645c51b85fff7f163d3cd3d00296ed816b6ab01529b359fbfd549a79e8adb72bbc83bc7a389cf13e0afd50636ff79a138e no-version-test.patch +f367d27ebcc412ff03c12ae98e50aeae5051fb5ffa9da6220f664c59993ed0e330b55b3b41fe941d546634901163d006e318891b4b886f6c49a93e0888fccd3e thelounge.initd +" diff --git a/backports/thelounge/no-version-test.patch b/backports/thelounge/no-version-test.patch new file mode 100644 index 0000000..dfae092 --- /dev/null +++ b/backports/thelounge/no-version-test.patch @@ -0,0 +1,19 @@ +diff --git a/test/src/helperTest.ts b/test/src/helperTest.ts +index 2a8ddc8..22f0532 100644 +--- a/test/src/helperTest.ts ++++ b/test/src/helperTest.ts +@@ -40,14 +40,6 @@ describe("Helper", function () { + describe("#getVersion()", function () { + const version = Helper.getVersion(); + +- it("should mention it is served from source code", function () { +- expect(version).to.include("source"); +- }); +- +- it("should include a short Git SHA", function () { +- expect(version).to.match(/\([0-9a-f]{7,11} /); +- }); +- + it("should include a valid semver version", function () { + expect(version).to.match(/v[0-9]+\.[0-9]+\.[0-9]+/); + }); diff --git a/backports/thelounge/thelounge.initd b/backports/thelounge/thelounge.initd new file mode 100644 index 0000000..b10d1c5 --- /dev/null +++ b/backports/thelounge/thelounge.initd @@ -0,0 +1,14 @@ +#!/sbin/openrc-run + +supervisor=supervise-daemon +name="thelounge" +command="/usr/bin/thelounge" +command_args="start" +command_user="thelounge:thelounge" +command_background=true +pidfile="/run/thelounge.pid" + +depend() { + need net localmount + after firewall +} diff --git a/backports/thelounge/thelounge.post-install b/backports/thelounge/thelounge.post-install new file mode 100644 index 0000000..1651780 --- /dev/null +++ b/backports/thelounge/thelounge.post-install @@ -0,0 +1,13 @@ +#!/bin/sh + +cat >&2 <<-EOF +* +* The configuration is in /var/lib/thelounge/config.js. +* To add users, use the cli: +* doas -u thelounge thelounge .. +* e.g. +* doas -u thelounge thelounge add myuser +* +EOF + +exit 0 diff --git a/backports/thelounge/thelounge.pre-install b/backports/thelounge/thelounge.pre-install new file mode 100644 index 0000000..b91b1ef --- /dev/null +++ b/backports/thelounge/thelounge.pre-install @@ -0,0 +1,6 @@ +#!/bin/sh + +addgroup -S thelounge 2>/dev/null +adduser -S -D -H -s /sbin/nologin -G thelounge -g thelounge thelounge 2>/dev/null + +exit 0