| 1 | package ShipIt::ProjectType::AutoConf; | ||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use base 'ShipIt::ProjectType'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use ShipIt::Util qw(slurp write_file tempdir_obj); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use File::Copy (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 2 | ▶ | use Cwd; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | # factory when called directly. | ||||||||||
| 9 | # returns undef if not a perl project, otherwise returns | ||||||||||
| 10 | # ::MakeMaker or ::ModuleBuild instance. | ||||||||||
| 11 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 12 | 0 | my ($class) = @_; | |||||||||
| 13 | 0 | ▶ | return undef unless -e "configure.ac"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 0 | my $self = $class->SUPER::new; | |||||||||
| 15 | 0 | return $self; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | 0 | ▶ | sub current_version { | ||||||||
|
Subroutine
current_version: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 19 | 0 | my ($self) = @_; | |||||||||
| 20 | 0 | my $conf = slurp("configure.ac"); | |||||||||
| 21 | 0 | ▶ | die "No AC_INIT found" unless | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | $conf =~ /^AC_INIT\((.+?), (\S+?), .+\)/m; | ||||||||||
| 23 | 0 | $self->{projname} = $1; | |||||||||
| 24 | 0 | $self->{projver} = $2; | |||||||||
| 25 | 0 | return $2; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub update_version { | ||||||||
|
Subroutine
update_version: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 29 | 0 | my ($self, $newver) = @_; | |||||||||
| 30 | 0 | my $conf = slurp("configure.ac"); | |||||||||
| 31 | 0 | ▶ | $conf =~ s/^AC_INIT\((.+?), (\S+?), (.+)\)/AC_INIT($1, $newver, $3)/m | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | or die "update_version regpexp failed"; | ||||||||||
| 33 | 0 | write_file("configure.ac", $conf); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 0 | ▶ | sub makedist { | ||||||||
|
Subroutine
makedist: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 37 | 0 | my $self = shift; | |||||||||
| 38 | 0 | my $distfile = $self->_build_tempdist; | |||||||||
| 39 | 0 | return $distfile; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub disttest { | ||||||||
|
Subroutine
disttest: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||
| 43 | 0 | my ($self) = @_; | |||||||||
| 44 | 0 | my $distfile = $self->_build_tempdist; | |||||||||
| 45 | |||||||||||
| 46 | # debug, | ||||||||||
| 47 | 0 | my $size = -s $distfile; | |||||||||
| 48 | 0 | warn "distfile = $distfile (size = $size)\n"; | |||||||||
| 49 | |||||||||||
| 50 | 0 | ▶ | my ($basename) = $distfile =~ m!([^/]+)$! or die; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 51 | |||||||||||
| 52 | 0 | my $testdir_o = tempdir_obj(); | |||||||||
| 53 | 0 | my $testdir = $testdir_o->directory; | |||||||||
| 54 | 0 | ▶ | File::Copy::copy($distfile, $testdir) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | or die "Copy from $distfile to $testdir failed: $!\n"; | ||||||||||
| 56 | |||||||||||
| 57 | 0 | my $old_cwd = getcwd; | |||||||||
| 58 | 0 | warn "Changing to tempdir $testdir for make/make test...\n"; | |||||||||
| 59 | 0 | ▶ | chdir($testdir) or die "chdir to testdir $testdir failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | 0 | ▶ | system("tar -zxvf $basename") and die "untar failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | my ($untardir) = $basename =~ m!^(.+)\.tar\.gz$! or die; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | ▶ | die "Expected untarred dir $untardir, but not there" unless -d $untardir; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | 0 | ▶ | chdir($untardir) or die; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | |||||||||||
| 66 | 0 | ▶ | system("./configure") and die "configure during test failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 67 | 0 | ▶ | system("make") and die "make during test failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | ▶ | system("make", "test") and die "make test failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 69 | |||||||||||
| 70 | # restore old working directory | ||||||||||
| 71 | 0 | ▶ | chdir($old_cwd) or die; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | |||||||||||
| 73 | 0 | return 1; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub _build_tempdist { | ||||||||
|
Subroutine
_build_tempdist: not called CC=14 SCAR=53.5
| |||||||||||
| 77 | 0 | my $self = shift; | |||||||||
| 78 | |||||||||||
| 79 | 0 | ▶ | my $projname = $self->{projname} or die "no projname found?"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | 0 | ▶ | my $projver = $self->{projver} or die "no projver found?"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | my $distfile = "$projname-$projver.tar.gz"; | |||||||||
| 82 | |||||||||||
| 83 | # did we already build it for a DistTest step earlier? | ||||||||||
| 84 | 0 | ▶ | if (my $tdir = $self->{dist_tempdirobj}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 85 | 0 | my $file = $tdir->directory . "/$distfile"; | |||||||||
| 86 | 0 | ▶ | return $file if -e $file; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | die "Distfile $distfile already exists" if -e $distfile; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | |||||||||||
| 91 | 0 | ▶ | if (-e "Makefile") { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 92 | 0 | ▶ | system("make", "distclean") and die "Distclean failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 93 | } | ||||||||||
| 94 | |||||||||||
| 95 | 0 | ▶ | if (-x "autogen.sh") { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 96 | 0 | ▶ | system("./autogen.sh") and die "autogen.sh failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 97 | } | ||||||||||
| 98 | |||||||||||
| 99 | 0 | ▶ | system("./configure") and die "configure failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 100 | 0 | ▶ | system("make", "dist") and die "make dist failed"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 101 | |||||||||||
| 102 | 0 | ▶ | die "Distfile $distfile doesn't exist" unless -e $distfile; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 103 | |||||||||||
| 104 | # throw object in $self, so it doesn't get rmtree'd until | ||||||||||
| 105 | # $self goes out of scope, later. | ||||||||||
| 106 | 0 | my $tdir = $self->{dist_tempdirobj} = tempdir_obj(); | |||||||||
| 107 | |||||||||||
| 108 | 0 | ▶ | File::Copy::move($distfile, $tdir->directory) or | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | die "Failed to move dist $distfile to tempdir"; | ||||||||||
| 110 | |||||||||||
| 111 | 0 | return $tdir->directory . "/$distfile"; | |||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | 2 | 1; | |||||||||