Commit 12b159118a67abf2c2d47492c6c502f5f5720d7f
1 parent
2b011f9d
Compare versions between CLI and library
Showing
5 changed files
with
44 additions
and
1 deletions
ChangeLog
| 1 | 2019-04-20 Jay Berkenbilt <ejb@ql.org> | 1 | 2019-04-20 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | ||
| 3 | + * When qpdf --version is run, it will detect if the qpdf CLI was | ||
| 4 | + built with a different version of qpdf than the library. This | ||
| 5 | + usually indicates that multiple versions of qpdf are installed and | ||
| 6 | + that the library path is not set up properly. This situation | ||
| 7 | + sometimes causes confusing behavior for users who are not actually | ||
| 8 | + running the version of qpdf they think they are running. | ||
| 9 | + | ||
| 3 | * Add parameter --remove-page-labels to remove page labels from | 10 | * Add parameter --remove-page-labels to remove page labels from |
| 4 | output. In qpdf 8.3.0, the behavior changed so that page labels | 11 | output. In qpdf 8.3.0, the behavior changed so that page labels |
| 5 | were preserved when merging and splitting files. Some users were | 12 | were preserved when merging and splitting files. Some users were |
README-maintainer
| @@ -103,6 +103,7 @@ RELEASE PREPARATION | @@ -103,6 +103,7 @@ RELEASE PREPARATION | ||
| 103 | * configure.ac | 103 | * configure.ac |
| 104 | * libqpdf/QPDF.cc | 104 | * libqpdf/QPDF.cc |
| 105 | * manual/qpdf-manual.xml | 105 | * manual/qpdf-manual.xml |
| 106 | + * qpdf/qpdf.cc | ||
| 106 | `make_dist` verifies this consistency. | 107 | `make_dist` verifies this consistency. |
| 107 | 108 | ||
| 108 | * Add a release entry to ChangeLog. | 109 | * Add a release entry to ChangeLog. |
make_dist
| @@ -63,6 +63,7 @@ cd($tmpdir); | @@ -63,6 +63,7 @@ cd($tmpdir); | ||
| 63 | my $config_version = get_version_from_configure(); | 63 | my $config_version = get_version_from_configure(); |
| 64 | my $code_version = get_version_from_source(); | 64 | my $code_version = get_version_from_source(); |
| 65 | my $doc_version = get_version_from_manual(); | 65 | my $doc_version = get_version_from_manual(); |
| 66 | +my $cli_version = get_version_from_cli(); | ||
| 66 | 67 | ||
| 67 | my $version_error = 0; | 68 | my $version_error = 0; |
| 68 | if ($version ne $config_version) | 69 | if ($version ne $config_version) |
| @@ -80,6 +81,11 @@ if ($version ne $doc_version) | @@ -80,6 +81,11 @@ if ($version ne $doc_version) | ||
| 80 | print "$whoami: qpdf-manual.xml version = $doc_version\n"; | 81 | print "$whoami: qpdf-manual.xml version = $doc_version\n"; |
| 81 | $version_error = 1; | 82 | $version_error = 1; |
| 82 | } | 83 | } |
| 84 | +if ($version ne $cli_version) | ||
| 85 | +{ | ||
| 86 | + print "$whoami: qpdf.cc version = $cli_version\n"; | ||
| 87 | + $version_error = 1; | ||
| 88 | +} | ||
| 83 | if ($version_error) | 89 | if ($version_error) |
| 84 | { | 90 | { |
| 85 | die "$whoami: version numbers are not consistent\n"; | 91 | die "$whoami: version numbers are not consistent\n"; |
| @@ -161,6 +167,22 @@ sub get_version_from_manual | @@ -161,6 +167,22 @@ sub get_version_from_manual | ||
| 161 | $doc_version; | 167 | $doc_version; |
| 162 | } | 168 | } |
| 163 | 169 | ||
| 170 | +sub get_version_from_cli | ||
| 171 | +{ | ||
| 172 | + my $fh = safe_open("qpdf/qpdf.cc"); | ||
| 173 | + my $cli_version = 'unknown'; | ||
| 174 | + while (<$fh>) | ||
| 175 | + { | ||
| 176 | + if (m/expected_version = \"([^\"]+)\"/) | ||
| 177 | + { | ||
| 178 | + $cli_version = $1; | ||
| 179 | + last; | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + $fh->close(); | ||
| 183 | + $cli_version; | ||
| 184 | +} | ||
| 185 | + | ||
| 164 | sub safe_open | 186 | sub safe_open |
| 165 | { | 187 | { |
| 166 | my $file = shift; | 188 | my $file = shift; |
qpdf/qpdf.cc
| @@ -30,6 +30,8 @@ static int const EXIT_WARNING = 3; | @@ -30,6 +30,8 @@ static int const EXIT_WARNING = 3; | ||
| 30 | 30 | ||
| 31 | static char const* whoami = 0; | 31 | static char const* whoami = 0; |
| 32 | 32 | ||
| 33 | +static std::string expected_version = "8.4.0"; | ||
| 34 | + | ||
| 33 | struct PageSpec | 35 | struct PageSpec |
| 34 | { | 36 | { |
| 35 | PageSpec(std::string const& filename, | 37 | PageSpec(std::string const& filename, |
| @@ -993,6 +995,17 @@ ArgParser::argPositional(char* arg) | @@ -993,6 +995,17 @@ ArgParser::argPositional(char* arg) | ||
| 993 | void | 995 | void |
| 994 | ArgParser::argVersion() | 996 | ArgParser::argVersion() |
| 995 | { | 997 | { |
| 998 | + if (expected_version != QPDF::QPDFVersion()) | ||
| 999 | + { | ||
| 1000 | + std::cerr << "***\n" | ||
| 1001 | + << "WARNING: qpdf CLI from version " << expected_version | ||
| 1002 | + << " is using library version " << QPDF::QPDFVersion() | ||
| 1003 | + << ".\n" | ||
| 1004 | + << "This probably means you have multiple versions of qpdf installed\n" | ||
| 1005 | + << "and don't have your library path configured correctly.\n" | ||
| 1006 | + << "***" | ||
| 1007 | + << std::endl; | ||
| 1008 | + } | ||
| 996 | std::cout | 1009 | std::cout |
| 997 | << whoami << " version " << QPDF::QPDFVersion() << std::endl | 1010 | << whoami << " version " << QPDF::QPDFVersion() << std::endl |
| 998 | << "Run " << whoami << " --copyright to see copyright and license information." | 1011 | << "Run " << whoami << " --copyright to see copyright and license information." |
qpdf/qtest/qpdf.test
| @@ -667,7 +667,7 @@ $n_tests += 3; | @@ -667,7 +667,7 @@ $n_tests += 3; | ||
| 667 | 667 | ||
| 668 | $td->runtest("qpdf version", | 668 | $td->runtest("qpdf version", |
| 669 | {$td->COMMAND => "qpdf --version"}, | 669 | {$td->COMMAND => "qpdf --version"}, |
| 670 | - {$td->REGEXP => "qpdf version \S+\n.*", $td->EXIT_STATUS => 0}, | 670 | + {$td->REGEXP => ".*qpdf version \S+\n.*", $td->EXIT_STATUS => 0}, |
| 671 | $td->NORMALIZE_NEWLINES); | 671 | $td->NORMALIZE_NEWLINES); |
| 672 | $td->runtest("qpdf copyright contains version too", | 672 | $td->runtest("qpdf copyright contains version too", |
| 673 | {$td->COMMAND => "qpdf --copyright"}, | 673 | {$td->COMMAND => "qpdf --copyright"}, |