Files
provision/scripts/plan9port.sh
2025-11-23 09:07:39 -08:00

61 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/common.sh"
PLAN9_INSTALL_DIR="/usr/local/plan9"
log_info "Installing plan9port"
if [ -d "$PLAN9_INSTALL_DIR" ] && [ -f "$PLAN9_INSTALL_DIR/bin/9" ]; then
log_success "plan9port already installed at ${PLAN9_INSTALL_DIR}"
exit 0
fi
# Install build dependencies
log_info "Installing build dependencies"
if is_macos; then
# macOS needs Xcode Command Line Tools
if ! xcode-select -p >/dev/null 2>&1; then
log_error "Xcode Command Line Tools required. Run: xcode-select --install"
exit 1
fi
elif is_debian; then
maybe_sudo apt-get install -y build-essential libx11-dev libxt-dev libxext-dev libfontconfig1-dev
elif is_arch; then
maybe_sudo pacman -S --noconfirm --needed base-devel xorg-server-devel fontconfig
fi
log_info "Cloning plan9port repository"
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
if ! git clone https://github.com/9fans/plan9port.git plan9; then
log_error "Failed to clone plan9port"
rm -rf "$TEMP_DIR"
exit 1
fi
cd plan9
log_info "Building plan9port (this may take a while)"
if ! ./INSTALL; then
log_error "Failed to build plan9port"
cd -
rm -rf "$TEMP_DIR"
exit 1
fi
log_info "Installing to ${PLAN9_INSTALL_DIR}"
cd ..
maybe_sudo mv plan9 "$PLAN9_INSTALL_DIR"
cd -
rm -rf "$TEMP_DIR"
log_success "plan9port installed to ${PLAN9_INSTALL_DIR}"
log_info "Add to environment:"
log_info " export PLAN9=${PLAN9_INSTALL_DIR}"
log_info " export PATH=\$PATH:\$PLAN9/bin"