Skip to content

Commit 080e296

Browse files
CybotTMclaude
andcommitted
feat(composer): switch from apt to binary installation method
Changes installation method from package_manager to dedicated binary installer. Why: - apt version lags behind (2.7.1 vs 2.8.12) - Binary installation is the official recommended method - Provides access to latest stable releases Changes: - catalog/composer.json: * install_method: package_manager → dedicated_script * Added script: install_composer.sh * Added github_repo for version tracking * Removed package manager definitions - scripts/install_composer.sh: NEW * Downloads latest stable phar from getcomposer.org * Verifies phar validity with PHP * Installs to /usr/local/bin/composer (requires sudo) * Supports COMPOSER_INSTALL_DIR env var for custom location * Provides clear error messages and installation feedback Installation: $ scripts/install_tool.sh composer update Binary will be installed to /usr/local/bin/composer which takes precedence over /usr/bin/composer (apt version), automatically preferring the newer binary installation. Reference: https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4df98e3 commit 080e296

2 files changed

Lines changed: 66 additions & 7 deletions

File tree

catalog/composer.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
{
22
"name": "composer",
3-
"install_method": "package_manager",
3+
"install_method": "dedicated_script",
44
"description": "PHP dependency manager",
55
"homepage": "https://getcomposer.org/",
6+
"github_repo": "composer/composer",
67
"binary_name": "composer",
7-
"packages": {
8-
"apt": "composer",
9-
"brew": "composer",
10-
"dnf": "composer",
11-
"pacman": "composer"
12-
}
8+
"script": "install_composer.sh",
9+
"notes": "Installed from latest stable phar (https://getcomposer.org/download/latest-stable/composer.phar). Requires PHP."
1310
}

scripts/install_composer.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
# Dedicated installer for Composer
3+
# Downloads latest stable composer.phar and installs to /usr/local/bin
4+
set -euo pipefail
5+
6+
INSTALL_DIR="${COMPOSER_INSTALL_DIR:-/usr/local/bin}"
7+
COMPOSER_URL="https://getcomposer.org/download/latest-stable/composer.phar"
8+
9+
echo "[composer] Downloading latest stable composer.phar..."
10+
11+
# Download to temp file
12+
TMP_FILE="$(mktemp)"
13+
trap "rm -f '$TMP_FILE'" EXIT
14+
15+
if ! curl -fsSL "$COMPOSER_URL" -o "$TMP_FILE"; then
16+
echo "[composer] Error: Failed to download from $COMPOSER_URL" >&2
17+
exit 1
18+
fi
19+
20+
# Verify it's a valid phar by checking version
21+
echo "[composer] Verifying downloaded phar..."
22+
if ! php "$TMP_FILE" --version >/dev/null 2>&1; then
23+
echo "[composer] Error: Downloaded file is not a valid composer.phar" >&2
24+
exit 1
25+
fi
26+
27+
# Get version
28+
COMPOSER_VERSION="$(php "$TMP_FILE" --version 2>/dev/null | head -1 || echo 'unknown')"
29+
echo "[composer] Downloaded: $COMPOSER_VERSION"
30+
31+
# Get current version
32+
CURRENT_VERSION="$(command -v composer >/dev/null 2>&1 && composer --version 2>/dev/null | head -1 || echo '<none>')"
33+
echo "[composer] Current: $CURRENT_VERSION"
34+
35+
# Install composer.phar
36+
echo "[composer] Installing to $INSTALL_DIR/composer..."
37+
38+
if [ -w "$INSTALL_DIR" ]; then
39+
# User has write access
40+
cp "$TMP_FILE" "$INSTALL_DIR/composer"
41+
chmod +x "$INSTALL_DIR/composer"
42+
elif command -v sudo >/dev/null 2>&1; then
43+
# Need sudo
44+
echo "[composer] Requires sudo to install to $INSTALL_DIR"
45+
sudo cp "$TMP_FILE" "$INSTALL_DIR/composer"
46+
sudo chmod +x "$INSTALL_DIR/composer"
47+
else
48+
echo "[composer] Error: Cannot write to $INSTALL_DIR and sudo not available" >&2
49+
echo "[composer] Try: COMPOSER_INSTALL_DIR=~/.local/bin $0" >&2
50+
exit 1
51+
fi
52+
53+
# Verify installation
54+
NEW_VERSION="$(composer --version 2>/dev/null | head -1 || echo '<failed>')"
55+
echo "[composer] Installed: $NEW_VERSION"
56+
57+
if [ "$NEW_VERSION" = "<failed>" ]; then
58+
echo "[composer] Error: Installation verification failed" >&2
59+
exit 1
60+
fi
61+
62+
echo "[composer] ✓ Installation successful"

0 commit comments

Comments
 (0)