[Frugalware-darcs] pacman-tools: chkdep - verbose & fakeroot
VMiklos
vmiklos at frugalware.org
Thu Apr 7 16:03:54 CEST 2005
Thu Apr 7 13:37:07 CEST 2005 VMiklos <vmiklos at frugalware.org>
* chkdep - verbose & fakeroot
* fixes in pod
* man page
* -v verbose option
* -i to ignore fakeroot
* from xbit
diff -rN -u darcs-old/chkdep.pl darcs-new/chkdep.pl
--- darcs-old/chkdep.pl 2005-04-07 16:03:51.000000000 +0200
+++ darcs-new/chkdep.pl 2005-04-07 13:27:18.000000000 +0200
@@ -6,9 +6,9 @@
=head1 SYNOPSIS
-chkdep [-d dir] [-p file]
+chkdep [-vi] [-n packagename] -d dir | -p file
-=head DESCRIPTION
+=head1 DESCRIPTION
Outputs a dependency array for a FrugalBuild scripts, containing the
the packages that are needed.
@@ -24,23 +24,35 @@
=item B<-d dir>
-check all executable files in dir directry with ldd and make depend array
+Check all executable files in dir directry with ldd and make depend array
=item B<-p file>
-if file is a tgz package, it will be extracted, making depend array
+If file is a tgz package, it will be extracted, making depend array
=item B<-n packagename>
-when the script cant determine the name of the package you're checking,
+When the script cant determine the name of the package you're checking,
you can give it manually with this(ie. when you use the -d option).
+=item B<-v>
+
+Be verbose
+
+=item B<-i>
+
+Ignore fakeroot library if found
+
=back
+=head1 AUTHOR
+
+Zsolt Szalai
+
=head1 COPYRIGHT
chkdep may be copied and modified under the terms of the GNU General Public
-License.
+License v2.
=cut
@@ -48,15 +60,21 @@
use Getopt::Std;
$Getopt::Std::STANDARD_HELP_VERSION = 1;
-our $VERSION = "1.3";
+our $VERSION = "1.5";
+
+my %opts;
+getopts('vid:p:f:n:', \%opts);
sub HELP_MESSAGE(){
print <<END
chkdep - checks dependencies for packages of Frugalware Linux
-usage: chkdep -d directory
- chkdep -p samepackage.fpm
- chkdep -n packagename(use with -d if necessary)
-
+usage: chkdep [-vi] [-n packagename] -d dir | -p file
+ -d directory
+ -p samepackage.fpm
+ -n packagename(use with -d if necessary)
+ -i ignore fakeroot
+ -v be verbose
+
It works correctly only if all the libraries have been
installed from fpm packages with pacman!
END
@@ -68,70 +86,74 @@
my @dir = split /\//, $pkg;
my $name = "/tmp/" . pop @dir;
die $! unless mkdir $name;
- `tar xzf $pkg -C $name`;
- #my ($pkgname) = $name =~ /.*\/(.*)-.*-.*.fpm$/;
+ my $comm = "tar xzf $pkg -C $name";
+ $comm .= ' 2>/dev/null' unless $opts{v};
+ qx/$comm/;
return $name;
}
sub ldddir{ #dir
my $dir = shift;
- my $comm = 'find ' . $dir .' -perm -u+x ! -type d ! -type l -print -exec ldd {} \;';
- return `$comm`;
+ my $comm = 'find ' . $dir .' -perm -u+x ! -type d ! -type l -exec ldd {} \;';
+ $comm .= ' 2>/dev/null' unless $opts{v};
+ return qx/$comm/;
}
-my %opts;
-getopts('d:p:f:n:', \%opts);
-
HELP_MESSAGE && die "Wrong option!" unless %opts;
my $dir = extractfpm $opts{p} if $opts{p};
$dir = $opts{d} if $opts{d};
my $pkgname;
$pkgname = $opts{n} or
- ($pkgname) = `grep pkgname $dir/.PKGINFO 2>/dev/null` =~ /pkgname = (.*)$/;
-if (not defined $pkgname){
- print "Could not determine packagname!\n"; $pkgname = '';
-} else {
- print "Package: $pkgname\n";
+ ($pkgname) = qx"grep pkgname $dir/.PKGINFO 2>/dev/null" =~ /pkgname = (.*)$/;
+if ($opts{v}){
+ if (! $pkgname){
+ print "Could not determine packagname!\n"; $pkgname = '';
+ } else {
+ print "Package: $pkgname\n";
+ }
}
my @ldd = ldddir $dir;
-`rm -rf $dir` if $opts{p};
-
-my %pkgs = (); #dependecies
-my %libs = ();
-my %depsdep =(); # the dependencies' dependencies
+my $comm = "rm -rf $dir";
+$comm .= ' 2>/dev/null' unless $opts{v};
+qx/$comm/;
+
+my %pkgs; #dependecies
+my %libs;
+my %depsdep; # the dependencies' dependencies
for my $line (@ldd){
if ($line =~ /.* => (.+) \(.*\)/){
my $lib = $1;
- if (!defined $libs{$lib}) {
- $libs{$lib} = '1';
- `pacman -Qo $lib` =~ /owned by (.*?)\s(.*)\Z/;
- my $pkg = $1;
- if ($pkg eq '' or !defined $pkg) {
- print "WARNING: No package found containing $lib\n";
- }
+ if ($lib =~ /fakeroot/){
+ print "fakeroot found in dependencies\n" if $opts{v};
+ next if $opts{i};
+ }
+ if (! $libs{$lib}) {
+ $libs{$lib} = 1;
+ my ($pkg) = qx/pacman -Qo $lib/ =~ /owned by (.*?)\s/;
+ print "WARNING: No package found containing $lib\n" if !$pkg && $opts{v};
if ($pkg ne $pkgname) {
- my ($pkgdeps) = `pacman -Qi $pkg` =~ /Depends.*?: (.*?)Removes/s;
- foreach my $dd (split ' ', $pkgdeps){
- $depsdep{$dd} = '1';
+ my ($pkgdeps) = qx/pacman -Qi $pkg/ =~ /Depends.*?: (.*?)Removes/s;
+ foreach my $dd (split(' ',$pkgdeps)){
+ $depsdep{$dd} = 1;
}
# handle provides directive!
$pkg = 'x' if ($pkg eq 'xorg');
- $pkgs{$pkg} = '1' if ($pkg ne $pkgname);
+ $pkgs{$pkg} = 1;
}
}
}
}
my $deps = 'depends=(';
foreach my $key (keys %pkgs){
- $deps .= "\'$key\' " if (not defined $depsdep{$key});
+ $deps .= "\'$key\' " unless $depsdep{$key};
}
chop $deps if %pkgs;
$deps = $deps . ')';
More information about the Frugalware-darcs
mailing list