Skip to content

Commit

Permalink
Fix --completion-* args to work from AppImage (fixes qpdf#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
jberkenbilt committed Jun 22, 2019
1 parent 7bd38a3 commit ed62be8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ manual/print.xsl
qpdf/build/
zlib-flate/build/
fuzz/qpdf_fuzzer_seed_corpus/
distribution/
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2019-06-22 Jay Berkenbilt <[email protected]>

* 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
security context. Thanks to user zdenop for supplying some code.
Fixes #286.
Expand Down
14 changes: 5 additions & 9 deletions README-maintainer
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,11 @@ zip -r qpdf-external-libs-src.zip external-libs
When releasing on sourceforge, `external-libs` distributions go in
`external-libs/yyyymmdd`, and qpdf distributions go in `qpdf/vvv`.

For local iteration on the AppImage generation, follow the release
procedures for building the AppImage, but instead of passing git clone
options to the docker command, copy qpdf to /tmp/build. You can also
pass -e SKIP_TESTS=1 to docker to skip the test suite, useful for
rapid iteration. Set up /tmp/build as in the release process.

cp -a $PWD /tmp/build
docker run --privileged -ti --rm -e SKIP_TESTS=1 -v /tmp/build:/tmp/build qpdfbuild

For local iteration on the AppImage generation, it works to just
./azure-pipelines/build-appimage and get the resulting AppImage from
the distribution directory. You can also pass -e SKIP_TESTS=1
build-appimage, which passes it along to to docker, to skip the test
suite, which useful for rapid iteration.

GENERAL BUILD STUFF

Expand Down
9 changes: 8 additions & 1 deletion azure-pipelines/build-appimage
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/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
cd appimage
docker build -t qpdfbuild .
rm -rf build
mkdir build
cd ..
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
cp -p appimage/build/qpdf/appimage/build/qpdf*AppImage* distribution
for i in distribution/*; do
Expand Down
7 changes: 7 additions & 0 deletions manual/qpdf-manual.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4337,6 +4337,13 @@ print "\n";
with exit code 3 instead of 2.
</para>
</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>
</listitem>
<listitem>
Expand Down
17 changes: 15 additions & 2 deletions qpdf/qpdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1471,10 +1471,23 @@ ArgParser::argHelp()
void
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"
<< " -C " << argv[0] << " " << whoami << std::endl;
<< " -C " << progname << " " << whoami << std::endl;
// Put output before error so calling from zsh works properly
std::string path = argv[0];
std::string path = progname;
size_t slash = path.find('/');
if ((slash != 0) && (slash != std::string::npos))
{
Expand Down

0 comments on commit ed62be8

Please sign in to comment.