From 739c1c290901e97dce991b77af7b76c29acf043b Mon Sep 17 00:00:00 2001 From: somew1nd Date: Fri, 4 Sep 2026 17:12:03 -0700 Subject: [PATCH] fix(start.sh): remove snap and rogue local keyword, streamline fast portable scrcpy fallback --- scripts/install_deps.sh | 20 ++++++-------------- start.sh | 19 ++++++------------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index 272bd67..6669595 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -231,34 +231,26 @@ install_system_packages() { fi if has_cmd apt-get; then - echo -e " ${CYAN}Detected Debian/Ubuntu (apt-get). Synchronizing and installing...${NC}" - ${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=5 update -qq 2>/dev/null || true - ${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=5 install -y "${PKGS[@]}" 2>/dev/null || true + echo -e " ${CYAN}Detected Debian/Ubuntu (apt-get). Installing missing packages...${NC}" + DEBIAN_FRONTEND=noninteractive ${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=3 -o Acquire::http::Timeout=3 -o Acquire::https::Timeout=3 install -y "${PKGS[@]}" 2>/dev/null || true elif has_cmd dnf; then echo -e " ${CYAN}Detected Fedora/RHEL (dnf). Installing packages...${NC}" local DNF_PKGS=() [ "${need_adb}" = true ] && DNF_PKGS+=("android-tools") [ "${need_ffmpeg}" = true ] && DNF_PKGS+=("ffmpeg") [ "${need_scrcpy}" = true ] && DNF_PKGS+=("scrcpy") - ${SUDO_PREFIX} dnf install -y "${DNF_PKGS[@]}" || true + ${SUDO_PREFIX} dnf install -y "${DNF_PKGS[@]}" 2>/dev/null || true elif has_cmd pacman; then echo -e " ${CYAN}Detected Arch Linux (pacman). Installing packages...${NC}" local PAC_PKGS=() [ "${need_adb}" = true ] && PAC_PKGS+=("android-tools") [ "${need_ffmpeg}" = true ] && PAC_PKGS+=("ffmpeg") [ "${need_scrcpy}" = true ] && PAC_PKGS+=("scrcpy") - ${SUDO_PREFIX} pacman -S --noconfirm "${PAC_PKGS[@]}" || true + ${SUDO_PREFIX} pacman -S --noconfirm "${PAC_PKGS[@]}" 2>/dev/null || true fi fi - # Fallback: if scrcpy is still missing, try snap or install portable scrcpy in user space - if ! has_cmd scrcpy; then - if has_cmd snap && request_sudo "install scrcpy via snap"; then - local SUDO_PREFIX="" - if [ "$(id -u)" -ne 0 ]; then SUDO_PREFIX="sudo"; fi - ${SUDO_PREFIX} snap install scrcpy 2>/dev/null || true - fi - fi + # Fallback: if scrcpy is still missing, install official precompiled portable scrcpy in user space if ! has_cmd scrcpy; then local SCRCPY_ARCH="" case "${ARCH_TYPE}" in @@ -271,7 +263,7 @@ install_system_packages() { echo -e " ${CYAN}📦 Installing portable scrcpy in user space (~/.local)...${NC}" mkdir -p "${SCRCPY_DIR}" "${HOME}/.local/bin" local SCRCPY_URL="https://github.com/Genymobile/scrcpy/releases/download/v4.1/scrcpy-linux-${SCRCPY_ARCH}-v4.1.tar.gz" - if curl -fsSL "${SCRCPY_URL}" | tar -xz -C "${SCRCPY_DIR}" --strip-components=1 2>/dev/null; then + if curl -fsSL --connect-timeout 5 --max-time 30 "${SCRCPY_URL}" | tar -xz -C "${SCRCPY_DIR}" --strip-components=1 2>/dev/null; then ln -sf "${SCRCPY_DIR}/scrcpy" "${HOME}/.local/bin/scrcpy" export PATH="${SCRCPY_DIR}:${PATH}" echo -e " ${GREEN}✓ scrcpy installed in user space.${NC}" diff --git a/start.sh b/start.sh index 8d3adae..47837bd 100755 --- a/start.sh +++ b/start.sh @@ -178,23 +178,16 @@ if [ ${#MISSING_CORE[@]} -gt 0 ]; then SUDO_PREFIX="" if [ "$(id -u)" -ne 0 ]; then SUDO_PREFIX="sudo"; fi if command -v apt-get >/dev/null 2>&1; then - ${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=5 update -qq 2>/dev/null || true - ${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=5 install -y -qq "${MISSING_CORE[@]}" 2>/dev/null || true + echo -e " ${CYAN}📦 Installing missing packages (${MISSING_CORE[*]}) via apt-get...${NC}" + DEBIAN_FRONTEND=noninteractive ${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=3 -o Acquire::http::Timeout=3 -o Acquire::https::Timeout=3 install -y -qq "${MISSING_CORE[@]}" 2>/dev/null || true elif command -v dnf >/dev/null 2>&1; then - ${SUDO_PREFIX} dnf install -y "${MISSING_CORE[@]}" || true + ${SUDO_PREFIX} dnf install -y "${MISSING_CORE[@]}" 2>/dev/null || true elif command -v pacman >/dev/null 2>&1; then - ${SUDO_PREFIX} pacman -S --noconfirm "${MISSING_CORE[@]}" || true + ${SUDO_PREFIX} pacman -S --noconfirm "${MISSING_CORE[@]}" 2>/dev/null || true fi fi - # Fallback: if scrcpy is still missing, try snap or install portable scrcpy in user space - if ! command -v scrcpy >/dev/null 2>&1; then - if command -v snap >/dev/null 2>&1 && request_sudo "install scrcpy via snap"; then - local SUDO_PREFIX="" - if [ "$(id -u)" -ne 0 ]; then SUDO_PREFIX="sudo"; fi - ${SUDO_PREFIX} snap install scrcpy 2>/dev/null || true - fi - fi + # Fallback: if scrcpy is still missing, install official precompiled portable scrcpy in user space if ! command -v scrcpy >/dev/null 2>&1; then ARCH="$(uname -m)" SCRCPY_ARCH="" @@ -208,7 +201,7 @@ if [ ${#MISSING_CORE[@]} -gt 0 ]; then echo -e " ${CYAN}📦 Installing portable scrcpy in user space (~/.local)...${NC}" mkdir -p "${SCRCPY_DIR}" "${HOME}/.local/bin" SCRCPY_URL="https://github.com/Genymobile/scrcpy/releases/download/v4.1/scrcpy-linux-${SCRCPY_ARCH}-v4.1.tar.gz" - if curl -fsSL "${SCRCPY_URL}" | tar -xz -C "${SCRCPY_DIR}" --strip-components=1 2>/dev/null; then + if curl -fsSL --connect-timeout 5 --max-time 30 "${SCRCPY_URL}" | tar -xz -C "${SCRCPY_DIR}" --strip-components=1 2>/dev/null; then ln -sf "${SCRCPY_DIR}/scrcpy" "${HOME}/.local/bin/scrcpy" export PATH="${SCRCPY_DIR}:${PATH}" echo -e " ${GREEN}✓ scrcpy installed in user space.${NC}"