eeabdf6da85144f9b81e0899c6c744d4d38bdeef
[scpubgit/App-EzPz.git] / bin / ezpz-create-test-ezmlm-install
1 #!/usr/bin/env perl
2
3 use lib (-d 'lib' ? ('lib') : ());
4 use strictures 1;
5 use IO::All;
6 use Cwd;
7 use IPC::System::Simple qw(run);
8
9 die "Usage: ezpz-create-test-ezmlm-install ezmlm-source.tgz build-dir install-dir"
10   unless @ARGV == 3;
11
12 my ($ezmlm_tarball_path, $build_dir_path, $install_to_path) = @ARGV;
13
14 my $ezmlm_tarball = io->file(io->file($ezmlm_tarball_path)->rel2abs);
15
16 my $orig_cwd = io->dir(cwd);
17
18 my $build_dir = io->dir(io->dir($build_dir_path)->rel2abs);
19 my $install_to = io->dir(io->dir($install_to_path)->rel2abs);
20
21 unless ($build_dir->exists) {
22   $build_dir->mkpath;
23   $build_dir->chdir;
24   run 'tar', 'xzf', $ezmlm_tarball;
25   $orig_cwd->chdir;
26 }
27
28 my ($src_dir) = ($build_dir->all_dirs)[0];
29
30 die "No source dir found in ${build_dir}" unless $src_dir;
31
32 foreach my $type (qw(bin etc lib man qmail)) {
33   $src_dir->catfile("conf-${type}")->print($install_to->catdir($type)."\n");
34 }
35
36 $src_dir->chdir;
37
38 run make => 'clean';
39 run 'make';
40 run make => 'man';
41 run './ezmlm-test';
42 $install_to->catdir('bin')->mkpath;
43 run make => 'install';