Commit ed62be888cdab0c84d4dd2799f8e4727cfaaf9d6
1 parent
7bd38a3e
Fix --completion-* args to work from AppImage (fixes #285)
Showing
6 changed files
with
39 additions
and
12 deletions
.gitignore
ChangeLog
| 1 | 2019-06-22 Jay Berkenbilt <ejb@ql.org> | 1 | 2019-06-22 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | ||
| 3 | + * It now works to run --completion-bash and --completion-zsh when | ||
| 4 | + qpdf is started from an AppImage. | ||
| 5 | + | ||
| 3 | * Provided a more useful error message when Windows can't get | 6 | * Provided a more useful error message when Windows can't get |
| 4 | security context. Thanks to user zdenop for supplying some code. | 7 | security context. Thanks to user zdenop for supplying some code. |
| 5 | Fixes #286. | 8 | Fixes #286. |
README-maintainer
| @@ -264,15 +264,11 @@ zip -r qpdf-external-libs-src.zip external-libs | @@ -264,15 +264,11 @@ zip -r qpdf-external-libs-src.zip external-libs | ||
| 264 | When releasing on sourceforge, `external-libs` distributions go in | 264 | When releasing on sourceforge, `external-libs` distributions go in |
| 265 | `external-libs/yyyymmdd`, and qpdf distributions go in `qpdf/vvv`. | 265 | `external-libs/yyyymmdd`, and qpdf distributions go in `qpdf/vvv`. |
| 266 | 266 | ||
| 267 | -For local iteration on the AppImage generation, follow the release | ||
| 268 | -procedures for building the AppImage, but instead of passing git clone | ||
| 269 | -options to the docker command, copy qpdf to /tmp/build. You can also | ||
| 270 | -pass -e SKIP_TESTS=1 to docker to skip the test suite, useful for | ||
| 271 | -rapid iteration. Set up /tmp/build as in the release process. | ||
| 272 | - | ||
| 273 | -cp -a $PWD /tmp/build | ||
| 274 | -docker run --privileged -ti --rm -e SKIP_TESTS=1 -v /tmp/build:/tmp/build qpdfbuild | ||
| 275 | - | 267 | +For local iteration on the AppImage generation, it works to just |
| 268 | +./azure-pipelines/build-appimage and get the resulting AppImage from | ||
| 269 | +the distribution directory. You can also pass -e SKIP_TESTS=1 | ||
| 270 | +build-appimage, which passes it along to to docker, to skip the test | ||
| 271 | +suite, which useful for rapid iteration. | ||
| 276 | 272 | ||
| 277 | GENERAL BUILD STUFF | 273 | GENERAL BUILD STUFF |
| 278 | 274 |
azure-pipelines/build-appimage
| 1 | #!/bin/bash | 1 | #!/bin/bash |
| 2 | +# | ||
| 3 | +# Any extra args are passed to the docker run command before the | ||
| 4 | +# invocation of qpdfbuild. This is useful for iterating locally as | ||
| 5 | +# described in README-maintainer. | ||
| 6 | +# | ||
| 2 | set -ex | 7 | set -ex |
| 3 | cd appimage | 8 | cd appimage |
| 4 | docker build -t qpdfbuild . | 9 | docker build -t qpdfbuild . |
| @@ -6,7 +11,9 @@ rm -rf build | @@ -6,7 +11,9 @@ rm -rf build | ||
| 6 | mkdir build | 11 | mkdir build |
| 7 | cd .. | 12 | cd .. |
| 8 | git clone .git appimage/build/qpdf | 13 | git clone .git appimage/build/qpdf |
| 9 | -docker run --privileged --rm -v $PWD/appimage/build:/tmp/build qpdfbuild | 14 | +docker run --privileged --rm \ |
| 15 | + -v $PWD/appimage/build:/tmp/build ${1+"$@"} qpdfbuild | ||
| 16 | +rm -rf distribution | ||
| 10 | mkdir distribution | 17 | mkdir distribution |
| 11 | cp -p appimage/build/qpdf/appimage/build/qpdf*AppImage* distribution | 18 | cp -p appimage/build/qpdf/appimage/build/qpdf*AppImage* distribution |
| 12 | for i in distribution/*; do | 19 | for i in distribution/*; do |
manual/qpdf-manual.xml
| @@ -4337,6 +4337,13 @@ print "\n"; | @@ -4337,6 +4337,13 @@ print "\n"; | ||
| 4337 | with exit code 3 instead of 2. | 4337 | with exit code 3 instead of 2. |
| 4338 | </para> | 4338 | </para> |
| 4339 | </listitem> | 4339 | </listitem> |
| 4340 | + <listitem> | ||
| 4341 | + <para> | ||
| 4342 | + The <option>--completion-bash</option> and | ||
| 4343 | + <option>--completion-zsh</option> options now work properly | ||
| 4344 | + when qpdf is invoked as an AppImage. | ||
| 4345 | + </para> | ||
| 4346 | + </listitem> | ||
| 4340 | </itemizedlist> | 4347 | </itemizedlist> |
| 4341 | </listitem> | 4348 | </listitem> |
| 4342 | <listitem> | 4349 | <listitem> |
qpdf/qpdf.cc
| @@ -1471,10 +1471,23 @@ ArgParser::argHelp() | @@ -1471,10 +1471,23 @@ ArgParser::argHelp() | ||
| 1471 | void | 1471 | void |
| 1472 | ArgParser::argCompletionBash() | 1472 | ArgParser::argCompletionBash() |
| 1473 | { | 1473 | { |
| 1474 | + std::string progname = argv[0]; | ||
| 1475 | + // Detect if we're in an AppImage and adjust | ||
| 1476 | + std::string appdir; | ||
| 1477 | + std::string appimage; | ||
| 1478 | + if (QUtil::get_env("APPDIR", &appdir) && | ||
| 1479 | + QUtil::get_env("APPIMAGE", &appimage)) | ||
| 1480 | + { | ||
| 1481 | + if ((appdir.length() < strlen(argv[0])) && | ||
| 1482 | + (strncmp(appdir.c_str(), argv[0], appdir.length()) == 0)) | ||
| 1483 | + { | ||
| 1484 | + progname = appimage; | ||
| 1485 | + } | ||
| 1486 | + } | ||
| 1474 | std::cout << "complete -o bashdefault -o default -o nospace" | 1487 | std::cout << "complete -o bashdefault -o default -o nospace" |
| 1475 | - << " -C " << argv[0] << " " << whoami << std::endl; | 1488 | + << " -C " << progname << " " << whoami << std::endl; |
| 1476 | // Put output before error so calling from zsh works properly | 1489 | // Put output before error so calling from zsh works properly |
| 1477 | - std::string path = argv[0]; | 1490 | + std::string path = progname; |
| 1478 | size_t slash = path.find('/'); | 1491 | size_t slash = path.find('/'); |
| 1479 | if ((slash != 0) && (slash != std::string::npos)) | 1492 | if ((slash != 0) && (slash != std::string::npos)) |
| 1480 | { | 1493 | { |