From 460028948190e2ded035459953bb6efba960a111 Mon Sep 17 00:00:00 2001 From: madomado Date: Mon, 29 Apr 2024 21:33:35 +0800 Subject: [PATCH 1/3] fix: arrpc Add suppport for esbuild / node20 Close #1114 --- .../misc/arrpc/0001-fix-support-esbuild.patch | 31 ++++++++++ anda/misc/arrpc/arrpc.spec | 9 +-- anda/tools/git-sizer/anda.hcl | 5 ++ .../git-sizer/golang-github-git-sizer.spec | 60 +++++++++++++++++++ anda/tools/git-sizer/update.rhai | 1 + 5 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 anda/misc/arrpc/0001-fix-support-esbuild.patch create mode 100644 anda/tools/git-sizer/anda.hcl create mode 100644 anda/tools/git-sizer/golang-github-git-sizer.spec create mode 100644 anda/tools/git-sizer/update.rhai diff --git a/anda/misc/arrpc/0001-fix-support-esbuild.patch b/anda/misc/arrpc/0001-fix-support-esbuild.patch new file mode 100644 index 0000000000..28e7183fae --- /dev/null +++ b/anda/misc/arrpc/0001-fix-support-esbuild.patch @@ -0,0 +1,31 @@ +From db29e1ce9f1a2b6b2ac3ef9df8b8b8524ab895f9 Mon Sep 17 00:00:00 2001 +From: madomado +Date: Mon, 29 Apr 2024 21:29:01 +0800 +Subject: [PATCH] fix: support esbuild + +--- + src/process/index.js | 8 +------- + 1 file changed, 1 insertion(+), 7 deletions(-) + +diff --git a/src/process/index.js b/src/process/index.js +index 97ea651..f5486ca 100644 +--- a/src/process/index.js ++++ b/src/process/index.js +@@ -1,13 +1,7 @@ + const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`; + const log = (...args) => console.log(`[${rgb(88, 101, 242, 'arRPC')} > ${rgb(237, 66, 69, 'process')}]`, ...args); + +-import fs from 'node:fs'; +-import { dirname, join } from 'path'; +-import { fileURLToPath } from 'url'; +- +-const __dirname = dirname(fileURLToPath(import.meta.url)); +-const DetectableDB = JSON.parse(fs.readFileSync(join(__dirname, 'detectable.json'), 'utf8')); +- ++import DetectableDB from './detectable.json' with { type: "json" }; + import * as Natives from './native/index.js'; + const Native = Natives[process.platform]; + +-- +2.44.0 + diff --git a/anda/misc/arrpc/arrpc.spec b/anda/misc/arrpc/arrpc.spec index a9802da434..814fa0cd17 100644 --- a/anda/misc/arrpc/arrpc.spec +++ b/anda/misc/arrpc/arrpc.spec @@ -10,6 +10,7 @@ License: MIT URL: https://arrpc.openasar.dev Source0: https://github.com/OpenAsar/arrpc/archive/%commit.tar.gz Source1: arrpc.service +Patch0: 0001-fix-support-esbuild.patch Requires: glibc BuildRequires: nodejs-npm systemd-rpm-macros @@ -21,15 +22,15 @@ server which messages the JSON of exactly what to dispatch with in the client wi allowing small and simple mods or plugins. arRPC is experimental and a work in progress, so expect bugs, etc. %prep -%autosetup -n arrpc-%commit +%autosetup -n arrpc-%commit -p1 # 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 +npm i esbuild @yao-pkg/pkg +npx esbuild --bundle --platform=node --target=node20 --outdir=dist ./src/index.js +npx pkg -t node20-linux-x64 -o arrpc ./dist/index.js %install install -D -m755 arrpc %buildroot%_bindir/arrpc diff --git a/anda/tools/git-sizer/anda.hcl b/anda/tools/git-sizer/anda.hcl new file mode 100644 index 0000000000..13773c1ca4 --- /dev/null +++ b/anda/tools/git-sizer/anda.hcl @@ -0,0 +1,5 @@ +project pkg { + rpm { + spec = "golang-github-git-sizer.spec" + } +} diff --git a/anda/tools/git-sizer/golang-github-git-sizer.spec b/anda/tools/git-sizer/golang-github-git-sizer.spec new file mode 100644 index 0000000000..48bfdf07b0 --- /dev/null +++ b/anda/tools/git-sizer/golang-github-git-sizer.spec @@ -0,0 +1,60 @@ +# Generated by go2rpm 1.10.0 +%bcond_without check + +# https://github.com/github/git-sizer +%global goipath github.com/github/git-sizer +Version: 1.5.0 +%global commit b84ee4d41db733827387690506556739b0c02817 + +%global common_description %{expand: +Compute various size metrics for a Git repository, flagging those that might +cause problems.} + +%global golicenses LICENSE.md +%global godocs docs CODE_OF_CONDUCT.md CONTRIBUTING.md README.md + +%gometa -f + +Name: golang-github-git-sizer +Release: %autorelease +Summary: Compute various size metrics for a Git repository, flagging those that might cause problems + +License: MIT +URL: %{gourl} +Source: %{gosource} +BuildRequires: git-core + +%description %{common_description} + +%gopkg + +%prep +%goprep -A +%autopatch -p1 +go mod download + +%build +export GO111MODULE=off +go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${GO_BUILDTAGS-${BUILDTAGS-}}" -a -v -x -ldflags "${GO_LDFLAGS-${LDFLAGS-}} -B 0x$(echo "%{name}-%{version}-%{release}-${SOURCE_DATE_EPOCH:-}" | sha1sum | + cut -d ' ' -f1) -compressdwarf=false -linkmode=external -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1'" -o git-sizer . + +# -linkmode=external -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' + +%install +install -m 0755 -vd %{buildroot}%{_bindir} +install -m 0755 -vp git-sizer %{buildroot}%{_bindir}/ + +%if %{with check} +%check +%gocheck +%endif + +%files +%license LICENSE.md +%doc docs CODE_OF_CONDUCT.md CONTRIBUTING.md README.md +%{_bindir}/* + +%gopkgfiles + +%changelog +%autochangelog diff --git a/anda/tools/git-sizer/update.rhai b/anda/tools/git-sizer/update.rhai new file mode 100644 index 0000000000..09f5baa114 --- /dev/null +++ b/anda/tools/git-sizer/update.rhai @@ -0,0 +1 @@ +rpm.version(gh("github/git-sizer")); From 1f91a80a15d47464f0559145500ab39a4337b5d1 Mon Sep 17 00:00:00 2001 From: madomado Date: Mon, 29 Apr 2024 21:35:43 +0800 Subject: [PATCH 2/3] chore: remove git-sizer because that was an accident --- anda/tools/git-sizer/anda.hcl | 5 -- .../git-sizer/golang-github-git-sizer.spec | 60 ------------------- anda/tools/git-sizer/update.rhai | 1 - 3 files changed, 66 deletions(-) delete mode 100644 anda/tools/git-sizer/anda.hcl delete mode 100644 anda/tools/git-sizer/golang-github-git-sizer.spec delete mode 100644 anda/tools/git-sizer/update.rhai diff --git a/anda/tools/git-sizer/anda.hcl b/anda/tools/git-sizer/anda.hcl deleted file mode 100644 index 13773c1ca4..0000000000 --- a/anda/tools/git-sizer/anda.hcl +++ /dev/null @@ -1,5 +0,0 @@ -project pkg { - rpm { - spec = "golang-github-git-sizer.spec" - } -} diff --git a/anda/tools/git-sizer/golang-github-git-sizer.spec b/anda/tools/git-sizer/golang-github-git-sizer.spec deleted file mode 100644 index 48bfdf07b0..0000000000 --- a/anda/tools/git-sizer/golang-github-git-sizer.spec +++ /dev/null @@ -1,60 +0,0 @@ -# Generated by go2rpm 1.10.0 -%bcond_without check - -# https://github.com/github/git-sizer -%global goipath github.com/github/git-sizer -Version: 1.5.0 -%global commit b84ee4d41db733827387690506556739b0c02817 - -%global common_description %{expand: -Compute various size metrics for a Git repository, flagging those that might -cause problems.} - -%global golicenses LICENSE.md -%global godocs docs CODE_OF_CONDUCT.md CONTRIBUTING.md README.md - -%gometa -f - -Name: golang-github-git-sizer -Release: %autorelease -Summary: Compute various size metrics for a Git repository, flagging those that might cause problems - -License: MIT -URL: %{gourl} -Source: %{gosource} -BuildRequires: git-core - -%description %{common_description} - -%gopkg - -%prep -%goprep -A -%autopatch -p1 -go mod download - -%build -export GO111MODULE=off -go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${GO_BUILDTAGS-${BUILDTAGS-}}" -a -v -x -ldflags "${GO_LDFLAGS-${LDFLAGS-}} -B 0x$(echo "%{name}-%{version}-%{release}-${SOURCE_DATE_EPOCH:-}" | sha1sum | - cut -d ' ' -f1) -compressdwarf=false -linkmode=external -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1'" -o git-sizer . - -# -linkmode=external -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' - -%install -install -m 0755 -vd %{buildroot}%{_bindir} -install -m 0755 -vp git-sizer %{buildroot}%{_bindir}/ - -%if %{with check} -%check -%gocheck -%endif - -%files -%license LICENSE.md -%doc docs CODE_OF_CONDUCT.md CONTRIBUTING.md README.md -%{_bindir}/* - -%gopkgfiles - -%changelog -%autochangelog diff --git a/anda/tools/git-sizer/update.rhai b/anda/tools/git-sizer/update.rhai deleted file mode 100644 index 09f5baa114..0000000000 --- a/anda/tools/git-sizer/update.rhai +++ /dev/null @@ -1 +0,0 @@ -rpm.version(gh("github/git-sizer")); From 922399c020650591bb13a07876e38878b0080598 Mon Sep 17 00:00:00 2001 From: madomado Date: Mon, 29 Apr 2024 23:38:02 +0800 Subject: [PATCH 3/3] fix: bump release --- anda/misc/arrpc/arrpc.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anda/misc/arrpc/arrpc.spec b/anda/misc/arrpc/arrpc.spec index 814fa0cd17..f08773510a 100644 --- a/anda/misc/arrpc/arrpc.spec +++ b/anda/misc/arrpc/arrpc.spec @@ -4,7 +4,7 @@ Name: arrpc Version: 3.4.0 -Release: 1%?dist +Release: 2%?dist Summary: Open Discord RPC server for atypical setups License: MIT URL: https://arrpc.openasar.dev