|
The rpm dependency check project
RPM dependency check v0.0.1
the file: rpmdepend-current.pl
old file: rpmdepend0.0.pl
rpmdepend.pl
#!/usr/bin/perl
#------ ----- ---- --- -- - - - - -
# This is rpmdepend version 0.0.1
#
# RPMDEPEND is a program that goes through your
# currently installed RPM packages and finds out
# which dependencies are met and which aren't.
# it then generates a report of its findings.
#
# Often a newly installed RPM based system will
# be missing a few dependencies. Some are
# necessary for the operation of certain packages
# some are really just suggestions (like csh...)
# (or aalib for gimp)
#
# It is up to the sysadmin to make decisions
# (such as installing packages) based on the
# findings.
#
# Currently RPMDEPEND is a rapid prototype
# a true version would be a binary which can
# directly access the rpm database without
# calling on 'rpm' directly. Due to its current
# implementation it churns your drive, forks
# often to 'sh' and 'rpm', and uses memory in
# bursts.
#
# By releasing early the author hopes to recieve
# feed back as to usability features that may be
# desired; such as command line options for
# searching through some packages only, for
# using a criteria to install dependencies, and
# for alternate output modes or additional
# output information.
#
# please contact the author (Daniel Lamblin) at:
# daniell_at_kapowee.com
# and begin your subject line with "rpmdepend"
# in case of difficulties try: daniell_at_slithy.toves.net
#
# Currently ascii (stdout) output is formatted
# as:
# [blank line]
# PACKAGE:
# [package name]
# > Provides:
# - [provided feature]
# - [...]
# > Requires:
# - [file name] -- File Exists
# - [package or lib] -- provided by: [providing package]
# ? [package] [<= || >=] [version string] -- check vers: [providing package]
# ! [un-met req] -- (not installed)
# #PARSE!# [req]
#
# You probably won't get #PARSE!# problems... report them if you do
# You should manually check the version numbers of '?' lines (for now)
# You want to be aware of all '!' lines
#- - - - - -- --- ---- ----- ------
#--figure out user's command line options
#
for( $i=0; $i<@ARGV; $i++ ){
#--check for "--help" and stop
#
if ($ARGV[$i] eq "--help"){
print "\n";
print "Command line arguments for $0 [rpmdepend.pl] are:\n";
print " $0 [--help] [--grep regex | --package name]\n";
print " --help Show this help comment\n";
print " --grep regex Grep all packages for regex pattern match\n";
print " --package name Only process named package\n";
print "\n";
exit 0;
}
#--check for "--grep" and its follow up argument
#
elsif ($ARGV[$i] eq "--grep"){
#--if $exclude_grep_package has been defined or there is no argument
#
if (defined $exclude_grep_package || !defined $ARGV[i+1]){
print "\nSee: \n$0 --help\n\n";
exit 1;
} else {
$options = "-a |grep '$ARGV[$i+1]'";
$exclude_grep_package = 1;
}
}
#--check for "--package" and its follow up argument
#
elsif ($ARGV[$i] eq "--package"){
#--if $exclude_grep_package has been defined or there is no argument
#
if (defined $exclude_grep_package || !defined $ARGV[i+1]){
print "\nSee: \n$0 --help\n\n";
exit 1;
} else {
$options = $ARGV[$i+1];
$exclude_grep_package = 1;
}
}
}
#--if no options were used default query all
#
if (!defined $options) {$options = "-a";}
#--once per text line from rpm query (and add options)
#
foreach $rpmpkg (`rpm -q $options`) {
chomp ($rpmpkg);
print "\nPACKAGE:\n$rpmpkg\n";
print "> Provides:\n";
#--once for each item the package provides
#
foreach $provide (`rpm -q --provides $rpmpkg`){
chomp ($provide);
#--(usually there's 2 spaces at the end): chop ($provide);chop ($provide);
#--not always though, so lets remove all trailing whitespace
#
$provide =~ s/\s*$//; #\s=whitespace *=any amount $=end of line
print " - $provide\n";
}
print "> Requires:\n";
#--once for each item the package requires
#
foreach $require (`rpm -q -R $rpmpkg 2>&1`){
chomp ($require);
#--(usually there's 2 spaces at the end): chop ($require);chop ($require);
#--not always though, so lets remove all trailing whitespace
#
$require =~ s/\s*$//; #\s=whitespace *=any amount $=end of line
#--sometimes there's a [worthless?] parenthetical note at the end
#--lets chop it off too.
#
$require =~ s/\(.*?\)$//; #\( and \)=a true paren char .*?=greedy [short] match of anything
#--if there's an equal clause in $require, only use the first word
#
if ($require =~ '=') {
($first, $trash) = split(/.=/, $require, 2); #.= matches both >= and <=;
#--provider is what provides the requirement
#--package could be a full package name
#
$package = `rpm -q $first 2>&1`;
$provider = `rpm -q --whatprovides $first 2>&1`;
} else {
$package = `rpm -q $require 2>&1`;
$provider = `rpm -q --whatprovides $require 2>&1`;
}
#--if $require starts with a / and is a file on the filesystem
#
if ((substr($require, 0, 1) eq "/") && -e $require) {
printf " - %-32s -- File Exists\n", $require;
#--if $require is a package name which is installed
#
} elsif ($package ne "package $require is not installed\n" && $package ne "") {
if ($require =~ '=') {
printf " ? %-32s -- check vers: $package", $require;
} else {
printf " - %-32s -- provided by: $package", $require;
}
#--if $require is not provided by a package
#
} elsif ($provider eq "no package provides $require\n") {
printf " ! %-32s -- (not installed)\n", $require;
#--if $require was a garbled thing that caused errors
#
} elsif ($provider eq "") {
#--this means we needed to properly filter out parenthesis after $require
print " #PARSE!# $require\n";
} else {
printf " - %-32s -- provided by: $provider", $require;
}
}
}
|
|
by: Daniel P. Lamblin
|
|