Revert "Add Debian package system busy detection"

This reverts commit 8f44b698c9.
This commit is contained in:
Ilia Ross
2026-07-20 23:59:49 +02:00
parent 8f44b698c9
commit cae7596303
3 changed files with 0 additions and 126 deletions

View File

@@ -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

View File

@@ -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.

View File

@@ -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();