Add ability to show reverse dependencies

This commit is contained in:
Ilia Ross
2025-02-05 02:23:33 +02:00
parent ea5a1c0f8c
commit 9cc735c01b
15 changed files with 160 additions and 3 deletions

View File

@@ -67,6 +67,14 @@ sub package_info
}
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# is_package(file)
# Tests if some file is a valid package file
sub is_package

View File

@@ -80,6 +80,14 @@ close(RPM);
return ($tmp[0], $tmp[1], $d, $tmp[2], $tmp[3], $tmp[4], &make_date($tmp[5]));
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# is_package(file)
# Check if some file is a package file
sub is_package

View File

@@ -87,6 +87,41 @@ push(@rv, $text{'debian_unknown'});
return @rv;
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
my ($pkg) = @_;
my $qpkg = quotemeta($pkg);
my $apt_cache_cmd = &has_command("apt-cache");
return ( ) if (!$apt_cache_cmd);
my $out = &backquote_command("$apt_cache_cmd showpkg $qpkg 2>&1", 1);
# Get the package that provides this virtual package
my ($vpkg);
if ($out =~ /Reverse Provides:\s*(\S+\s+\S+)/) {
my ($rpkg, $rver) = split(/\s+/, $1, 2);
$vpkg = $rpkg;
$qvpkg = quotemeta($vpkg)."=".quotemeta($rver);
}
return ( ) if (!$vpkg);
# Get full status
$out = &backquote_command("$apt_cache_cmd show $qvpkg 2>&1", 1);
$out =~ s/[\0-\177]*\r?\n\r?\n(Package:)/\\1/; # remove available ver
return () if ($? || $out =~ /Package .* is not available/i);
local @rv = ( $vpkg, &alphabet_name($vpkg) );
push(@rv, $out =~ /Description(-en)?:\s+((.*\n)(\s+.*\n)*)/i ? $2
: $text{'debian_unknown'});
push(@rv, $out =~ /Architecture:\s+(\S+)/i ? $1 : $text{'debian_unknown'});
push(@rv, $out =~ /Version:\s+(\S+)/i ? $1 : $text{'debian_unknown'});
push(@rv, $out =~ /Maintainer:\s+(.*)/i ? &html_escape($1)
: $text{'debian_unknown'});
push(@rv, $text{'debian_unknown'});
return @rv;
}
# check_files(package)
# Fills in the %files array with information about the files belonging
# to some package. Values in %files are path type user group mode size error

View File

@@ -98,6 +98,14 @@ return ( $packages{0,'name'}, $packages{0,'class'}, $packages{0,'desc'},
$system_arch, $packages{0,'version'}, "Gentoo", &make_date($st[9]) );
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# is_package(file)
# Check if some file is a package file
sub is_package

View File

@@ -73,6 +73,14 @@ push(@rv, @st ? ctime($st[9]) : $text{'bsd_unknown'});
return @rv;
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# check_files(package, version)
# Fills in the %files array with information about the files belonging
# to some package. Values in %files are path type user group mode size error

View File

@@ -92,6 +92,14 @@ close(SW);
return ($name, $class, $desc, $arch, $version, $vendor, $date);
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# is_package(file)
# Check if some file is a package file
sub is_package

View File

@@ -113,6 +113,14 @@ push(@rv, $packages{$pos, 'install'} ? "" : false);
return @rv;
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# check_files(package)
# Fills in the %files array with information about the files belonging
# to some package. Values in %files are path type user group mode size error

View File

@@ -175,6 +175,14 @@ else {
}
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# is_package(file)
# Check if some file is a package file
sub is_package

View File

@@ -49,6 +49,14 @@ push(@rv, @st ? ctime($st[9]) : $text{'bsd_unknown'});
return @rv;
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# check_files(package)
# Fills in the %files array with information about the files belonging
# to some package. Values in %files are path type user group mode size error

View File

@@ -71,6 +71,14 @@ push(@rv, $out =~ /INSTDATE:\s+(.*)\n/ ? $1 : $text{'pkgadd_unknown'});
return @rv;
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# is_package(file)
# Tests if some file is a valid package file
sub is_package

View File

@@ -78,6 +78,14 @@ return ($packages{0,'name'}, $packages{0,'class'}, $packages{0,'desc'},
$packages{0,'arch'}, $packages{0,'version'}, undef, undef);
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# is_package(file)
# Always returns 0, because pkgsrc doesn't support installing from files
sub is_package

View File

@@ -58,6 +58,29 @@ close(RPM);
return ($tmp[0], $tmp[1], $d, $tmp[2], $tmp[3], $tmp[4], &make_date($tmp[5]));
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
my ($vpkg) = @_;
my $query_format =
'%{NAME}\n%{GROUP}\n%{ARCH}\n%{VERSION}-%{RELEASE}\n%{VENDOR}\n'.
'%{INSTALLTIME}\n%{DESCRIPTION}';
&open_execute_command(*RPM, "rpm -q --whatprovides $vpkg --queryformat ".
"\"$query_format\" 2>/dev/null", 1, 1);
my @tmp = <RPM>;
close(RPM);
return () if (!@tmp || $tmp[0] =~ /no\s+package\s+provides/);
# Extract fields properly
my @fields = splice(@tmp, 0, 6);
chomp(@fields);
return (@fields[0, 1], join('', @tmp), @fields[2, 3, 4], &make_date($fields[5]));
}
# is_package(file)
# Check if some file is a package file
sub is_package

View File

@@ -94,6 +94,14 @@ close(PKG);
return @rv;
}
# virtual_package_info(package)
# Returns an array of package information for a virtual package, usually called
# if "package_info" returns nothing.
sub virtual_package_info
{
return ( );
}
# check_files(package)
# Fills in the %files array with information about the files belonging
# to some package. Values in %files are path type user group mode size error