#!/bin/sh # # Yaria Desktop App — FreeBSD Install Script # Usage: sh <(curl -fsSL https://yaria.live/install-freebsd.sh) # # Installs the Yaria desktop app on FreeBSD (amd64/arm64). # App binary goes to ~/bin (already in FreeBSD's default PATH). # System packages are installed with pkg/sudo when privileges allow. # # POSIX sh — FreeBSD's /bin/sh, no bash required. set -eu APP_NAME="yaria" # FreeBSD's default PATH already includes ~/bin INSTALL_DIR="${INSTALL_DIR:-$HOME/bin}" DESKTOP_DIR="$HOME/.local/share/applications" ICON_DIR="$HOME/.local/share/icons/hicolor" BASE_URL="${BASE_URL:-https://yaria.live/download}" VERSION_URL="${BASE_URL}/latest.txt" RED=''; GREEN=''; YELLOW=''; CYAN=''; PURPLE=''; NC='' if [ -t 1 ]; then RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m' CYAN='\033[0;36m'; PURPLE='\033[0;35m'; NC='\033[0m' fi info() { printf '%b\n' "${CYAN}[INFO]${NC} $1"; } ok() { printf '%b\n' "${GREEN}[OK]${NC} $1"; } warn() { printf '%b\n' "${YELLOW}[WARN]${NC} $1"; } error() { printf '%b\n' "${RED}[ERROR]${NC} $1" >&2; exit 1; } # --- Header --- printf '\n' printf ' %b\n' "${PURPLE}Yaria Desktop App Installer — FreeBSD${NC}" printf ' %b\n' "${CYAN}Video Downloader + Media Center${NC}" printf '\n' # --- Preflight: must actually be FreeBSD --- if [ "$(uname -s)" != "FreeBSD" ]; then error "This installer is for FreeBSD. On Linux use: curl -fsSL https://yaria.live/install.sh | bash" fi # --- Detect architecture --- ARCH=$(uname -m) case "$ARCH" in x86_64|amd64) ARCH_SUFFIX="amd64" ;; aarch64|arm64) ARCH_SUFFIX="arm64" ;; *) error "Unsupported architecture: $ARCH. Yaria supports x86_64 and aarch64." ;; esac info "Detected architecture: ${ARCH} (${ARCH_SUFFIX})" # --- Detect download tool --- if command -v curl >/dev/null 2>&1; then DL_OUT="curl -fsSL -o" DL_PIPE="curl -fsSL" elif command -v fetch >/dev/null 2>&1; then DL_OUT="fetch -q -o" DL_PIPE="fetch -q -o -" else error "Neither curl nor fetch found. Install one with: sudo pkg install curl" fi # --- Get latest version --- info "Checking latest version..." VERSION=$($DL_PIPE "$VERSION_URL" 2>/dev/null | tr -d '[:space:]') || true if [ -z "$VERSION" ]; then VERSION="latest" fi info "Version: ${VERSION}" DOWNLOAD_URL="${BASE_URL}/yaria-app-freebsd-${ARCH_SUFFIX}.tar.gz" # --- Download and extract --- TMP_DIR=$(mktemp -d) trap 'rm -rf "$TMP_DIR"' EXIT INT TERM info "Downloading Yaria ${VERSION}..." if ! $DL_OUT "$TMP_DIR/yaria.tar.gz" "$DOWNLOAD_URL"; then error "Download failed: $DOWNLOAD_URL If you are building from source, copy the binary next to this script and re-run." fi info "Extracting..." tar -xzf "$TMP_DIR/yaria.tar.gz" -C "$TMP_DIR" # Find the REAL ELF binary (never the shell launcher named yaria-app) BINARY="" if [ -f "$TMP_DIR/yaria-app/yaria-app.bin" ]; then BINARY="$TMP_DIR/yaria-app/yaria-app.bin" else BINARY=$(find "$TMP_DIR" -name 'yaria-app.bin' -type f 2>/dev/null | head -1) fi if [ -z "$BINARY" ]; then while IFS= read -r cand; do if file -b "$cand" 2>/dev/null | grep -qiE 'ELF|executable'; then if ! head -1 "$cand" 2>/dev/null | grep -q '^#!'; then BINARY="$cand" break fi fi done </dev/null) EOF fi if [ -z "$BINARY" ]; then BINARY=$(find "$TMP_DIR" -type f -executable ! -name '*.sh' 2>/dev/null | head -1) fi if [ -z "$BINARY" ]; then error "Could not find the Yaria binary in the archive." fi # --- Install binary + launcher --- info "Installing to ${INSTALL_DIR}..." mkdir -p "$INSTALL_DIR" cp "$BINARY" "$INSTALL_DIR/yaria-app.bin" chmod 755 "$INSTALL_DIR/yaria-app.bin" # Sanity: must be a real binary, not a shell script if head -1 "$INSTALL_DIR/yaria-app.bin" 2>/dev/null | grep -q '^#!'; then error "Install failed: binary looks like a script (package layout bug)." fi # Launcher (installs/prompts for deps on first run) LAUNCHER_SRC=$(find "$TMP_DIR" -name 'yaria-launcher-freebsd.sh' -type f 2>/dev/null | head -1) if [ -z "$LAUNCHER_SRC" ] && [ -f "$(dirname "$0")/yaria-launcher-freebsd.sh" ]; then LAUNCHER_SRC="$(dirname "$0")/yaria-launcher-freebsd.sh" fi if [ -n "$LAUNCHER_SRC" ]; then cp "$LAUNCHER_SRC" "$INSTALL_DIR/yaria-app" chmod 755 "$INSTALL_DIR/yaria-app" ok "Launcher + binary installed: ${INSTALL_DIR}/yaria-app" else cp "$BINARY" "$INSTALL_DIR/yaria-app" chmod 755 "$INSTALL_DIR/yaria-app" warn "Launcher not found in archive — installed the binary directly." warn "WebKitGTK will not be auto-installed on first run." fi # Shared dependency helpers DEPS_SRC=$(find "$TMP_DIR" -name 'freebsd-deps.sh' -type f 2>/dev/null | head -1) if [ -z "$DEPS_SRC" ] && [ -f "$(dirname "$0")/freebsd-deps.sh" ]; then DEPS_SRC="$(dirname "$0")/freebsd-deps.sh" fi if [ -n "$DEPS_SRC" ]; then cp "$DEPS_SRC" "$INSTALL_DIR/freebsd-deps.sh" chmod 644 "$INSTALL_DIR/freebsd-deps.sh" ok "Dependency helper installed: ${INSTALL_DIR}/freebsd-deps.sh" fi # --- Ensure ~/bin is in PATH --- case ":$PATH:" in *":$INSTALL_DIR:"*) ;; *) warn "$INSTALL_DIR is not in your PATH" printf '\n Add it by running:\n' printf ' %b\n' "${CYAN}echo 'export PATH=\"\$HOME/bin:\$PATH\"' >> ~/.shrc${NC}" printf ' %b\n\n' "${CYAN}. ~/.shrc${NC}" ;; esac # --- Desktop entry --- info "Installing desktop entry..." mkdir -p "$DESKTOP_DIR" cat > "$DESKTOP_DIR/yaria.desktop" </dev/null | head -1) if [ -n "$ICON_SRC" ]; then ICON_SRC_DIR=$(dirname "$ICON_SRC") for size in 16 32 48 64 128 256 512; do ICON_FILE="${ICON_SRC_DIR}/yaria-${size}.png" if [ -f "$ICON_FILE" ]; then DEST_DIR="${ICON_DIR}/${size}x${size}/apps" mkdir -p "$DEST_DIR" cp "$ICON_FILE" "$DEST_DIR/yaria.png" fi done else for size in 48 128 256; do DEST_DIR="${ICON_DIR}/${size}x${size}/apps" mkdir -p "$DEST_DIR" $DL_OUT "$DEST_DIR/yaria.png" "${BASE_URL}/icons/yaria-${size}.png" 2>/dev/null || true done fi # FreeBSD has no gtk-update-icon-cache binary; rely on XDG hicolor lookup. ok "Icons installed" # --- System dependencies --- printf '\n' info "Checking system dependencies..." # Load helpers (installed copy first, then the ones next to this script) for cand in "$INSTALL_DIR/freebsd-deps.sh" "$(dirname "$0")/freebsd-deps.sh"; do if [ -f "$cand" ]; then # shellcheck disable=SC1090 . "$cand" break fi done if ! command -v yaria_have_webkit >/dev/null 2>&1; then # Minimal inline fallback so the installer still works standalone. yaria_have_webkit() { [ -e /usr/local/lib/libwebkit2gtk-4.1.so ]; } yaria_have_gtk3() { [ -e /usr/local/lib/libgtk-3.so.0 ]; } yaria_have_ffmpeg() { command -v ffmpeg >/dev/null 2>&1; } yaria_have_python() { command -v python3 >/dev/null 2>&1; } yaria_have_aria2() { command -v aria2c >/dev/null 2>&1; } yaria_have_mpv() { command -v mpv >/dev/null 2>&1; } yaria_deps_summary() { :; } yaria_deps_install_help() { cat <<'HELP' Required: sudo pkg install webkit2-gtk_41 gtk3 dbus ffmpeg python3 Optional: sudo pkg install aria2 mpv HELP } fi if ! yaria_have_webkit; then info "Installing WebKitGTK (one-time)…" if yaria_install_webkit && yaria_have_webkit; then ok "WebKitGTK installed" else warn "WebKitGTK still missing — Yaria cannot start without it." fi else ok "WebKitGTK found" fi # Media toolchain. aria2/mpv are optional; ffmpeg/python3 are needed for # downloading, but only block if absent. MISSING_MEDIA="" command -v ffmpeg >/dev/null 2>&1 || MISSING_MEDIA="$MISSING_MEDIA ffmpeg" command -v python3 >/dev/null 2>&1 || MISSING_MEDIA="$MISSING_MEDIA python3" command -v aria2c >/dev/null 2>&1 || MISSING_MEDIA="$MISSING_MEDIA aria2" command -v mpv >/dev/null 2>&1 || MISSING_MEDIA="$MISSING_MEDIA mpv" if [ -n "$MISSING_MEDIA" ]; then if [ "$(id -u)" -eq 0 ] || command -v sudo >/dev/null 2>&1; then info "Installing media tools (one-time)…" yaria_install_media 2>/dev/null || \ warn "Could not install automatically — run: sudo pkg install$MISSING_MEDIA" else warn "Missing media tools — run: sudo pkg install$MISSING_MEDIA" fi fi printf '\n' yaria_deps_summary printf '\n' if yaria_missing_required; then warn "Some required dependencies are still missing." yaria_deps_install_help >&2 fi # --- Notes --- printf '\n' printf ' %b\n' "${YELLOW}Notes:${NC}" printf ' %b\n' "• App installs to ${INSTALL_DIR} — no root needed." printf ' %b\n' "• WebKitGTK is required for the UI; installed above when possible." printf ' %b\n' "• aria2c is OPTIONAL — it only enables multi-connection downloads." printf ' %b\n' " Without it Yaria uses yt-dlp's native downloader (slower, works fine)." printf ' %b\n' " Install it with: sudo pkg install aria2" printf ' %b\n' "• FFmpeg is needed to merge separate video+audio into one file:" printf ' %b\n' " sudo pkg install ffmpeg" printf ' %b\n' "• Python 3 runs the yt-dlp engine: sudo pkg install python3" printf ' %b\n' "• Yaria cannot self-install aria2/ffmpeg on FreeBSD: no static builds" printf ' %b\n' " are published for FreeBSD and pkg needs root." printf ' %b\n' "• yt-dlp itself IS auto-downloaded into ~/.yaria/dependencies." printf '\n' # --- Done --- printf '\n' printf ' %b\n' "${GREEN}Yaria installed successfully!${NC}" printf '\n' printf ' Launch from your app drawer or run: %b\n' "${CYAN}yaria-app${NC}" printf '\n' printf ' %b\n' "${PURPLE}Activate Pro:${NC} Enter your license key in Settings" printf ' %b\n' "${PURPLE}Get a key:${NC} https://yaria.live" printf '\n'