use Getopt::Long qw(:config bundling no_ignore_case);
use POSIX;
+use Cwd;
use strict;
use warnings;
my $help = 0;
-GetOptions ("h|help" => \$help);
+my $build_binary = 1;
+GetOptions ("h|help" => \$help,
+ "binary!" => \$build_binary);
usage () if $help;
# Select build number.
my $build_number = POSIX::strftime("%Y%m%d%H%M%S", localtime);
+my $topdir = getcwd();
+
# Create build directory.
my $builddir = "builds/$build_number";
mkdir "builds" or die "builds: mkdir: $!\n" if ! -d "builds";
print "\t$var=$value\n";
}
+sub save_result {
+ my ($src, $rm_src) = @_;
+ my ($dst) = $src;
+ $dst =~ s(^.*/)();
+ $dst = "$resultsdir/$dst";
+
+ start_step ("Saving $src");
+ run ("cp -R $src $dst");
+
+ if (defined ($rm_src) && $rm_src) {
+ run ("rm $src");
+ }
+
+ return $dst;
+}
+
+sub save_result_if_exists {
+ my ($src, $rm_src) = @_;
+ if (-e $src) {
+ save_result (@_);
+ } else {
+ start_step ("$src does not exist, cannot save");
+ }
+}
+
my $tarball;
if (@ARGV == 2) {
my ($repo, $branch) = @ARGV;
run ("cd $builddir/pspp$build_number && mkdir _build && cd _build && ../configure");
# Distribute.
- start_step ("Make dist tarball");
+ start_step ("Make source tarball");
run ("cd $builddir/pspp$build_number/_build && make dist");
+ my $tarname = "pspp-$version-g$abbrev_commit.tar.gz";
+ $tarball = save_result ("$builddir/pspp$build_number/_build/$tarname", 1);
- $tarball = "$builddir/pspp$build_number/_build/pspp-$version-g$abbrev_commit.tar.gz";
+ # Build the manual in various formats.
+ start_step ("Build manual");
+ run ("cd $builddir/pspp$build_number/doc && GENDOCS_TEMPLATE_DIR=$topdir/gnulib/doc $topdir/gnulib/build-aux/gendocs.sh --email bug-gnu-pspp\@gnu.org pspp \\\"GNU PSPP Manual\\\"");
+ save_result ("$builddir/pspp$build_number/doc/manual");
} else {
$tarball = $ARGV[0];
}
-start_step ("Determining $tarball target directory");
-my $sample_filename = `zcat $tarball | tar tf - | head -1`;
-my ($tarball_dir) = $sample_filename =~ m%^(?:[./])*([^/]+)/%;
-set_var ("dist_dir", $tarball_dir);
-
-start_step ("Extracting $tarball into $builddir/$tarball_dir");
-run ("zcat $tarball | (cd $builddir && tar xf -)");
-
-start_step ("Extracting tar version");
-my ($version) = `cd $builddir/$tarball_dir && ./configure --version | head -1`
- =~ /configure (\S+)$/;
-set_var ("dist_version", $version);
-my ($binary_version) = "$version-$builder-build$build_number";
-set_var ("binary_version", $binary_version);
-
-start_step ("Configuring");
-run ("chmod -R a-w $builddir/$tarball_dir");
-run ("chmod u+w $builddir/$tarball_dir");
-run ("mkdir $builddir/$tarball_dir/_build");
-run ("chmod a-w $builddir/$tarball_dir");
-run ("cd $builddir/$tarball_dir/_build && ../configure --enable-relocatable --prefix=''");
+if ($build_binary) {
+ start_step ("Determining $tarball target directory");
+ my $sample_filename = `zcat $tarball | tar tf - | head -1`;
+ my ($tarball_dir) = $sample_filename =~ m%^(?:[./])*([^/]+)/%;
+ set_var ("dist_dir", $tarball_dir);
+
+ start_step ("Extracting $tarball into $builddir/$tarball_dir");
+ run ("zcat $tarball | (cd $builddir && tar xf -)");
+
+ start_step ("Extracting tar version");
+ my ($version) = `cd $builddir/$tarball_dir && ./configure --version | head -1`
+ =~ /configure (\S+)$/;
+ set_var ("dist_version", $version);
+ my ($binary_version) = "$version-$builder-build$build_number";
+ set_var ("binary_version", $binary_version);
+
+ start_step ("Configuring");
+ run ("chmod -R a-w $builddir/$tarball_dir");
+ run ("chmod u+w $builddir/$tarball_dir");
+ run ("mkdir $builddir/$tarball_dir/_build");
+ run ("chmod a-w $builddir/$tarball_dir");
+ my $ok = try_run ("cd $builddir/$tarball_dir/_build && ../configure --enable-relocatable --prefix=''");
+ for my $basename ("config.h", "config.log") {
+ save_result_if_exists ("$builddir/$tarball_dir/_build/$basename");
+ }
+ exit 1 if !$ok;
-start_step ("Build");
-run ("cd $builddir/$tarball_dir/_build && make");
+ start_step ("Build");
+ run ("cd $builddir/$tarball_dir/_build && make");
-start_step ("Install");
-run ("cd $builddir/$tarball_dir/_build && make install DESTDIR=\$PWD/pspp-$binary_version");
+ start_step ("Install");
+ run ("cd $builddir/$tarball_dir/_build && make install DESTDIR=\$PWD/pspp-$binary_version");
-start_step ("Make binary distribution");
-run ("cd $builddir/$tarball_dir/_build && tar cfz pspp-$binary_version.tar.gz pspp-$binary_version");
+ start_step ("Make binary distribution");
+ run ("cd $builddir/$tarball_dir/_build && tar cfz pspp-$binary_version.tar.gz pspp-$binary_version");
+ save_result ("$builddir/$tarball_dir/_build/pspp-$binary_version.tar.gz", 1);
-start_step ("Check");
-run ("cd $builddir/$tarball_dir/_build && make check");
+ start_step ("Check");
+ $ok = try_run ("cd $builddir/$tarball_dir/_build && make check");
+ for my $basename ("tests/testsuite.log", "tests/testsuite.dir") {
+ save_result_if_exists ("$builddir/$tarball_dir/_build/$basename");
+ }
+ exit 1 if !$ok;
-start_step ("Uninstall");
-run ("cd $builddir/$tarball_dir/_build && make uninstall DESTDIR=\$PWD/pspp-$binary_version");
+ start_step ("Uninstall");
+ run ("cd $builddir/$tarball_dir/_build && make uninstall DESTDIR=\$PWD/pspp-$binary_version");
-start_step ("Check uninstall");
-run ("cd $builddir/$tarball_dir/_build && make distuninstallcheck distuninstallcheck_dir=\$PWD/pspp-$binary_version");
+ start_step ("Check uninstall");
+ run ("cd $builddir/$tarball_dir/_build && make distuninstallcheck distuninstallcheck_dir=\$PWD/pspp-$binary_version");
-# distcleancheck
+ # distcleancheck
+}
start_step ("Success");
}
sub run {
+ exit 1 if !try_run(@_);
+}
+
+sub try_run {
my ($command) = @_;
print LOG "$command\n";
close (COMMAND);
print "\r \r";
- if ($? == 0) {
- return;
- } elsif ($? & 127) {
+ return 1 if !$?;
+
+ if ($? & 127) {
printf "%s: child died with signal %d, %s coredump\n",
$command, ($? & 127), ($? & 128) ? 'with' : 'without';
} else {
printf "%s: child exited with value %d\n", $command, $? >> 8;
}
- exit 1;
+ return 0;
}
-
-# Clone source
-# Add build number
-# Tag build
-# Clone gnulib at correct commit number
-# Run gnulib-tool.
-# Run configure
-# Make dist
-
-# Unpack dist
-# Run configure
-# Check
-# Install
-# Make binary dist
-# Build mingw32 installer
-# Other distcheck stuff?
-
-# Distribute manual in various formats