From cae759630356e2f447476bf16e45f769923385cd Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Mon, 20 Jul 2026 23:59:49 +0200 Subject: [PATCH] Revert "Add Debian package system busy detection" This reverts commit 8f44b698c9a339151d8f09a3a2357c58c483e92c. --- software/debian-lib.pl | 27 ------------ software/software-lib.pl | 9 ---- t/software-debian.t | 90 ---------------------------------------- 3 files changed, 126 deletions(-) delete mode 100644 t/software-debian.t diff --git a/software/debian-lib.pl b/software/debian-lib.pl index d05687ef7..911ca8ad3 100755 --- a/software/debian-lib.pl +++ b/software/debian-lib.pl @@ -6,33 +6,6 @@ sub list_package_system_commands return ("dpkg"); } -# package_system_busy_internal() -# Returns 1 if dpkg is locked or has incomplete packages, 0 if it is stable, -# or undef if lock ownership cannot be checked. -sub package_system_busy_internal -{ -my $fuser = &has_command("fuser"); -my $locks_checked = 0; -if ($fuser) { - foreach my $lock ("/var/lib/dpkg/lock-frontend", - "/var/lib/dpkg/lock") { - &backquote_command(quotemeta($fuser)." -s ". - quotemeta($lock)." 2>&1", 1); - return 1 if (!$?); - } - $locks_checked = 1; - } - -# An interrupted transaction can leave packages incomplete after the process -# holding the lock has exited. -my $dpkg = &has_command("dpkg"); -return undef if (!$dpkg); -my $out = &backquote_command(quotemeta($dpkg)." --audit 2>&1", 1); -return 1 if ($? || $out =~ /\S/); - -return $locks_checked ? 0 : undef; -} - # list_packages([package]*) # Fills the array %packages with a list of all packages sub list_packages diff --git a/software/software-lib.pl b/software/software-lib.pl index 433e7a6f1..637b88063 100755 --- a/software/software-lib.pl +++ b/software/software-lib.pl @@ -300,15 +300,6 @@ if ($rel1 ne "" && $rel2 ne "" && $config{'package_system'} eq 'rpm') { return &compare_version_numbers($_[0], $_[1]); } -# package_system_busy() -# Returns 1 if the package system is busy or incomplete, 0 if it is stable, -# or undef if the current package system cannot determine this. -sub package_system_busy -{ -return defined(&package_system_busy_internal) ? - &package_system_busy_internal() : undef; -} - # check_package_system() # Returns an error message if some command needed by the selected package # management system is missing. diff --git a/t/software-debian.t b/t/software-debian.t deleted file mode 100644 index 2bac20cc0..000000000 --- a/t/software-debian.t +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/local/bin/perl - -use strict; -use warnings; -use Test::More; -use File::Basename qw(dirname); -use File::Spec; -use Cwd qw(abs_path); - -my $root = abs_path(File::Spec->catdir(dirname(__FILE__), '..')); -chdir($root) or die "chdir($root): $!"; - -do './software/debian-lib.pl' or die $@ || $!; - -sub run_busy_test -{ -my ($commands, $available) = @_; -my @ran; -no warnings qw(once redefine); -local *has_command = sub { - my ($name) = @_; - return $available->{$name}; - }; -local *backquote_command = sub { - my ($command) = @_; - push(@ran, $command); - my $normalized = $command; - $normalized =~ s/\\(.)/$1/g; - foreach my $match (@$commands) { - if ($normalized =~ $match->{'match'}) { - $? = $match->{'status'} << 8; - return $match->{'output'} || ''; - } - } - die "Unexpected command: $command"; - }; -my $busy = package_system_busy_internal(); -return ($busy, \@ran); -} - -my %commands = ( - 'fuser' => '/usr/bin/fuser', - 'dpkg' => '/usr/bin/dpkg', -); - -my ($busy, $ran) = run_busy_test( - [ { 'match' => qr{/var/lib/dpkg/lock-frontend}, - 'status' => 0 } ], - \%commands); -is($busy, 1, 'reports a held dpkg frontend lock as busy'); -is(scalar(@$ran), 1, 'stops checking after finding a held lock'); - -($busy, $ran) = run_busy_test( - [ { 'match' => qr{/var/lib/dpkg/lock-frontend}, - 'status' => 1 }, - { 'match' => qr{/var/lib/dpkg/lock(?:\s|$)}, - 'status' => 1 }, - { 'match' => qr{dpkg\s+--audit}, - 'status' => 0 } ], - \%commands); -is($busy, 0, 'reports unlocked and consistent dpkg state as stable'); - -($busy, $ran) = run_busy_test( - [ { 'match' => qr{/var/lib/dpkg/lock-frontend}, - 'status' => 1 }, - { 'match' => qr{/var/lib/dpkg/lock(?:\s|$)}, - 'status' => 1 }, - { 'match' => qr{dpkg\s+--audit}, - 'status' => 0, - 'output' => "The following packages are only half configured.\n" } ], - \%commands); -is($busy, 1, 'reports incomplete packages as busy'); - -($busy, $ran) = run_busy_test( - [ { 'match' => qr{/var/lib/dpkg/lock-frontend}, - 'status' => 1 }, - { 'match' => qr{/var/lib/dpkg/lock(?:\s|$)}, - 'status' => 1 }, - { 'match' => qr{dpkg\s+--audit}, - 'status' => 2 } ], - \%commands); -is($busy, 1, 'treats a failed dpkg audit as unsafe'); - -($busy, $ran) = run_busy_test( - [ { 'match' => qr{dpkg\s+--audit}, - 'status' => 0 } ], - { 'dpkg' => '/usr/bin/dpkg' }); -is($busy, undef, 'returns undef when lock ownership cannot be checked'); - -done_testing();