diff --git a/software/lang/en b/software/lang/en index e630dd2eb..459438c54 100644 --- a/software/lang/en +++ b/software/lang/en @@ -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 diff --git a/software/rpm-lib.pl b/software/rpm-lib.pl index 04b2f47d6..8d81b88eb 100755 --- a/software/rpm-lib.pl +++ b/software/rpm-lib.pl @@ -395,6 +395,51 @@ if ($? || $out =~ /error:/) { return "
$out
"; } 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"; diff --git a/software/software-lib.pl b/software/software-lib.pl index fe9f3aee1..0e083dc0c 100755 --- a/software/software-lib.pl +++ b/software/software-lib.pl @@ -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;