diff --git a/src/__tests__/scripts.test.ts b/src/__tests__/scripts.test.ts index b67a06e..ed04e48 100644 --- a/src/__tests__/scripts.test.ts +++ b/src/__tests__/scripts.test.ts @@ -60,9 +60,15 @@ describe('Script Generators', () => { it('should generate apt install commands', () => { const script = generateUbuntuScript([pkg]); - expect(script).toContain('sudo apt-get update'); + expect(script).toContain('sudo apt-get -o DPkg::Lock::Timeout=60 update'); expect(script).toContain('install_pkg "Mock Official App" "mock-pkg"'); }); + + it('should use native apt lock waiting instead of wait_for_lock', () => { + const script = generateUbuntuScript([pkg]); + expect(script).toContain('DPkg::Lock::Timeout=60'); + expect(script).not.toContain('wait_for_lock /var/lib/dpkg/lock-frontend'); + }); }); describe('Flatpak Generator', () => { @@ -74,4 +80,4 @@ describe('Script Generators', () => { expect(script).toContain('install_pkg "Mock Official App" "org.mock.App"'); }); }); -}); +}); \ No newline at end of file diff --git a/src/lib/scripts/debian.ts b/src/lib/scripts/debian.ts index 5a8005b..148f851 100644 --- a/src/lib/scripts/debian.ts +++ b/src/lib/scripts/debian.ts @@ -18,7 +18,7 @@ install_pkg() { local start=$(date +%s) - with_retry sudo apt-get install -y "$pkg" & + with_retry sudo apt-get -o DPkg::Lock::Timeout=60 install -y "$pkg" & local pid=$! if animate_progress "$name" $pid; then @@ -30,8 +30,8 @@ install_pkg() { printf "\\r\\033[K" >&3 if tail -n 50 "$LOG" | grep -q "unmet dependencies"; then warn "Fixing dependencies for $name..." - if sudo apt-get --fix-broken install -y >/dev/null 2>&1; then - sudo apt-get install -y "$pkg" & + if sudo apt-get -o DPkg::Lock::Timeout=60 --fix-broken install -y >/dev/null 2>&1; then + sudo apt-get -o DPkg::Lock::Timeout=60 install -y "$pkg" & if animate_progress "$name (retry)" $!; then local elapsed=$(($(date +%s) - start)) success "$name" "\${elapsed}s, deps fixed" @@ -53,11 +53,10 @@ info "Caching sudo credentials..." sudo -v || exit 1 while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & -wait_for_lock /var/lib/dpkg/lock-frontend sudo dpkg --configure -a >/dev/null 2>&1 || true info "Updating package lists..." -with_retry sudo apt-get update -qq & +with_retry sudo apt-get -o DPkg::Lock::Timeout=60 update -qq & if animate_progress "Updating..." $!; then printf "\\r\\033[K" >&3 success "Updated" @@ -74,4 +73,4 @@ ${packages.map(({ app, pkg }) => `install_pkg "${escapeShellString(app.name)}" " print_summary `; -} +} \ No newline at end of file diff --git a/src/lib/scripts/ubuntu.ts b/src/lib/scripts/ubuntu.ts index bda9610..2ef1397 100644 --- a/src/lib/scripts/ubuntu.ts +++ b/src/lib/scripts/ubuntu.ts @@ -18,7 +18,7 @@ install_pkg() { local start=$(date +%s) - with_retry sudo apt-get install -y "$pkg" & + with_retry sudo apt-get -o DPkg::Lock::Timeout=60 install -y "$pkg" & local pid=$! if animate_progress "$name" $pid; then @@ -30,8 +30,8 @@ install_pkg() { printf "\\r\\033[K" >&3 if tail -n 50 "$LOG" | grep -q "unmet dependencies"; then warn "Fixing dependencies for $name..." >&3 - if sudo apt-get --fix-broken install -y >/dev/null 2>&1; then - sudo apt-get install -y "$pkg" & + if sudo apt-get -o DPkg::Lock::Timeout=60 --fix-broken install -y >/dev/null 2>&1; then + sudo apt-get -o DPkg::Lock::Timeout=60 install -y "$pkg" & if animate_progress "$name (retry)" $!; then local elapsed=$(($(date +%s) - start)) success "$name" "\${elapsed}s, deps fixed" @@ -53,11 +53,10 @@ info "Caching sudo credentials..." sudo -v || exit 1 while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & -wait_for_lock /var/lib/dpkg/lock-frontend sudo dpkg --configure -a >/dev/null 2>&1 || true info "Updating package lists..." -with_retry sudo apt-get update -qq & +with_retry sudo apt-get -o DPkg::Lock::Timeout=60 update -qq & if animate_progress "Updating..." $!; then printf "\\r\\033[K" >&3 success "Updated" @@ -74,4 +73,4 @@ ${packages.map(({ app, pkg }) => `install_pkg "${escapeShellString(app.name)}" " print_summary `; -} +} \ No newline at end of file