2008-04-29 12:55:25 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
#
|
|
|
|
# This program creates a source distribution of qpdf. For details,
|
2017-08-22 17:10:47 +00:00
|
|
|
# see README-maintainer.md.
|
2008-04-29 12:55:25 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
require 5.008;
|
2011-08-10 20:43:12 +00:00
|
|
|
use warnings;
|
2008-04-29 12:55:25 +00:00
|
|
|
use strict;
|
2011-08-10 20:43:12 +00:00
|
|
|
use File::Basename;
|
2008-04-29 12:55:25 +00:00
|
|
|
use Cwd;
|
|
|
|
use IO::File;
|
|
|
|
|
2011-08-10 20:43:12 +00:00
|
|
|
my $whoami = basename($0);
|
2008-04-29 12:55:25 +00:00
|
|
|
|
|
|
|
usage() unless @ARGV >= 1;
|
|
|
|
my $srcdir = shift(@ARGV);
|
|
|
|
my $run_tests = 1;
|
|
|
|
if (@ARGV)
|
|
|
|
{
|
|
|
|
if ($ARGV[0] eq '--no-tests')
|
|
|
|
{
|
|
|
|
$run_tests = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$srcdir =~ s,/$,,;
|
2008-05-06 15:44:50 +00:00
|
|
|
usage() unless $srcdir =~ m/^qpdf-(\d+\.\d+(?:\.(a|b|rc)?\d+)?)$/;
|
2008-04-29 12:55:25 +00:00
|
|
|
my $version = $1;
|
|
|
|
usage() unless -d $srcdir;
|
|
|
|
|
|
|
|
my $pwd = getcwd();
|
|
|
|
cd($srcdir);
|
|
|
|
|
|
|
|
# Check versions
|
|
|
|
my $fh = safe_open("configure.ac");
|
|
|
|
my $config_version = 'unknown';
|
|
|
|
while (<$fh>)
|
|
|
|
{
|
2012-06-21 21:10:34 +00:00
|
|
|
if (m/^AC_INIT\(\[qpdf\],\[([^\)]+)\]\)/)
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
$config_version = $1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$fh->close();
|
|
|
|
|
2009-10-24 04:47:17 +00:00
|
|
|
$fh = safe_open("libqpdf/QPDF.cc");
|
2008-04-29 12:55:25 +00:00
|
|
|
my $code_version = 'unknown';
|
|
|
|
while (<$fh>)
|
|
|
|
{
|
2009-10-24 13:41:03 +00:00
|
|
|
if (m/QPDF::qpdf_version = \"([^\"]+)\"/)
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
$code_version = $1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$fh->close();
|
|
|
|
|
|
|
|
$fh = safe_open("manual/qpdf-manual.xml");
|
|
|
|
my $doc_version = 'unknown';
|
|
|
|
while (<$fh>)
|
|
|
|
{
|
|
|
|
if (m/swversion "([^\"]+)\"/)
|
|
|
|
{
|
|
|
|
$doc_version = $1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$fh->close();
|
|
|
|
|
|
|
|
my $version_error = 0;
|
|
|
|
if ($version ne $config_version)
|
|
|
|
{
|
|
|
|
print "$whoami: configure.ac version = $config_version\n";
|
|
|
|
$version_error = 1;
|
|
|
|
}
|
|
|
|
if ($version ne $code_version)
|
|
|
|
{
|
2009-10-24 13:41:03 +00:00
|
|
|
print "$whoami: QPDF.cc version = $code_version\n";
|
2008-04-29 12:55:25 +00:00
|
|
|
$version_error = 1;
|
|
|
|
}
|
|
|
|
if ($version ne $doc_version)
|
|
|
|
{
|
|
|
|
print "$whoami: qpdf-manual.xml version = $doc_version\n";
|
|
|
|
$version_error = 1;
|
|
|
|
}
|
|
|
|
if ($version_error)
|
|
|
|
{
|
|
|
|
die "$whoami: version numbers are not consistent\n";
|
|
|
|
}
|
|
|
|
|
2010-03-27 13:17:17 +00:00
|
|
|
run("./autogen.sh");
|
2011-06-23 18:40:37 +00:00
|
|
|
run("./configure --enable-doc-maintenance --enable-werror");
|
2015-10-31 22:59:04 +00:00
|
|
|
run("make -j8 build_manual");
|
2008-04-29 12:55:25 +00:00
|
|
|
run("make distclean");
|
|
|
|
cd($pwd);
|
|
|
|
run("tar czvf $srcdir.tar.gz-candidate $srcdir");
|
|
|
|
if ($run_tests)
|
|
|
|
{
|
|
|
|
cd($srcdir);
|
|
|
|
run("./configure");
|
2012-12-31 15:57:45 +00:00
|
|
|
run("make -j8");
|
2008-04-29 12:55:25 +00:00
|
|
|
run("make check");
|
|
|
|
cd($pwd);
|
|
|
|
}
|
|
|
|
rename "$srcdir.tar.gz-candidate", "$srcdir.tar.gz" or die;
|
|
|
|
|
|
|
|
print "
|
|
|
|
Source distribution created as $srcdir.tar.gz
|
|
|
|
You can now remove $srcdir.
|
|
|
|
If this is a release, don't forget to tag the version control system and
|
|
|
|
make a backup of the release tar file.
|
|
|
|
|
|
|
|
";
|
|
|
|
|
|
|
|
sub safe_open
|
|
|
|
{
|
|
|
|
my $file = shift;
|
|
|
|
my $fh = new IO::File("<$file") or die "$whoami: can't open $file: $!";
|
|
|
|
$fh;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub run
|
|
|
|
{
|
|
|
|
my $cmd = shift;
|
|
|
|
system($cmd) == 0 or die "$whoami: $cmd failed\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub cd
|
|
|
|
{
|
|
|
|
my $dir = shift;
|
|
|
|
chdir($dir) or die;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub usage
|
|
|
|
{
|
|
|
|
die "
|
|
|
|
Usage: $whoami qpdf-version [ --no-tests ]
|
|
|
|
|
|
|
|
qpdf-version must be a directory containing a pristine export of that
|
|
|
|
version of qpdf from the version control system. Use of --no-tests
|
|
|
|
can be used for internally testing releases, but do not use it for a
|
|
|
|
real release.
|
|
|
|
|
|
|
|
";
|
|
|
|
}
|