[open-ils-commits] r898 - conifer/branches/rel_1_6_0/tools (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Jun 27 12:20:35 EDT 2010
Author: dbs
Date: 2010-06-27 12:20:32 -0400 (Sun, 27 Jun 2010)
New Revision: 898
Added:
conifer/branches/rel_1_6_0/tools/autobuild.pl
Log:
Simple, mostly stubbed, script for autobuilding/packaging/testing arbitrary branches
We probably actually want http://hudson-ci.org/ though.
Added: conifer/branches/rel_1_6_0/tools/autobuild.pl
===================================================================
--- conifer/branches/rel_1_6_0/tools/autobuild.pl (rev 0)
+++ conifer/branches/rel_1_6_0/tools/autobuild.pl 2010-06-27 16:20:32 UTC (rev 898)
@@ -0,0 +1,139 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use File::Spec;
+use File::Path qw/make_path remove_tree/;
+
+=head1 Purpose
+
+This script is intended to automate the process of checking out current
+versions of one or more branches (including trunk) from a Subversion
+repository, run through the configure and make processes to ensure that
+the basic build is successful, and then run additional steps such as
+creating the database schema or running available tests.
+
+It's a super-simple stupid script.
+
+=head2 Usage
+
+Pass the relative directories for the branches that you want to build as
+arguments to the script; for example, if you want to build both the
+rel_1_6_0 branch and trunk, issue the following command:
+
+perl autobuild.pl branches/rel_1_6_0 trunk
+
+The script will create timestamped log files for the output from the various
+steps in the log directory.
+
+=head2 TODO
+
+Lots. I don't intend this to ever get to the level of a hudson continuous
+integration server, though.
+
+=over
+
+=item * Start using Getopt::Long to avoid hard-coded variables
+
+=item * Highlight errors at the various steps
+
+=item * Flesh out the packaging step to generate tarballs
+
+=back
+
+=cut
+
+my $repo_base = 'svn://svn.open-ils.org/';
+my $repo_type = 'ILS/';
+my $repo = $repo_base . $repo_type;
+my $work_dir = '/tmp';
+my $export_dir = '/tmp/export';
+my $log_dir = '/tmp';
+my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
+my $tstamp = ($year + 1900) . "-" . ($mon + 1) . "-$mday\_$hour-$min";
+
+for my $release (@ARGV) {
+ my $export_dir = checkout($release);
+ configure($release, $export_dir);
+ package($release, $export_dir);
+ build($release, $export_dir);
+ test($release, $export_dir);
+}
+
+=head2 sub checkout($release)
+
+Check to see if the local repo has already been created; if so, then just
+update it. Otherwise, do a clean checkout.
+
+Then export the source to a clean export directory.
+
+Returns the export directory name
+
+=cut
+
+sub checkout {
+ my $release = shift;
+ my $source = $repo . $release;
+ my $export = File::Spec->catdir($export_dir, $release);
+
+ my @log;
+
+ chdir($work_dir);
+ if (-d $release) {
+ print "Release directory has already been created; just update\n";
+ chdir($release);
+ @log = `svn up 2>&1`;
+ } else {
+ print "Check it out\n";
+ @log = `svn co $source $release 2>&1`;
+ chdir($release);
+ }
+
+ # Now export the code to a clean export directory
+ # First we create the complete path, then trim the base directory
+ # ("svn export" won't export to an existing directory)
+ make_path(File::Spec->catdir($export, '../'));
+ remove_tree($export);
+ print "Exporting the code\n";
+ `svn export . $export 2>&1`;
+
+ logit($release, 'svn', \@log);
+
+ return $export;
+}
+
+sub build {
+ my ($release, $export_dir) = @_;
+ chdir($export_dir);
+ my @log = `make 2>&1`;
+ logit($release, 'build', \@log);
+}
+
+sub configure {
+ my ($release, $export_dir) = @_;
+ chdir($export_dir);
+ my @log = `./autogen.sh && ./configure --prefix=/openils --sysconf=/openils/conf 2>&1`;
+ logit($release, 'config', \@log);
+}
+
+sub package {
+ my ($release, $export_dir) = @_;
+ chdir($export_dir);
+
+ # Remove some files
+ # Generate changelog
+ chdir('..');
+ # Create tarball
+ print "package stub\n";
+}
+
+sub test {
+ my ($release, $export_dir) = @_;
+ print "test stub\n";
+}
+
+sub logit {
+ my ($release, $type, $log) = @_;
+ open(LOGFH, '>', File::Spec->catfile($work_dir, $release, "$type\_$tstamp.log"));
+ print LOGFH @$log;
+ close(LOGFH);
+}
More information about the open-ils-commits
mailing list