mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-23 03:18:59 +00:00
150 lines
2.7 KiB
Perl
Executable File
150 lines
2.7 KiB
Perl
Executable File
#!/usr/bin/env perl
|
|
#
|
|
# This program creates a source distribution of qpdf. For details,
|
|
# see README-maintainer.md.
|
|
#
|
|
|
|
require 5.008;
|
|
use warnings;
|
|
use strict;
|
|
use File::Basename;
|
|
use Cwd;
|
|
use Cwd 'abs_path';
|
|
use IO::File;
|
|
|
|
my $whoami = basename($0);
|
|
my $srcdir = basename(dirname($0));
|
|
my $pwd = getcwd();
|
|
usage() unless $pwd eq abs_path(dirname(dirname($0)));
|
|
|
|
my $run_tests = 1;
|
|
foreach my $arg (@ARGV)
|
|
{
|
|
if ($arg eq '--no-tests')
|
|
{
|
|
$run_tests = 0;
|
|
}
|
|
else
|
|
{
|
|
usage();
|
|
}
|
|
}
|
|
|
|
usage() unless $srcdir =~ m/^qpdf-(\d+\.\d+(?:\.(a|b|rc)?\d+)?)$/;
|
|
my $version = $1;
|
|
cd($srcdir);
|
|
|
|
# Check versions
|
|
my $fh = safe_open("configure.ac");
|
|
my $config_version = 'unknown';
|
|
while (<$fh>)
|
|
{
|
|
if (m/^AC_INIT\(\[qpdf\],\[([^\)]+)\]\)/)
|
|
{
|
|
$config_version = $1;
|
|
last;
|
|
}
|
|
}
|
|
$fh->close();
|
|
|
|
$fh = safe_open("libqpdf/QPDF.cc");
|
|
my $code_version = 'unknown';
|
|
while (<$fh>)
|
|
{
|
|
if (m/QPDF::qpdf_version = \"([^\"]+)\"/)
|
|
{
|
|
$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)
|
|
{
|
|
print "$whoami: QPDF.cc version = $code_version\n";
|
|
$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";
|
|
}
|
|
|
|
run("./autogen.sh");
|
|
run("./configure --enable-doc-maintenance --enable-werror");
|
|
run("make -j8 build_manual");
|
|
run("make distclean");
|
|
cd($pwd);
|
|
run("tar czvf $srcdir.tar.gz-candidate $srcdir");
|
|
if ($run_tests)
|
|
{
|
|
cd($srcdir);
|
|
run("./configure");
|
|
run("make -j8");
|
|
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 [ --no-tests ]
|
|
|
|
$whoami must be run from the parent of a directory called
|
|
qpdf-<version> which must contain 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.
|
|
|
|
";
|
|
}
|