fix: add apt lock timeout and official portable scrcpy fallback across Linux and Windows

- Handle Debian/Ubuntu apt-get lock contention with DPkg::Lock::Timeout
- Decouple apt update from apt install so locks on update do not block installation
- Add official portable scrcpy v4.1 fallback download for Linux (x64/arm64) and Windows (win64)
- Add scrcpy user directories to standard PATH discovery
This commit is contained in:
somew1nd committed 2026-09-04 17:07:54 -07:00
1 parent 29622bae52
commit afbc402225
4 files changed
+149 -4

No files matched your search

+35 -1
View File
@@ -52,6 +52,7 @@ STANDARD_PATHS=(
"${HOME}/.local/bin"
"${HOME}/.local/share/node/bin"
"${HOME}/.local/share/platform-tools"
"${HOME}/.local/share/scrcpy"
"${HOME}/.cargo/bin"
"${HOME}/Library/Android/sdk/platform-tools"
"${HOME}/Android/Sdk/platform-tools"
@@ -231,7 +232,8 @@ install_system_packages() {
if has_cmd apt-get; then
echo -e " ${CYAN}Detected Debian/Ubuntu (apt-get). Synchronizing and installing...${NC}"
${SUDO_PREFIX} apt-get update -qq && ${SUDO_PREFIX} apt-get install -y "${PKGS[@]}" || true
${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=60 update -qq 2>/dev/null || true
${SUDO_PREFIX} apt-get -o DPkg::Lock::Timeout=60 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=()
@@ -249,6 +251,38 @@ install_system_packages() {
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
if ! has_cmd scrcpy; then
local SCRCPY_ARCH=""
case "${ARCH_TYPE}" in
x86_64|amd64) SCRCPY_ARCH="x86_64" ;;
aarch64|arm64) SCRCPY_ARCH="aarch64" ;;
esac
if [ -n "${SCRCPY_ARCH}" ]; then
local SCRCPY_DIR="${HOME}/.local/share/scrcpy"
if [ ! -x "${SCRCPY_DIR}/scrcpy" ]; then
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
ln -sf "${SCRCPY_DIR}/scrcpy" "${HOME}/.local/bin/scrcpy"
export PATH="${SCRCPY_DIR}:${PATH}"
echo -e " ${GREEN}✓ scrcpy installed in user space.${NC}"
fi
else
ln -sf "${SCRCPY_DIR}/scrcpy" "${HOME}/.local/bin/scrcpy"
export PATH="${SCRCPY_DIR}:${PATH}"
fi
fi
fi
# User-space fallback for adb if missing and no root privileges
if ! has_cmd adb; then
if [[ "${ARCH_TYPE}" = "x86_64" || "${ARCH_TYPE}" = "amd64" ]]; then