Initial work on showing package dependencies

This commit is contained in:
Jamie Cameron
2024-02-25 21:33:14 -08:00
parent 24bf147c9a
commit a3f9d0a60f
3 changed files with 93 additions and 0 deletions

View File

@ -52,6 +52,14 @@ edit_ver=Version
edit_vend=Vendor
edit_arch=Architecture
edit_inst=Installed
edit_deps=Dependencies
edit_dname=Depends on
edit_dtype=Dependency type
edit_dvers=Version
edit_dpackage=Package
edit_dfile=File
edit_dother=Capability
edit_dlibrary=Library
edit_list=List Files
edit_listdesc=Show all the files in this package, and their current verification state.
edit_uninst=Uninstall

View File

@ -395,6 +395,51 @@ if ($? || $out =~ /error:/) { return "<pre>$out</pre>"; }
return undef;
}
# package_dependencies(name, [version])
# Returns a list of packages that this one depends on, as hash refs
sub package_dependencies
{
my ($pkg, $ver) = @_;
my $out = &backquote_command(
"rpm -qR ".quotemeta($pkg.($ver ? "-$ver" : ""))." 2>/dev/null");
my @rv;
my %done;
foreach my $l (split(/\r?\n/, $out)) {
next if ($done{$l}++);
if ($l =~ /^(\/.*)$/) {
# Depends on a file
push(@rv, { 'file' => $1 });
}
elsif ($l =~ /^([^\(\)= ]+)$/) {
# A bare package name
push(@rv, { 'package' => $1 });
}
elsif ($l =~ /^([^\(\)= ]+)\s+([=<>]+)\s+(\S+)$/) {
# A package name and matching version
push(@rv, { 'package' => $1,
'compare' => $2,
'version' => $3 });
}
elsif ($l =~ /^(\S+)\s+([=<>]+)\s+(\S+)$/) {
# Some other capability and matching version
push(@rv, { 'other' => $1,
'compare' => $2,
'version' => $3 });
}
elsif ($l =~ /^(\S+)\((\S*)\)\((\S*)\)$/) {
# Library with a tag and architecture
push(@rv, { 'library' => $1,
'version' => $2,
'arch' => $3 });
}
elsif ($l =~ /^(\S+)$/) {
# Some other capability
push(@rv, { 'other' => $1 });
}
}
return @rv;
}
sub package_system
{
return "RPM";

View File

@ -151,6 +151,46 @@ if ($pinfo[6]) {
print &ui_table_row($text{'edit_inst'}, $pinfo[6]);
}
# Dependencies, if we can get them
my @deps = defined(&package_dependencies) ?
&package_dependencies($name, $ver) : ( );
if (@deps) {
my $dtable = &ui_columns_start([ $text{'edit_dname'},
$text{'edit_dtype'},
$text{'edit_dvers'} ]);
foreach my $d (@deps) {
my @row;
if ($d->{'package'}) {
push(@row, &ui_link("edit_pack.cgi?package=".
&urlize($d->{'package'}), $d->{'package'}));
push(@row, $text{'edit_dpackage'});
}
elsif ($d->{'file'}) {
push(@row, &ui_link("file_info.cgi?file=".
&urlize($d->{'file'}), $d->{'file'}));
push(@row, $text{'edit_dfile'});
}
elsif ($d->{'library'}) {
push(@row, $d->{'library'});
push(@row, $text{'edit_dlibrary'});
}
else {
push(@row, $d->{'other'});
push(@row, $text{'edit_dother'});
}
if ($d->{'version'}) {
push(@row, (!$d->{'compare'} || $d->{'compare'} eq '=' ?
'' : $d->{'compare'}.' ').$d->{'version'});
}
else {
push(@row, "");
}
$dtable .= &ui_columns_row(\@row);
}
$dtable .= &ui_columns_end();
print &ui_table_row($text{'edit_deps'}, $dtable, 3);
}
print &ui_table_end();
return @pinfo;