install from native binary instead

This commit is contained in:
Christopher Cooper 2025-11-04 13:10:09 -08:00
parent 46d57c06e8
commit 51cbedfef6
3 changed files with 82 additions and 18 deletions

View file

@ -1,18 +1,23 @@
pkgbase = claude-code
pkgdesc = An agentic coding tool that lives in your terminal
pkgver = 2.0.32
pkgrel = 1
pkgrel = 2
url = https://github.com/anthropics/claude-code
arch = any
arch = x86_64
arch = aarch64
license = LicenseRef-claude-code
makedepends = npm
depends = nodejs
depends = bash
depends = glibc
optdepends = git: allow Claude to use git
optdepends = github-cli: interact with GitHub
optdepends = glab: interact with GitLab
optdepends = ripgrep: enhanced file search
noextract = claude-code-2.0.32.tgz
source = https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-2.0.32.tgz
b2sums = 54f1874bf2192cb797656cf85dd80dccc71af5e540ae9c383ec46453ff04f74387d27f129c2c284ec0c9b90f83e8b38d9ff53dd61a489662a62af4abd82bfe3b
options = !strip
source = LICENSE::https://raw.githubusercontent.com/anthropics/claude-code/refs/heads/main/LICENSE.md
sha256sums = 8b601297f77814bdd043daedb9a5ab89effad513a2ce5513c90cd12abac418a5
source_x86_64 = claude-2.0.32-x86_64::https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/2.0.32/linux-x64/claude
sha256sums_x86_64 = 3a9e90f7f6a820f158a2e83977e916ca6ce6082ad80ff038ba129cf8e519637a
source_aarch64 = claude-2.0.32-aarch64::https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/2.0.32/linux-arm64/claude
sha256sums_aarch64 = 873edc4f4daf522b8830ab871f1842fdea31912ab3c1a450d88c619d80b0d3bb
pkgname = claude-code

View file

@ -1,28 +1,43 @@
# Maintainer: Christopher Cooper <christopher@cg505.com>
# Maintainer: Jérôme Poulin <jeromepoulin@gmail.com>
pkgname=claude-code
_full_pkgname="@anthropic-ai/${pkgname}"
pkgver=2.0.32
pkgrel=1
pkgrel=2
pkgdesc="An agentic coding tool that lives in your terminal"
arch=('any')
arch=('x86_64' 'aarch64')
url="https://github.com/anthropics/claude-code"
license=('LicenseRef-claude-code')
depends=('nodejs')
makedepends=('npm')
depends=('bash' 'glibc')
# Binary is a self-contained Bun executable with embedded JS/resources - stripping breaks it
options=('!strip')
optdepends=(
'git: allow Claude to use git'
'github-cli: interact with GitHub'
'glab: interact with GitLab'
'ripgrep: enhanced file search'
)
source=("https://registry.npmjs.org/$_full_pkgname/-/$pkgname-$pkgver.tgz")
b2sums=('54f1874bf2192cb797656cf85dd80dccc71af5e540ae9c383ec46453ff04f74387d27f129c2c284ec0c9b90f83e8b38d9ff53dd61a489662a62af4abd82bfe3b')
noextract=("${pkgname}-${pkgver}.tgz")
_gcs_bucket="https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases"
source=("LICENSE::https://raw.githubusercontent.com/anthropics/claude-code/refs/heads/main/LICENSE.md")
source_x86_64=("claude-${pkgver}-x86_64::${_gcs_bucket}/${pkgver}/linux-x64/claude")
source_aarch64=("claude-${pkgver}-aarch64::${_gcs_bucket}/${pkgver}/linux-arm64/claude")
sha256sums=('8b601297f77814bdd043daedb9a5ab89effad513a2ce5513c90cd12abac418a5')
sha256sums_x86_64=('3a9e90f7f6a820f158a2e83977e916ca6ce6082ad80ff038ba129cf8e519637a')
sha256sums_aarch64=('873edc4f4daf522b8830ab871f1842fdea31912ab3c1a450d88c619d80b0d3bb')
package() {
npm install -g --prefix "${pkgdir}/usr" "${srcdir}/${pkgname}-${pkgver}.tgz"
install -Dm755 "${srcdir}/claude-${pkgver}-${CARCH}" "${pkgdir}/opt/claude-code/bin/claude"
# Install from location in pkgdir since we have noextract.
install -Dm644 "${pkgdir}/usr/lib/node_modules/@anthropic-ai/claude-code/LICENSE.md" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
# Create wrapper script that sets NPM_CONFIG_PREFIX to avoid false npm detection
install -dm755 "${pkgdir}/usr/bin"
cat > "${pkgdir}/usr/bin/claude" << 'EOF'
#!/bin/sh
# Wrapper to prevent claude from detecting /usr/bin/claude as npm-global installation
export NPM_CONFIG_PREFIX="${NPM_CONFIG_PREFIX:-/nonexistent}"
exec /opt/claude-code/bin/claude "$@"
EOF
chmod 755 "${pkgdir}/usr/bin/claude"
install -Dm644 "${srcdir}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

44
update-version.sh Executable file
View file

@ -0,0 +1,44 @@
#!/bin/bash
set -e
GCS_BUCKET="https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases"
PKGBUILD="PKGBUILD"
# Get current version from PKGBUILD
current_version=$(grep -Po '^pkgver=\K.*' "$PKGBUILD")
# Fetch stable version
new_version=$(curl -fsSL "$GCS_BUCKET/stable")
echo "Current version: $current_version"
echo "New version: $new_version"
if [ "$current_version" = "$new_version" ]; then
echo "Already up to date!"
exit 1
fi
# Download manifest
manifest=$(curl -fsSL "$GCS_BUCKET/$new_version/manifest.json")
# Extract checksums using jq
linux_x64=$(echo "$manifest" | jq -r '.platforms["linux-x64"].checksum')
linux_arm64=$(echo "$manifest" | jq -r '.platforms["linux-arm64"].checksum')
echo ""
echo "Checksums (SHA256):"
echo " linux-x64: $linux_x64"
echo " linux-arm64: $linux_arm64"
echo ""
# Update PKGBUILD
echo "Updating PKGBUILD..."
sed -i "s/^pkgver=.*/pkgver=$new_version/" "$PKGBUILD"
sed -i "s/^pkgrel=.*/pkgrel=1/" "$PKGBUILD"
sed -i "s/^sha256sums_x86_64=.*/sha256sums_x86_64=('$linux_x64')/" "$PKGBUILD"
sed -i "s/^sha256sums_aarch64=.*/sha256sums_aarch64=('$linux_arm64')/" "$PKGBUILD"
echo "Regenerating .SRCINFO..."
makepkg --printsrcinfo > .SRCINFO
echo ""
echo "Done! Updated from $current_version to $new_version"