3 # build_perl_modules -d dest_dir [-c] [-m] [-t] [-i] tarball_dir
6 # Installs perl modules found in tarball_dir
7 # Expects a file called install_order, containing one line per distribution name
8 # Will take action against each distribution in turn
9 # -d is a necessary destination directory for the perl mods
10 # If -c is set, will remove the module build directories and exit
11 # If -m is set, will run perl Makefile.PL and make
12 # If -t is set, will run make test
13 # If -i is set, will run make install
14 # Options are discrete. This is because an overall ./configure, make, make test, make install
15 # are run in different invocations. Obviously, you can't run a -t without a -m, but there's no
16 # checking here for that
18 # Can only use base modules
27 getopts
('d:cmti', $opts) || die "Invalid options";
28 my $moddir = shift @ARGV or die "Must specify a directory where tarballs exist";
30 my $destdir = $opts->{d
};
31 die "Must set a destination directory" unless $destdir;
33 chdir $moddir or die "Cannot change to $moddir";
34 open F
, "install_order" or die "Cannot open install_order file";
35 my @files = grep { ! /^#/ && chop } <F
>;
39 foreach my $f (@files) {
40 # Needs to be better. Also, what if there are two with same name?
42 eval '$tarball = <'."$f".'*.tar.gz>';
43 die unless ($tarball);
44 print "Got $f, with file: $tarball",$/;
45 push @tarballs, $tarball;
46 (my $dir = $tarball) =~ s/\.tar.gz//;
47 # Need to do cleaning before doing each module in turn
49 print "Cleaning $dir",$/;
55 print "Finished cleaning",$/;
60 foreach my $tarball (@tarballs) {
61 (my $dir = $tarball) =~ s/\.tar.gz//;
63 # Don't compile if already done - this is because of invocating this
64 # script at different stages
66 system("gunzip -c $tarball | tar -xf -") == 0 or die "Cannot extract $tarball";
67 chdir $dir or die "Can't chdir into $dir";
68 system("perl Makefile.PL PREFIX=$destdir INSTALLDIRS=site LIB=$destdir/lib") == 0 or die "Can't run perl Makefile.PL";
69 system("make") == 0 or die "Can't run make";
70 chdir $topdir or die "Can't chdir to top";;
74 chdir $dir or die "Can't chdir into $dir";
76 # Need to add this so this module is found for subsequent ones
77 $ENV{PERL5LIB
}="$topdir/$dir/blib/lib:$ENV{PERL5LIB}";
80 system("make test") == 0 or die "Can't run make test failed";
83 system("make install SITEPREFIX=$destdir") == 0 or die "Can't run make install";
85 chdir $topdir or die "Can't go back to $topdir";