Initial commit
[buildfarm-client.git] / EximBuild / Modules / FileTextArrayFDW.pm
1
2 # Package Namespace is hardcoded. Modules must live in
3 # EximBuild::Modules
4
5 package EximBuild::Modules::FileTextArrayFDW;
6
7 use EximBuild::Options;
8 use EximBuild::SCM;
9
10 use strict;
11
12 # strip required namespace from package name
13 (my $MODULE = __PACKAGE__ ) =~ s/EximBuild::Modules:://;
14
15 use vars qw($VERSION); $VERSION = 'REL_0.1';
16
17 my $hooks = {
18     'checkout' => \&checkout,
19     'setup-target' => \&setup_target,
20
21     # 'need-run' => \&need_run,
22     # 'configure' => \&configure,
23     'build' => \&build,
24
25     # 'check' => \&check,
26     'install' => \&install,
27     'installcheck' => \&installcheck,
28     'cleanup' => \&cleanup,
29 };
30
31 sub setup
32 {
33     my $class = __PACKAGE__;
34
35     my $buildroot = shift; # where we're building
36     my $branch = shift; # The branch of exim that's being built.
37     my $conf = shift;  # ref to the whole config object
38     my $exim = shift; # exim build dir
39
40     #return unless $branch ge 'REL9_1_STABLE' || $branch eq 'HEAD';
41
42     # could even set up several of these (e.g. for different branches)
43     my $self  = {
44         buildroot => $buildroot,
45         eximbranch=> $branch,
46         bfconf => $conf,
47         exim => $exim
48     };
49     bless($self, $class);
50
51     my $scmconf ={
52         scm => 'git',
53         scmrepo => 'git://github.com/adunstan/file_text_array_fdw.git',
54         git_reference => undef,
55         git_keep_mirror => 'true',
56         git_ignore_mirror_failure => 'true',
57         build_root => $self->{buildroot},
58     };
59
60     $self->{scm} = new EximBuild::SCM $scmconf, 'file_text_array_fdw';
61     my $where = $self->{scm}->get_build_path();
62     $self->{where} = $where;
63
64     # for each instance you create, do:
65     main::register_module_hooks($self,$hooks);
66
67 }
68
69 sub checkout
70 {
71     my $self = shift;
72     my $savescmlog = shift; # array ref to the log lines
73
74     print main::time_str(), "checking out $MODULE\n" if $verbose;
75
76     my $scmlog = $self->{scm}->checkout($self->{eximbranch});
77
78     push(@$savescmlog,
79         "------------- $MODULE checkout ----------------\n",@$scmlog);
80 }
81
82 sub setup_target
83 {
84     my $self = shift;
85
86     # copy the code or setup a vpath dir if supported as appropriate
87
88     print main::time_str(), "copying source to  ...$self->{where}\n"
89       if $verbose;
90
91     $self->{scm}->copy_source(undef);
92
93 }
94
95 sub need_run
96 {
97     my $self = shift;
98     my $run_needed = shift; # ref to flag
99
100     # to force a run do:
101     # $$run_needed = 1;
102
103     print main::time_str(), "checking if run needed by $MODULE\n"
104       if        $verbose;
105
106 }
107
108 sub configure
109 {
110     my $self = shift;
111
112     print main::time_str(), "configuring $MODULE\n" if  $verbose;
113
114 }
115
116 sub build
117 {
118     my $self = shift;
119
120     print main::time_str(), "building $MODULE\n" if     $verbose;
121
122     my $cmd = "PATH=../inst:$ENV{PATH} make USE_PGXS=1";
123
124     my @makeout = `cd $self->{where} && $cmd 2>&1`;
125
126     my $status = $? >>8;
127     main::writelog("$MODULE-build",\@makeout);
128     print "======== make log ===========\n",@makeout if ($verbose > 1);
129     main::send_result("$MODULE-build",$status,\@makeout) if $status;
130
131 }
132
133 sub install
134 {
135     my $self = shift;
136
137     print main::time_str(), "installing $MODULE\n" if   $verbose;
138
139     my $cmd = "PATH=../inst:$ENV{PATH} make USE_PGXS=1 install";
140
141     my @log = `cd $self->{where} && $cmd 2>&1`;
142
143     my $status = $? >>8;
144     main::writelog("$MODULE-install",\@log);
145     print "======== install log ===========\n",@log if ($verbose > 1);
146     main::send_result("$MODULE-install",$status,\@log) if $status;
147
148 }
149
150 sub check
151 {
152     my $self = shift;
153
154     print main::time_str(), "checking ",__PACKAGE__,"\n" if     $verbose;
155 }
156
157 sub installcheck
158 {
159     my $self = shift;
160     my $locale = shift;
161
162     print main::time_str(), "install-checking $MODULE\n" if     $verbose;
163
164     my $cmd = "PATH=../inst:$ENV{PATH} make USE_PGXS=1 installcheck";
165
166     my @log = `cd $self->{where} && $cmd 2>&1`;
167
168     my $status = $? >>8;
169     my $installdir = "$self->{buildroot}/$self->{eximbranch}/inst";
170     my @logfiles =("$self->{where}/regression.diffs","$installdir/logfile");
171     foreach my $logfile(@logfiles)
172     {
173         last unless $status;
174         next unless (-e $logfile );
175         push(@log,"\n\n================== $logfile ==================\n");
176         my $handle;
177         open($handle,$logfile);
178         while(<$handle>)
179         {
180             push(@log,$_);
181         }
182         close($handle);
183     }
184
185     main::writelog("$MODULE-installcheck-$locale",\@log);
186     print "======== installcheck ($locale) log ===========\n",@log
187       if ($verbose > 1);
188     main::send_result("$MODULE-installcheck-$locale",$status,\@log) if $status;
189
190 }
191
192 sub cleanup
193 {
194     my $self = shift;
195
196     print main::time_str(), "cleaning up $MODULE\n" if  $verbose > 1;
197
198     system("rm -rf $self->{where}");
199 }
200
201 1;