2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-04 11:20:53 +00:00

Fix --completion-* args to work from AppImage (fixes #285)

This commit is contained in:
Jay Berkenbilt 2019-06-22 16:38:17 -04:00
parent 7bd38a3eb3
commit ed62be888c
6 changed files with 39 additions and 12 deletions

1
.gitignore vendored
View File

@ -26,3 +26,4 @@ manual/print.xsl
qpdf/build/ qpdf/build/
zlib-flate/build/ zlib-flate/build/
fuzz/qpdf_fuzzer_seed_corpus/ fuzz/qpdf_fuzzer_seed_corpus/
distribution/

View File

@ -1,5 +1,8 @@
2019-06-22 Jay Berkenbilt <ejb@ql.org> 2019-06-22 Jay Berkenbilt <ejb@ql.org>
* It now works to run --completion-bash and --completion-zsh when
qpdf is started from an AppImage.
* Provided a more useful error message when Windows can't get * Provided a more useful error message when Windows can't get
security context. Thanks to user zdenop for supplying some code. security context. Thanks to user zdenop for supplying some code.
Fixes #286. Fixes #286.

View File

@ -264,15 +264,11 @@ zip -r qpdf-external-libs-src.zip external-libs
When releasing on sourceforge, `external-libs` distributions go in When releasing on sourceforge, `external-libs` distributions go in
`external-libs/yyyymmdd`, and qpdf distributions go in `qpdf/vvv`. `external-libs/yyyymmdd`, and qpdf distributions go in `qpdf/vvv`.
For local iteration on the AppImage generation, follow the release For local iteration on the AppImage generation, it works to just
procedures for building the AppImage, but instead of passing git clone ./azure-pipelines/build-appimage and get the resulting AppImage from
options to the docker command, copy qpdf to /tmp/build. You can also the distribution directory. You can also pass -e SKIP_TESTS=1
pass -e SKIP_TESTS=1 to docker to skip the test suite, useful for build-appimage, which passes it along to to docker, to skip the test
rapid iteration. Set up /tmp/build as in the release process. suite, which useful for rapid iteration.
cp -a $PWD /tmp/build
docker run --privileged -ti --rm -e SKIP_TESTS=1 -v /tmp/build:/tmp/build qpdfbuild
GENERAL BUILD STUFF GENERAL BUILD STUFF

View File

@ -1,4 +1,9 @@
#!/bin/bash #!/bin/bash
#
# Any extra args are passed to the docker run command before the
# invocation of qpdfbuild. This is useful for iterating locally as
# described in README-maintainer.
#
set -ex set -ex
cd appimage cd appimage
docker build -t qpdfbuild . docker build -t qpdfbuild .
@ -6,7 +11,9 @@ rm -rf build
mkdir build mkdir build
cd .. cd ..
git clone .git appimage/build/qpdf git clone .git appimage/build/qpdf
docker run --privileged --rm -v $PWD/appimage/build:/tmp/build qpdfbuild docker run --privileged --rm \
-v $PWD/appimage/build:/tmp/build ${1+"$@"} qpdfbuild
rm -rf distribution
mkdir distribution mkdir distribution
cp -p appimage/build/qpdf/appimage/build/qpdf*AppImage* distribution cp -p appimage/build/qpdf/appimage/build/qpdf*AppImage* distribution
for i in distribution/*; do for i in distribution/*; do

View File

@ -4337,6 +4337,13 @@ print "\n";
with exit code 3 instead of 2. with exit code 3 instead of 2.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
The <option>--completion-bash</option> and
<option>--completion-zsh</option> options now work properly
when qpdf is invoked as an AppImage.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</listitem> </listitem>
<listitem> <listitem>

View File

@ -1471,10 +1471,23 @@ ArgParser::argHelp()
void void
ArgParser::argCompletionBash() ArgParser::argCompletionBash()
{ {
std::string progname = argv[0];
// Detect if we're in an AppImage and adjust
std::string appdir;
std::string appimage;
if (QUtil::get_env("APPDIR", &appdir) &&
QUtil::get_env("APPIMAGE", &appimage))
{
if ((appdir.length() < strlen(argv[0])) &&
(strncmp(appdir.c_str(), argv[0], appdir.length()) == 0))
{
progname = appimage;
}
}
std::cout << "complete -o bashdefault -o default -o nospace" std::cout << "complete -o bashdefault -o default -o nospace"
<< " -C " << argv[0] << " " << whoami << std::endl; << " -C " << progname << " " << whoami << std::endl;
// Put output before error so calling from zsh works properly // Put output before error so calling from zsh works properly
std::string path = argv[0]; std::string path = progname;
size_t slash = path.find('/'); size_t slash = path.find('/');
if ((slash != 0) && (slash != std::string::npos)) if ((slash != 0) && (slash != std::string::npos))
{ {