diff options
author | Techcable | 2022-01-02 17:17:30 -0700 |
---|---|---|
committer | Techcable | 2022-01-02 19:47:33 -0700 |
commit | 8919e49a098d66c761e39469bc31b588dd9bb9d7 (patch) | |
tree | b500f2f4ec4a3ec3c1b5f61161cebfd02b4a1762 | |
download | aur-8919e49a098d66c761e39469bc31b588dd9bb9d7.tar.gz |
Initial commit
Tested fairly thoroughly on my (Arch) laptop.
I'm not sure I like systemd anymore.
At least it's better then a bunch of old shell scripts. I think that's
what they used in the dark ages (shudder)
-rw-r--r-- | .SRCINFO | 21 | ||||
-rw-r--r-- | .gitignore | 10 | ||||
-rw-r--r-- | PKGBUILD | 61 | ||||
-rw-r--r-- | README.md | 22 | ||||
-rw-r--r-- | dis4irc-sysusers.conf | 2 | ||||
-rw-r--r-- | dis4irc.install | 10 | ||||
-rw-r--r-- | dis4irc.service | 20 | ||||
-rw-r--r-- | dis4irc.sysusers | 2 |
8 files changed, 148 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..d445f9e578c6 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,21 @@ +pkgbase = dis4irc + pkgdesc = A modern Discord <-> IRC bridge + pkgver = 1.4.2 + pkgrel = 1 + url = https://github.com/zachbr/Dis4IRC + install = dis4irc.install + arch = any + license = MIT + depends = java-runtime>=8 + options = !strip + backup = etc/dis4irc/config.hocon + source = https://github.com/zachbr/Dis4IRC/releases/download/v1.4.2/Dis4IRC-1.4.2.jar + source = https://raw.githubusercontent.com/zachbr/Dis4IRC/master/LICENSE.md + source = dis4irc-sysusers.conf + source = dis4irc.service + sha256sums = 48edcc18204b4528f23c44cb5cd2008a0dce36103422b619a95492e1a11f7ee6 + sha256sums = c32266a724ab7bf258627950a7f66563aebef1a0e1aa9ea9296b95cc900a823e + sha256sums = d8c07815db79c8e9e6d9dec5fe2bca2fe3d1ed11470f4eb232c0bce7c87e2a4d + sha256sums = 76d6b4d777da06de04b4cc82f5c2fba651d839e05fbdc68a9c75b4219c27d691 + +pkgname = dis4irc diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..99359679a1e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# PKGBUILD +pkg +src +# Finalized packages +*.pkg.tar.zst + + +# Downloded files +*.jar +LICENSE.md diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..02d4cf29274a --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,61 @@ +# Maintainer: Techcable <$USERNAME at techcable.net> + +# This package is mirored on github at Techcable/aur-dis4irc +# PRs and issues welcome + +# This package uses precompiled jar files, see README.md for justification + +pkgname=dis4irc +pkgver=1.4.2 +pkgrel=1 +pkgdesc="A modern Discord <-> IRC bridge" +arch=('any') # Java :) +url="https://github.com/zachbr/Dis4IRC" +license=('MIT') +depends=('java-runtime>=8') +# We put the config here +backup=('etc/dis4irc/config.hocon') +options=(!strip) +# We have to change the permissions on /etc/dis4irc/config.hocon +# +# to be writable by the `dis4irc` user, because Sponge's configurate +# modifies the config file +install=dis4irc.install +source=( + # It's just a github release + "https://github.com/zachbr/Dis4IRC/releases/download/v${pkgver}/Dis4IRC-${pkgver}.jar" + # License is required for MIT per the official packaging guideliness + "https://raw.githubusercontent.com/zachbr/Dis4IRC/master/LICENSE.md" + # We create a dedcicated dis4irc user + "dis4irc-sysusers.conf" + # I wrote my own systemd file (kind of overkill huh) + "dis4irc.service" +) +sha256sums=('48edcc18204b4528f23c44cb5cd2008a0dce36103422b619a95492e1a11f7ee6' + 'c32266a724ab7bf258627950a7f66563aebef1a0e1aa9ea9296b95cc900a823e' + 'd8c07815db79c8e9e6d9dec5fe2bca2fe3d1ed11470f4eb232c0bce7c87e2a4d' + '76d6b4d777da06de04b4cc82f5c2fba651d839e05fbdc68a9c75b4219c27d691') + +build() { + # Default config file doesn't exist. We have to generate it + + # remove previous default config (autogenerated) + rm -f "${srcdir}/default-config.hocon" + # Generate the configuration file by invoking the jar + # + # This will fail (without connecting to anything), but it will successfully generate the default config in the process. + java -jar "$srcdir/Dis4IRC-${pkgver}.jar" --config "${srcdir}/default-config.hocon" "$pkgdir/" > /dev/null 2>&1 || true +} + + +package() { + # Per the java packaging guidelines, we place jar files into /usr/share/java/dis4irc + install -Dm644 "$srcdir/Dis4IRC-${pkgver}.jar" "$pkgdir/usr/share/java/dis4irc/Dis4IRC.jar" + + # We install the "default" config into /etc/dis4irc/config.hocon + install -Dm644 "$srcdir/default-config.hocon" "$pkgdir/etc/dis4irc/config.hocon" + + install -Dm644 dis4irc.service "$pkgdir/usr/lib/systemd/system/dis4irc.service" + install -Dm644 dis4irc.sysusers "$pkgdir/usr/lib/sysusers.d/dis4irc.conf" + install -Dm644 "$srcdir/LICENSE.md" "$pkgdir/usr/share/licenses/dis4irc/LICENSE.md" +} diff --git a/README.md b/README.md new file mode 100644 index 000000000000..575516cfa22e --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +dis4irc-aur +=========== +This is an *unoffical* AUR package for [Dis4IRC](https://github.com/zachbr/Dis4IRC) + +It creates an isolated user and includes a systemd unit file. It downloads the binary instead of compiling it (see below). + +It is in no way endorsed by upstream, so make sure you can distinguish between their bugs and ours ;) + +Also, this is my first time mirroring an AUR package to github. + +PRs and issues are welcome. + +## Why precompiled binaries + This package uses precompiled jar files, but does *not* have the traditional `-bin` suffix in its name. + +This is because the Java packaging guidelines say "You do not need to compile Java applications from source" ([See wiki](https://wiki.archlinux.org/title/Java_package_guidelines#Java_packaging_on_Arch_Linux)). + +This is common practice even in the official Java packages. For example `jenkins` just downloads the offical jar and checks the hash. + +Compiling from source would require installing gradle (or using the wrapper) and take much longer. + + diff --git a/dis4irc-sysusers.conf b/dis4irc-sysusers.conf new file mode 100644 index 000000000000..799e7c7bda14 --- /dev/null +++ b/dis4irc-sysusers.conf @@ -0,0 +1,2 @@ +u dis4irc - "Discord to IRC Bridge" /var/lib/dis4irc /sbin/nologin + diff --git a/dis4irc.install b/dis4irc.install new file mode 100644 index 000000000000..ea7eb12f2819 --- /dev/null +++ b/dis4irc.install @@ -0,0 +1,10 @@ +post_install() { + # pacman does this automatically, but we need to do it first + # + # because otherwise chown will fail + systemd-sysusers dis4irc.conf + # NOTE: The home directory has to actually exist (sysusers doesn't do this) + mkdir -p /var/lib/dis4irc || exit 1 + chown dis4irc -R /etc/dis4irc || exit 1 + chown dis4irc -R /var/lib/dis4irc +} diff --git a/dis4irc.service b/dis4irc.service new file mode 100644 index 000000000000..81e5c57a2671 --- /dev/null +++ b/dis4irc.service @@ -0,0 +1,20 @@ +[Unit] +Description="A modern Discord <-> IRC bridge" +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/java -jar "/usr/share/java/dis4irc/Dis4IRC.jar" --config "/etc/dis4irc/config.hocon" +User=dis4irc +WorkingDirectory=/var/lib/dis4irc +# Give a little time to shutdown +TimeoutStopSec=30s +# NOTE: Dis4IRC handles SIGTERM correctly and cleanly exists (saving any data in the process) +# +# See here: https://github.com/zachbr/Dis4IRC/blob/v1.4.2/src/main/kotlin/io/zachbr/dis4irc/Dis4IRC.kt#L110-L117 +# +# As such, if it exits with a SIGTERM, then we consider it a success.. +SuccessExitStatus=143 + +[Install] +WantedBy=multi-user.target diff --git a/dis4irc.sysusers b/dis4irc.sysusers new file mode 100644 index 000000000000..799e7c7bda14 --- /dev/null +++ b/dis4irc.sysusers @@ -0,0 +1,2 @@ +u dis4irc - "Discord to IRC Bridge" /var/lib/dis4irc /sbin/nologin + |