public
Created

example Buildfarm module to run "make dist" and collect the results

  • Download Gist
Dist.pm
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
package PGBuild::Modules::Dist;
 
use PGBuild::Options;
use PGBuild::SCM;
 
use strict;
 
use vars qw($VERSION); $VERSION = 'REL_4.6';
 
my $hooks = {
'build' => \&build,
'install' => \&install,
};
 
sub setup
{
my $class = __PACKAGE__;
my $buildroot = shift; # where we're building
my $branch = shift; # The branch of Postgres that's being built.
my $conf = shift; # ref to the whole config object
my $pgsql = shift; # postgres build dir
 
die "can't run this module with vpath builds"
if $conf->{vpath};
 
my $self = {buildroot => $buildroot, pgbranch=> $branch, bfconf => $conf, pgsql => $pgsql};
bless ($self, $class);
 
main::register_module_hooks($self,$hooks);
 
}
 
sub build
{
my $self = shift;
 
print main::time_str(), "running make dist ",__PACKAGE__,"\n" if $verbose;
 
my @log = `cd $self->{pgsql} && make dist 2>&1`;
my $status = $? >>8;
main::writelog('make-dist',\@log);
print "======== make dist log ===========\n",@log
if ($verbose > 1);
 
main::send_result('Make-Dist',$status,\@log) if $status;
 
}
 
sub install
{
my $self = shift;
 
print main::time_str(), "copying dist files ",__PACKAGE__,"\n" if $verbose;
my $whence = $self->{pgsql};
my $where = "$self->{buildroot}/$self->{pgbranch}";
 
system("mv $whence/postgresql-*.tar* $where >/dev/null 2>&1");
my $status = $? >>8;
 
main::send_result('Copy-Dist',$status,[]) if $status;
}
 
 
1;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.