aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-13 14:19:31 +0200
committerDanilo M. <danix@danix.xyz>2026-10-13 14:19:31 +0200
commit4f331cc9cf7cfe63c28194c7c4229429569c5099 (patch)
tree38574ea837056cc0848ea586cae371e12644bbbc
parentd6577d3a03320d55b24c69500a9880c2134ede9a (diff)
downloadmy-slackbuilds-4f331cc9cf7cfe63c28194c7c4229429569c5099.tar.gz
my-slackbuilds-4f331cc9cf7cfe63c28194c7c4229429569c5099.zip
opencode2-bin: isolate config/state with a launcher wrapper
Install the real binary as /usr/libexec/opencode2/opencode and make /usr/bin/opencode2 a wrapper that points XDG_CONFIG_HOME and XDG_DATA_HOME at opencode2-specific directories, so 2.0 does not touch the v1 opencode package's config, auth or state.
-rw-r--r--opencode2-bin/README13
-rw-r--r--opencode2-bin/opencode29
-rw-r--r--opencode2-bin/opencode2-bin.SlackBuild7
3 files changed, 21 insertions, 8 deletions
diff --git a/opencode2-bin/README b/opencode2-bin/README
index 511792d..67f16b7 100644
--- a/opencode2-bin/README
+++ b/opencode2-bin/README
@@ -12,12 +12,11 @@ The binary is compiled with Bun and is self-contained (no runtime
dependencies). The default build targets glibc x86_64 with AVX2. On a
CPU without AVX2, use the `-baseline` variant instead.
-OpenCode v1 and v2 share the same configuration and state directories
-(`~/.config/opencode`, `~/.local/share/opencode`). To test 2.0 without
-touching the v1 state, run it with an isolated XDG environment, e.g.:
-
- XDG_CONFIG_HOME=~/.config/opencode2 \
- XDG_DATA_HOME=~/.local/share/opencode2 \
- opencode2
+OpenCode v1 and v2 would otherwise share the same configuration and
+state directories (`~/.config/opencode`, `~/.local/share/opencode`).
+The `opencode2` command is therefore a wrapper that launches the real
+binary with `XDG_CONFIG_HOME` and `XDG_DATA_HOME` pointed at
+`~/.config/opencode2` and `~/.local/share/opencode2`, keeping 2.0's
+config and state separate from the v1 package.
Homepage: https://opencode.ai
diff --git a/opencode2-bin/opencode2 b/opencode2-bin/opencode2
new file mode 100644
index 0000000..5f7bc4f
--- /dev/null
+++ b/opencode2-bin/opencode2
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Launch OpenCode 2.0 with its own config and data directories, so it does
+# not read or write the v1 opencode package's ~/.config/opencode and
+# ~/.local/share/opencode. Edit the two paths below to relocate them.
+export XDG_CONFIG_HOME="$HOME/.config/opencode2"
+export XDG_DATA_HOME="$HOME/.local/share/opencode2"
+
+exec /usr/libexec/opencode2/opencode "$@"
diff --git a/opencode2-bin/opencode2-bin.SlackBuild b/opencode2-bin/opencode2-bin.SlackBuild
index 53b65f6..1dd27f1 100644
--- a/opencode2-bin/opencode2-bin.SlackBuild
+++ b/opencode2-bin/opencode2-bin.SlackBuild
@@ -67,7 +67,12 @@ find -L . \
# commands; this package ships it as `opencode2` so it can coexist with the
# v1 `opencode-bin` package. No stripping: the binary is bun-generated and
# stripping renders it unusable.
-install -D -m 0755 package/bin/opencode $PKG/usr/bin/opencode2
+#
+# The real binary goes under /usr/libexec and /usr/bin/opencode2 is a small
+# wrapper that points XDG_CONFIG_HOME/XDG_DATA_HOME at opencode2-specific
+# directories, keeping its config and state out of the v1 opencode folders.
+install -D -m 0755 package/bin/opencode $PKG/usr/libexec/opencode2/opencode
+install -D -m 0755 $CWD/opencode2 $PKG/usr/bin/opencode2
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/README > $PKG/usr/doc/$PRGNAM-$VERSION/README