add extra dependency installs

main
superrob1500 2025-10-12 21:37:25 +02:00
parent 0d21efef70
commit f510426c8d
1 changed files with 53 additions and 17 deletions

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
#Script to build ghostty from source. It automatically grabs required zig version binary. #Script to build ghostty from source. It automatically grabs required zig version binary.
#v1.0 #v1.0.1
set -euo pipefail set -euo pipefail
@ -27,11 +27,11 @@ command_exists() { command -v "$1" >/dev/null 2>&1; }
info() { echo "==> $*"; } info() { echo "==> $*"; }
error() { echo "ERROR: $*" >&2; exit 1; } error() { echo "ERROR: $*" >&2; exit 1; }
# Create the build directory if it doesn't exist # === Create build directory ===
mkdir -p "$BUILD_DIR" mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR" cd "$BUILD_DIR"
# === Pick version from tags === # === Version selection ===
choose_version() { choose_version() {
info "Fetching available Ghostty versions from GitHub..." info "Fetching available Ghostty versions from GitHub..."
local tags local tags
@ -78,7 +78,7 @@ resolve_zig_version() {
1.0.*|1.1.*) echo "0.13.0" ;; 1.0.*|1.1.*) echo "0.13.0" ;;
1.2.*) echo "0.14.1" ;; 1.2.*) echo "0.14.1" ;;
tip) echo "0.14.1" ;; tip) echo "0.14.1" ;;
v*) v*)
local ver="${GHOSTTY_VERSION#v}" local ver="${GHOSTTY_VERSION#v}"
case "$ver" in case "$ver" in
1.0.*|1.1.*) echo "0.13.0" ;; 1.0.*|1.1.*) echo "0.13.0" ;;
@ -90,7 +90,7 @@ resolve_zig_version() {
esac esac
} }
# === Download standalone Zig === # === Download Zig standalone binary ===
setup_zig() { setup_zig() {
local zig_version="$1" local zig_version="$1"
local os=$(uname -s | tr '[:upper:]' '[:lower:]') local os=$(uname -s | tr '[:upper:]' '[:lower:]')
@ -129,26 +129,62 @@ setup_zig() {
info "Using Zig at $(command -v zig) ($(zig version))" info "Using Zig at $(command -v zig) ($(zig version))"
} }
# === Install system deps (Linux only) === # === Install build dependencies ===
install_deps_linux() { install_deps_linux() {
if ! command_exists apt-get && ! command_exists pacman && ! command_exists dnf; then
error "No supported package manager found (apt, pacman, dnf). Install dependencies manually."
fi
local distro=""
if [ -f /etc/os-release ]; then
. /etc/os-release
distro="$ID"
fi
if command_exists apt-get; then if command_exists apt-get; then
info "Installing dependencies via apt-get..."
sudo apt-get update sudo apt-get update
sudo apt-get install -y \
git libgtk-4-dev libgtk4-layer-shell-dev libadwaita-1-dev \ # Base packages
gettext libxml2-utils pkg-config curl tar xz-utils sudo apt-get install -y git libgtk-4-dev gettext libxml2-utils pkg-config curl tar xz-utils g++
# Harfbuzz dev libraries
sudo apt-get install -y libharfbuzz-dev libharfbuzz-gobject0
# GTK Blueprint compiler
sudo apt-get install -y blueprint-compiler
# libadwaita and gtk-layer-shell packages
case "$distro" in
ubuntu)
sudo apt-get install -y libadwaita-1-dev libgtk-layer-shell-dev
;;
debian)
sudo apt-get install -y libadwaita-dev libgtk4-layer-shell-dev
;;
*)
sudo apt-get install -y libadwaita-dev libadwaita-1-dev libgtk4-layer-shell-dev libgtk-layer-shell-dev || true
;;
esac
# Verify critical pkg-config dependencies
for pkg in gtk4 adw-1 gtk4-layer-shell; do
if ! pkg-config --exists "$pkg"; then
error "Missing required development package: $pkg. Did apt-get install succeed?"
fi
done
elif command_exists pacman; then elif command_exists pacman; then
sudo pacman -Sy --noconfirm \ sudo pacman -Sy --noconfirm \
git gtk4 gtk4-layer-shell libadwaita gettext pkgconf curl tar xz git gtk4 gtk4-layer-shell libadwaita gettext pkgconf curl tar xz g++ blueprint-compiler harfbuzz
elif command_exists dnf; then elif command_exists dnf; then
sudo dnf install -y \ sudo dnf install -y \
git gtk4-devel gtk4-layer-shell-devel libadwaita-devel \ git gtk4-devel gtk4-layer-shell-devel libadwaita-devel \
gettext pkgconf curl tar xz gettext pkgconf curl tar xz g++ blueprint-compiler harfbuzz-devel
else
info "Install deps manually: git, gtk4, gtk4-layer-shell, libadwaita, gettext"
fi fi
} }
# === Clone repo and checkout version === # === Clone Ghostty repo and checkout version ===
fetch_source_git() { fetch_source_git() {
if [ ! -d "ghostty" ]; then if [ ! -d "ghostty" ]; then
git clone "$GHOSTTY_REPO" git clone "$GHOSTTY_REPO"
@ -163,14 +199,14 @@ fetch_source_git() {
fi fi
} }
# === Build & install === # === Build and install Ghostty ===
build_install() { build_install() {
zig build -Doptimize="$OPTIMIZATION" zig build -Doptimize="$OPTIMIZATION"
zig build install -p "$PREFIX" -Doptimize="$OPTIMIZATION" zig build install -p "$PREFIX" -Doptimize="$OPTIMIZATION"
info "Ghostty installed to $PREFIX/bin/ghostty" info "Ghostty installed to $PREFIX/bin/ghostty"
} }
# === Cleanup build directory === # === Clean build directory ===
cleanup_build() { cleanup_build() {
if $CLEAN_BUILD; then if $CLEAN_BUILD; then
info "Cleaning up build directory $BUILD_DIR" info "Cleaning up build directory $BUILD_DIR"
@ -193,4 +229,4 @@ main() {
cleanup_build cleanup_build
} }
main "$@" main "$@"