Compare versions between CLI and library

This commit is contained in:
Jay Berkenbilt 2019-04-20 20:03:59 -04:00
parent 2b011f9d81
commit 12b159118a
5 changed files with 44 additions and 1 deletions

View File

@ -1,5 +1,12 @@
2019-04-20 Jay Berkenbilt <ejb@ql.org>
* When qpdf --version is run, it will detect if the qpdf CLI was
built with a different version of qpdf than the library. This
usually indicates that multiple versions of qpdf are installed and
that the library path is not set up properly. This situation
sometimes causes confusing behavior for users who are not actually
running the version of qpdf they think they are running.
* Add parameter --remove-page-labels to remove page labels from
output. In qpdf 8.3.0, the behavior changed so that page labels
were preserved when merging and splitting files. Some users were

View File

@ -103,6 +103,7 @@ RELEASE PREPARATION
* configure.ac
* libqpdf/QPDF.cc
* manual/qpdf-manual.xml
* qpdf/qpdf.cc
`make_dist` verifies this consistency.
* Add a release entry to ChangeLog.

View File

@ -63,6 +63,7 @@ cd($tmpdir);
my $config_version = get_version_from_configure();
my $code_version = get_version_from_source();
my $doc_version = get_version_from_manual();
my $cli_version = get_version_from_cli();
my $version_error = 0;
if ($version ne $config_version)
@ -80,6 +81,11 @@ if ($version ne $doc_version)
print "$whoami: qpdf-manual.xml version = $doc_version\n";
$version_error = 1;
}
if ($version ne $cli_version)
{
print "$whoami: qpdf.cc version = $cli_version\n";
$version_error = 1;
}
if ($version_error)
{
die "$whoami: version numbers are not consistent\n";
@ -161,6 +167,22 @@ sub get_version_from_manual
$doc_version;
}
sub get_version_from_cli
{
my $fh = safe_open("qpdf/qpdf.cc");
my $cli_version = 'unknown';
while (<$fh>)
{
if (m/expected_version = \"([^\"]+)\"/)
{
$cli_version = $1;
last;
}
}
$fh->close();
$cli_version;
}
sub safe_open
{
my $file = shift;

View File

@ -30,6 +30,8 @@ static int const EXIT_WARNING = 3;
static char const* whoami = 0;
static std::string expected_version = "8.4.0";
struct PageSpec
{
PageSpec(std::string const& filename,
@ -993,6 +995,17 @@ ArgParser::argPositional(char* arg)
void
ArgParser::argVersion()
{
if (expected_version != QPDF::QPDFVersion())
{
std::cerr << "***\n"
<< "WARNING: qpdf CLI from version " << expected_version
<< " is using library version " << QPDF::QPDFVersion()
<< ".\n"
<< "This probably means you have multiple versions of qpdf installed\n"
<< "and don't have your library path configured correctly.\n"
<< "***"
<< std::endl;
}
std::cout
<< whoami << " version " << QPDF::QPDFVersion() << std::endl
<< "Run " << whoami << " --copyright to see copyright and license information."

View File

@ -667,7 +667,7 @@ $n_tests += 3;
$td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"},
{$td->REGEXP => "qpdf version \\S+\n.*", $td->EXIT_STATUS => 0},
{$td->REGEXP => ".*qpdf version \\S+\n.*", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("qpdf copyright contains version too",
{$td->COMMAND => "qpdf --copyright"},