From 139d5de3d70040b8326086f2b2aca8035293a698 Mon Sep 17 00:00:00 2001 From: dbs Date: Sun, 27 Jun 2010 16:20:32 +0000 Subject: [PATCH] Simple, mostly stubbed, script for autobuilding/packaging/testing arbitrary branches We probably actually want http://hudson-ci.org/ though. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_1_6_0@898 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- tools/autobuild.pl | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 tools/autobuild.pl diff --git a/tools/autobuild.pl b/tools/autobuild.pl new file mode 100644 index 0000000000..71e98b6035 --- /dev/null +++ b/tools/autobuild.pl @@ -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); +} -- 2.11.0