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