diff --git a/anda/misc/arrpc/anda.hcl b/anda/misc/arrpc/anda.hcl new file mode 100644 index 0000000000..00da3d6b50 --- /dev/null +++ b/anda/misc/arrpc/anda.hcl @@ -0,0 +1,5 @@ +project pkg { + rpm { + spec = "arrpc.spec" + } +} diff --git a/anda/misc/arrpc/arrpc.service b/anda/misc/arrpc/arrpc.service new file mode 100644 index 0000000000..5081e0fd29 --- /dev/null +++ b/anda/misc/arrpc/arrpc.service @@ -0,0 +1,11 @@ +[Unit] +Description=arRPC Discord RPC daemon +After=network.target + +[Service] +Type=simple +ExecStart=/usr/bin/arrpc +Restart=on-failure + +[Install] +WantedBy=default.target diff --git a/anda/misc/arrpc/arrpc.spec b/anda/misc/arrpc/arrpc.spec new file mode 100644 index 0000000000..db8461311f --- /dev/null +++ b/anda/misc/arrpc/arrpc.spec @@ -0,0 +1,53 @@ +%define debug_package %nil +%global commit c6e23e7eb733ad396d3eebc328404cc656fed581 + +Name: arrpc +Version: 3.3.0 +Release: 1%?dist +Summary: Open Discord RPC server for atypical setups +License: MIT +URL: https://arrpc.openasar.dev +Source0: https://github.com/OpenAsar/arrpc/archive/%commit.tar.gz +Source1: arrpc.service +Requires: glibc +BuildRequires: nodejs-npm systemd-rpm-macros + +%description +arRPC is an open source implementation of Discord's half-documented local RPC servers for their desktop client. +This open source implementation purely in NodeJS allows it to be used in many places where it is otherwise +impossible to do: Discord web and alternative clients like ArmCord/etc. It opens a simple bridge WebSocket +server which messages the JSON of exactly what to dispatch with in the client with no extra processing needed, +allowing small and simple mods or plugins. arRPC is experimental and a work in progress, so expect bugs, etc. + +%prep +%autosetup -n arrpc-%commit +# patch for using esbuild +sed -i -E 's@const server[^\n]+;@async function main() {\0@' src/index.js +sed -i -E 's@server\.on[^\n]+;@\0}\nmain();@' src/index.js + +%build +npm i esbuild pkg +npx esbuild --bundle --platform=node --target=node18 --outdir=dist ./src/index.js +npx pkg -t node18-linux-x64 -o arrpc ./dist/index.js + +%install +install -D -m755 arrpc %buildroot%_bindir/arrpc +install -D -m644 %SOURCE1 %buildroot%_userunitdir/arrpc.service + +%post +%systemd_user_post arrpc.service + +%preun +%systemd_user_preun arrpc.service + +%postun +%systemd_user_postun_with_restart arrpc.service + +%files +%doc README.md +%license LICENSE +%_bindir/arrpc +%_userunitdir/arrpc.service + +%changelog +%autochangelog diff --git a/anda/misc/arrpc/update.rhai b/anda/misc/arrpc/update.rhai new file mode 100644 index 0000000000..0c683bfb8a --- /dev/null +++ b/anda/misc/arrpc/update.rhai @@ -0,0 +1,2 @@ +let md = get("https://raw.githubusercontent.com/OpenAsar/arrpc/main/changelog.md"); +rpm.version(find("(?m)^## v([\\d.]+)", md, 1));