diff options
Diffstat (limited to 'make_dist')
-rwxr-xr-x | make_dist | 149 |
1 files changed, 98 insertions, 51 deletions
@@ -11,65 +11,58 @@ use File::Basename; use Cwd; use Cwd 'abs_path'; use IO::File; +use File::Path qw(rmtree); 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; +my $keep_tmp = 0; +my $ci_mode = 0; +my $version = undef; foreach my $arg (@ARGV) { if ($arg eq '--no-tests') { $run_tests = 0; } + elsif ($arg eq '--keep-tmp') + { + $keep_tmp = 1; + } + elsif ($arg eq '--ci') + { + $ci_mode = 1; + } + elsif (! defined $version) + { + $version = $arg; + } 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 ($ci_mode && (! defined $version)) { - if (m/^AC_INIT\(\[qpdf\],\[([^\)]+)\]\)/) - { - $config_version = $1; - last; - } + $version = get_version_from_configure(); } -$fh->close(); -$fh = safe_open("libqpdf/QPDF.cc"); -my $code_version = 'unknown'; -while (<$fh>) +usage() unless defined $version; +usage() unless $version =~ m/^(\d+\.\d+(?:\.(a|b|rc)?\d+)?)$/; +my $distname = "qpdf-$version"; +my $tmpdir = "/tmp/$distname"; +if ((-d $tmpdir) && (! $keep_tmp)) { - if (m/QPDF::qpdf_version = \"([^\"]+)\"/) - { - $code_version = $1; - last; - } + rmtree($tmpdir); } -$fh->close(); +run("git archive --prefix=qpdf-$version/ HEAD . | (cd /tmp; tar xf -)"); +cd($tmpdir); -$fh = safe_open("manual/qpdf-manual.xml"); -my $doc_version = 'unknown'; -while (<$fh>) -{ - if (m/swversion "([^\"]+)\"/) - { - $doc_version = $1; - last; - } -} -$fh->close(); +# Check versions +my $config_version = get_version_from_configure(); +my $code_version = get_version_from_source(); +my $doc_version = get_version_from_manual(); my $version_error = 0; if ($version ne $config_version) @@ -92,30 +85,82 @@ if ($version_error) die "$whoami: version numbers are not consistent\n"; } -run("./autogen.sh"); -run("./configure --enable-doc-maintenance --enable-werror"); +run("./configure --disable-shared --enable-doc-maintenance --enable-werror"); run("make -j8 build_manual"); run("make distclean"); -cd($pwd); -run("tar czvf $srcdir.tar.gz-candidate $srcdir"); +cd("/tmp"); +run("tar czvf $distname.tar.gz-candidate $distname"); if ($run_tests) { - cd($srcdir); + cd($tmpdir); run("./configure"); run("make -j8"); run("make check"); - cd($pwd); + cd("/tmp"); +} +my $distfile = ($ci_mode ? "$distname-ci.tar.gz" : "$distname.tar.gz"); +rename "$distname.tar.gz-candidate", $distfile or die; + +if (! $keep_tmp) +{ + rmtree($tmpdir); } -rename "$srcdir.tar.gz-candidate", "$srcdir.tar.gz" or die; print " -Source distribution created as $srcdir.tar.gz -You can now remove $srcdir. +Source distribution created as /tmp/$distfile If this is a release, don't forget to tag the version control system and make a backup of the release tar file. "; +sub get_version_from_configure +{ + my $fh = safe_open("configure.ac"); + my $config_version = 'unknown'; + while (<$fh>) + { + if (m/^AC_INIT\(\[qpdf\],\[([^\)]+)\]\)/) + { + $config_version = $1; + last; + } + } + $fh->close(); + $config_version; +} + +sub get_version_from_source +{ + my $fh = safe_open("libqpdf/QPDF.cc"); + my $code_version = 'unknown'; + while (<$fh>) + { + if (m/QPDF::qpdf_version = \"([^\"]+)\"/) + { + $code_version = $1; + last; + } + } + $fh->close(); + $code_version; +} + +sub get_version_from_manual +{ + my $fh = safe_open("manual/qpdf-manual.xml"); + my $doc_version = 'unknown'; + while (<$fh>) + { + if (m/swversion "([^\"]+)\"/) + { + $doc_version = $1; + last; + } + } + $fh->close(); + $doc_version; +} + sub safe_open { my $file = shift; @@ -138,12 +183,14 @@ sub cd sub usage { die " -Usage: $whoami [ --no-tests ] +Usage: $whoami [ --no-tests --keep-tmp ] version + +Use of --no-tests can be used for internally testing releases, but do +not use it for a real release. -$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. +$whoami creates /tmp/qpdf-<version> and deletes it when done. With +--keep-tmp, the directory is kept. This can be useful for debugging +the release process. "; } |