aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-01-17 13:01:32 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-01-17 13:01:32 +0000
commit5b45d947ae61c3f3043cf3db71dd19d7dc686a0a (patch)
tree91546c6386f6888e6d30650600b486dfb264a115
parentf534f471f1e3b8117085d42206e4912dad842650 (diff)
downloadrpmtools-5b45d947ae61c3f3043cf3db71dd19d7dc686a0a.tar
rpmtools-5b45d947ae61c3f3043cf3db71dd19d7dc686a0a.tar.gz
rpmtools-5b45d947ae61c3f3043cf3db71dd19d7dc686a0a.tar.bz2
rpmtools-5b45d947ae61c3f3043cf3db71dd19d7dc686a0a.tar.xz
rpmtools-5b45d947ae61c3f3043cf3db71dd19d7dc686a0a.zip
Add a "follow" option to the File::Find call, to follow symlinks, as
suggested by Steven Shiau. Plus some tidying up and perl_checker fixes.
-rw-r--r--genhdlist56
1 files changed, 27 insertions, 29 deletions
diff --git a/genhdlist b/genhdlist
index 37fdca2..16890f9 100644
--- a/genhdlist
+++ b/genhdlist
@@ -4,7 +4,7 @@
# $Id$
#
-#- Copyright (C) 1999 MandrakeSoft
+#- Copyright (C) 1999-2005 Mandrakesoft
#-
#- This program is free software; you can redistribute it and/or modify
#- it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@ use File::Find;
use File::Path;
use Getopt::Long;
-my ($noclean, $nooutput, $dontdie, $suffix, $dest) = (0, 0, 0, "");
+my ($noclean, $nooutput, $dontdie, $suffix, $dest) = (0, 0, 0, "", "");
my $tmpdir = (-d "$ENV{HOME}/tmp" ? "$ENV{HOME}/tmp" : $ENV{TMPDIR} || "/tmp") . "/.build_hdlist";
sub usage {
@@ -41,7 +41,6 @@ Options:
--nobadrpm do not stop on bad rpm
--noclean keep cache files
--suffix SUFFIX put a suffix on hdlist names
-
EOF
}
@@ -62,46 +61,46 @@ my @dir = @ARGV ? @ARGV : (".");
grep { m!^/! } @dir and die "Directory path to parse should be relative";
-$dest and do { chdir $dest or die "can't chdir in directory $dest"; };
+$dest and do { chdir $dest or die "can't chdir in directory $dest" };
rmtree($tmpdir) unless $noclean;
mkpath($tmpdir);
my @rpms;
my %rpmslist;
sub wanted {
- if (-f $_ && $_ =~ /^.*\.rpm$/ ) {
- push(@rpms, $File::Find::name);
- }
+ if (-f $_ && /^.*\.rpm$/) {
+ push(@rpms, $File::Find::name);
+ }
}
# get rpm list
-open(LIST, "> list$suffix") or die "can't create list file: $!";
+open my $list, ">", "list$suffix" or die "can't create list file: $!";
foreach my $dir (@dir) {
- print "parsing $dir\n" unless $nooutput;
- @rpms = ();
+ print "parsing $dir\n" unless $nooutput;
+ @rpms = ();
%rpmslist = ();
- File::Find::find({wanted => \&wanted}, $dir);
- $urpm->parse_rpms_build_headers(
- dir => $tmpdir,
- rpms => \@rpms,
- dontdie => $dontdie,
- silent => $nooutput,
- callback => sub {
- my ($urpm, $id, %options) = @_;
-
- # This code need a fix in perl-URPM
- # print LIST "$options{file}\n";
- $rpmslist{scalar($urpm->{depslist}[$id]->fullname).".rpm"} = 1;
- $urpm->{depslist}[$id]->pack_header;
- },
- );
+ File::Find::find({ wanted => \&wanted, follow => 1 }, $dir);
+ $urpm->parse_rpms_build_headers(
+ dir => $tmpdir,
+ rpms => \@rpms,
+ dontdie => $dontdie,
+ silent => $nooutput,
+ callback => sub {
+ my ($urpm, $id, %options) = @_;
+
+ # This code need a fix in perl-URPM
+ # print $list "$options{file}\n";
+ $rpmslist{scalar($urpm->{depslist}[$id]->fullname) . ".rpm"} = 1;
+ $urpm->{depslist}[$id]->pack_header;
+ },
+ );
# This code will become useless... see above
foreach my $rpm (@rpms) {
- $rpmslist{($rpm =~ m!.*/(.*)$!)[0]} or next;
- print LIST "$rpm\n";
+ $rpmslist{($rpm =~ m!.*/(.*)$!)[0]} or next;
+ print $list "$rpm\n";
}
}
-close(LIST);
+close($list);
# create index file
# No rpms, exit !
@@ -118,4 +117,3 @@ rmtree($tmpdir) unless $noclean;
$urpm->build_synthesis(start => 0,
end => $#{$urpm->{depslist}},
synthesis => $synthesis);
-