3 use Getopt::Long qw(:config bundling no_ignore_case);
10 GetOptions ("h|help" => \$help);
14 die "$0: exactly one or two nonoption arguments are required\n"
15 if @ARGV != 1 && @ARGV != 2;
17 my $buildslave = `hostname`;
20 # Select build number.
21 my $buildnumber = POSIX::strftime("%Y%m%d%H%M%S", localtime);
22 print "\tBUILDNUMBER=$buildnumber\n";
24 # Create build directory.
25 my $builddir = "builds/$buildnumber";
26 print "Create $builddir\n";
27 mkdir "builds" or die "builds: mkdir: $!\n" if ! -d "builds";
28 mkdir $builddir or die "$builddir: mkdir: $!\n";
31 my ($repo, $branch) = @ARGV;
34 print "Fetch $repo, branch $branch\n";
35 run ("git fetch $repo +$branch:buildtmp/$$/pspp");
37 # Get revision number.
38 my $revision = `git rev-parse buildtmp/$$/pspp`;
40 print "\tREVISION=$revision\n";
41 my $abbrev_revision = substr ($revision, 0, 6);
44 print "Extract branch into $builddir/pspp$buildnumber\n";
45 run ("git archive --format=tar --prefix=pspp$buildnumber/ buildtmp/$$/pspp | (cd $builddir && tar xf -)");
47 # Extract version number.
48 print "Extract version number\n";
49 my $trace = `cd $builddir/pspp$buildnumber && autoconf -t AC_INIT`;
51 my ($file, $line, $macro, $package, $version, @rest) = split (':', $trace);
52 print "\tVERSION=$version\n";
54 # Append -g012345 to AC_INIT version number.
55 my $fullname = "$builddir/pspp$buildnumber/$file";
56 open (OLDFILE, '<', $fullname)
57 or die "opening $fullname failed: $!\n";
58 open (NEWFILE, '>', "$fullname.new")
59 or die "creating $fullname.new failed: $!\n";
64 print NEWFILE "AC_INIT([[$package]]";
65 print NEWFILE ", [[$version-g$abbrev_revision]]";
66 print NEWFILE ", [[$_]]" foreach @rest;
72 rename ("$fullname.new", $fullname)
73 or die "rename $fullname.new to $fullname failed: $!\n";
75 # Add note to beginning of NEWS (otherwise "make dist" fails).
76 $fullname = "$builddir/pspp$buildnumber/NEWS";
77 open (OLDFILE, '<', $fullname)
78 or die "opening $fullname failed: $!\n";
79 open (NEWFILE, '>', "$fullname.new")
80 or die "creating $fullname.new failed: $!\n";
81 my $found_changes = 0;
83 if (!$found_changes && /^Changes/) {
86 Changes from $version to $version-g$abbrev_revision:
88 * Built automatically from commit $revision
89 in branch $branch on build slave $buildslave
97 rename ("$fullname.new", $fullname)
98 or die "rename $fullname.new to $fullname failed: $!\n";
100 # Get Gnulib commit number.
102 $fullname = "$builddir/pspp$buildnumber/README.Git";
103 open (README_GIT, '<', $fullname)
104 or die "opening $fullname failed: $!\n";
105 while (<README_GIT>) {
106 ($gnulib_commit) = /^\s+commit ([0-9a-fA-F]{8,})/ and last;
108 die "$fullname does not specify a Git commit number\n"
109 if !defined ($gnulib_commit);
110 print "\tGNULIB_REVISION=$gnulib_commit\n";
115 $0, for building and testing PSPP
116 usage: $0 [OPTIONS] [TARBALL | REPO REFSPEC]
117 where TARBALL is the name of a tarball produced by "make dist"
118 or REPO and REFSPEC are a Git repo and refspec (e.g. branch) to clone.
121 --help Print this usage message and exit
128 return if system ($command) == 0;
130 print "$command: failed to execute: $!\n";
132 printf "%s: child died with signal %d, %s coredump\n",
133 $command, ($? & 127), ($? & 128) ? 'with' : 'without';
135 printf "%s: child exited with value %d\n", $command, $? >> 8;
143 # Clone gnulib at correct commit number
153 # Build mingw32 installer
154 # Other distcheck stuff?