3 # Generate perl module package dependencies
5 # Copyright (C) 2007 Peter Colberg <peter@petercolberg.org>
6 # Licensed under the terms of the GNU General Public License.
10 echo >&2 "Usage: $(basename $0) STAGING-DIR PERL-BUILD-DIR [FILES...] [DIRECTORIES...]"
15 PERL_BIN
="$STAGING_DIR/usr/bin/perl"
16 PERL_LIB
="$STAGING_DIR/usr/lib/perl5/5.10"
17 INC_DIR
="$(dirname $0)"
20 "$PERL_BIN" -I"$INC_DIR" -I"$PERL_LIB" - "$@" <<'PERL_SCRIPT'
28 our $sitelib = "/usr/lib/perl5/5.10";
31 my $builddir = Cwd::abs_path(shift);
33 my ($curdir, @pkgdirs, $dir, @deps, %depends, $file);
34 our ($pkg, %bundles, $path, @files);
36 @pkgdirs = glob($builddir . "/*/ipkg");
40 chdir($dir) or die "$dir: $!";
41 for $pkg (glob("*")) {
42 chdir($dir . "/" . $pkg . $sitelib) or next;
45 return unless (-f $_);
49 find({ wanted => \&wanted, no_chdir => 1 }, ".");
52 chdir($curdir) or die "$curdir: $!\n";
54 for $path (@scanpaths) {
56 return unless (-f $_ and /\.(pl|pm)$/);
63 find({ wanted => \&scan_wanted, no_chdir => 1 }, $path);
67 @deps = keys %{scan_deps(files => \@files, recurse => 0)};
68 for $file (grep { not exists $bundles{$_} } @deps) {
69 warn "could not resolve dependency: $file\n";
71 %depends = map { $bundles{$_}, 1 } grep { exists $bundles{$_} } @deps;
74 print join(' ', 'perl', sort keys %depends), "\n";