|
|
@@ -131,7 +131,34 @@ if (!Script.preview) {
|
|
|
"",
|
|
|
"package() {",
|
|
|
` cd "opencode-\${pkgver}/packages/opencode"`,
|
|
|
- ' install -Dm755 $(find dist/*/bin/opencode) "${pkgdir}/usr/bin/opencode"',
|
|
|
+ ' mkdir -p "${pkgdir}/usr/bin"',
|
|
|
+ ' arch="x64"',
|
|
|
+ ' case "$CARCH" in',
|
|
|
+ ' x86_64) arch="x64" ;;',
|
|
|
+ ' aarch64) arch="arm64" ;;',
|
|
|
+ ' *) printf "unsupported architecture: %s\\n" "$CARCH" >&2 ; return 1 ;;',
|
|
|
+ " esac",
|
|
|
+ ' libc=""',
|
|
|
+ " if command -v ldd >/dev/null 2>&1; then",
|
|
|
+ " if ldd --version 2>&1 | grep -qi musl; then",
|
|
|
+ ' libc="-musl"',
|
|
|
+ " fi",
|
|
|
+ " fi",
|
|
|
+ ' if [ -z "$libc" ] && ls /lib/ld-musl-* >/dev/null 2>&1; then',
|
|
|
+ ' libc="-musl"',
|
|
|
+ " fi",
|
|
|
+ ' base=""',
|
|
|
+ ' if [ "$arch" = "x64" ]; then',
|
|
|
+ " if ! grep -qi avx2 /proc/cpuinfo 2>/dev/null; then",
|
|
|
+ ' base="-baseline"',
|
|
|
+ " fi",
|
|
|
+ " fi",
|
|
|
+ ' bin="dist/opencode-linux-${arch}${base}${libc}/bin/opencode"',
|
|
|
+ ' if [ ! -f "$bin" ]; then',
|
|
|
+ ' printf "unable to find binary for %s%s%s\\n" "$arch" "$base" "$libc" >&2',
|
|
|
+ " return 1",
|
|
|
+ " fi",
|
|
|
+ ' install -Dm755 "$bin" "${pkgdir}/usr/bin/opencode"',
|
|
|
"}",
|
|
|
"",
|
|
|
].join("\n")
|