line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ShipIt::ProjectType::AutoConf; |
2
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
138
|
|
3
|
2
|
|
|
2
|
|
9
|
use base 'ShipIt::ProjectType'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
186
|
|
4
|
2
|
|
|
2
|
|
965
|
use ShipIt::Util qw(slurp write_file tempdir_obj); |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
627
|
|
5
|
2
|
|
|
2
|
|
4124
|
use File::Copy (); |
|
2
|
|
|
|
|
7256
|
|
|
2
|
|
|
|
|
68
|
|
6
|
2
|
|
|
2
|
|
17
|
use Cwd; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2542
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# factory when called directly. |
9
|
|
|
|
|
|
|
# returns undef if not a perl project, otherwise returns |
10
|
|
|
|
|
|
|
# ::MakeMaker or ::ModuleBuild instance. |
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
0
|
|
my ($class) = @_; |
13
|
0
|
0
|
|
|
|
|
return undef unless -e "configure.ac"; |
14
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new; |
15
|
0
|
|
|
|
|
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub current_version { |
19
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
20
|
0
|
|
|
|
|
|
my $conf = slurp("configure.ac"); |
21
|
0
|
0
|
|
|
|
|
die "No AC_INIT found" unless |
22
|
|
|
|
|
|
|
$conf =~ /^AC_INIT\((.+?), (\S+?), .+\)/m; |
23
|
0
|
|
|
|
|
|
$self->{projname} = $1; |
24
|
0
|
|
|
|
|
|
$self->{projver} = $2; |
25
|
0
|
|
|
|
|
|
return $2; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub update_version { |
29
|
0
|
|
|
0
|
1
|
|
my ($self, $newver) = @_; |
30
|
0
|
|
|
|
|
|
my $conf = slurp("configure.ac"); |
31
|
0
|
0
|
|
|
|
|
$conf =~ s/^AC_INIT\((.+?), (\S+?), (.+)\)/AC_INIT($1, $newver, $3)/m |
32
|
|
|
|
|
|
|
or die "update_version regpexp failed"; |
33
|
0
|
|
|
|
|
|
write_file("configure.ac", $conf); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub makedist { |
37
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
38
|
0
|
|
|
|
|
|
my $distfile = $self->_build_tempdist; |
39
|
0
|
|
|
|
|
|
return $distfile; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub disttest { |
43
|
0
|
|
|
0
|
1
|
|
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
|
0
|
|
|
|
|
my ($basename) = $distfile =~ m!([^/]+)$! or die; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $testdir_o = tempdir_obj(); |
53
|
0
|
|
|
|
|
|
my $testdir = $testdir_o->directory; |
54
|
0
|
0
|
|
|
|
|
File::Copy::copy($distfile, $testdir) |
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
|
0
|
|
|
|
|
chdir($testdir) or die "chdir to testdir $testdir failed"; |
60
|
0
|
0
|
|
|
|
|
system("tar -zxvf $basename") and die "untar failed"; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
my ($untardir) = $basename =~ m!^(.+)\.tar\.gz$! or die; |
63
|
0
|
0
|
|
|
|
|
die "Expected untarred dir $untardir, but not there" unless -d $untardir; |
64
|
0
|
0
|
|
|
|
|
chdir($untardir) or die; |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
system("./configure") and die "configure during test failed"; |
67
|
0
|
0
|
|
|
|
|
system("make") and die "make during test failed"; |
68
|
0
|
0
|
|
|
|
|
system("make", "test") and die "make test failed"; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# restore old working directory |
71
|
0
|
0
|
|
|
|
|
chdir($old_cwd) or die; |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return 1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _build_tempdist { |
77
|
0
|
|
|
0
|
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
my $projname = $self->{projname} or die "no projname found?"; |
80
|
0
|
0
|
|
|
|
|
my $projver = $self->{projver} or die "no projver found?"; |
81
|
0
|
|
|
|
|
|
my $distfile = "$projname-$projver.tar.gz"; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# did we already build it for a DistTest step earlier? |
84
|
0
|
0
|
|
|
|
|
if (my $tdir = $self->{dist_tempdirobj}) { |
85
|
0
|
|
|
|
|
|
my $file = $tdir->directory . "/$distfile"; |
86
|
0
|
0
|
|
|
|
|
return $file if -e $file; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
die "Distfile $distfile already exists" if -e $distfile; |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
if (-e "Makefile") { |
92
|
0
|
0
|
|
|
|
|
system("make", "distclean") and die "Distclean failed"; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
if (-x "autogen.sh") { |
96
|
0
|
0
|
|
|
|
|
system("./autogen.sh") and die "autogen.sh failed"; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
system("./configure") and die "configure failed"; |
100
|
0
|
0
|
|
|
|
|
system("make", "dist") and die "make dist failed"; |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
die "Distfile $distfile doesn't exist" unless -e $distfile; |
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
|
0
|
|
|
|
|
File::Copy::move($distfile, $tdir->directory) or |
109
|
|
|
|
|
|
|
die "Failed to move dist $distfile to tempdir"; |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return $tdir->directory . "/$distfile"; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |