From 1b85faa61abcec253f9fb5aab6f94c844e4df816 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 11 Mar 2022 20:54:48 -0500 Subject: [PATCH] Convert AppImage build to use cmake --- README-maintainer | 10 ++++++---- appimage/Dockerfile | 31 +++++++++++++++++++++++-------- appimage/build-appimage | 25 ++++++++++++++----------- appimage/entrypoint | 15 +++++++++------ 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/README-maintainer b/README-maintainer index 5108cf83..5293e5ad 100644 --- a/README-maintainer +++ b/README-maintainer @@ -462,10 +462,12 @@ rsync -vrlcO ./ jay_berkenbilt,qpdf@frs.sourceforge.net:/home/frs/project/q/qp/q OTHER NOTES For local iteration on the AppImage generation, it works to just -./build-scripts/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. +./build-scripts/build-appimage and get the resulting AppImage from the +distribution directory. You can pass additional arguments to +build-appimage, which passes them along to to docker. + +Use -e SKIP_TESTS=1 to skip the test suite. +Use -ti -e RUN_SHELL=1 to run a shell instead of the build script. GENERAL BUILD STUFF diff --git a/appimage/Dockerfile b/appimage/Dockerfile index 0b7232f9..da0b8b72 100644 --- a/appimage/Dockerfile +++ b/appimage/Dockerfile @@ -1,13 +1,28 @@ -FROM ubuntu:18.04 +FROM ubuntu:18.04 as start ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && \ - apt-get -y install screen autoconf git sudo \ - build-essential zlib1g-dev libjpeg-dev libgnutls28-dev \ - python3-pip texlive-latex-extra latexmk \ - inkscape imagemagick busybox-static wget fuse && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* +RUN apt-get update +RUN apt-get -y install screen git sudo \ + build-essential pkg-config \ + zlib1g-dev libjpeg-dev libgnutls28-dev \ + python3-pip texlive-latex-extra latexmk \ + inkscape imagemagick busybox-static wget fuse + +# Until we move to ubuntu:20.04, we need a newer cmake. After 20.04, +# we can remove this and add cmake to the install above. +RUN apt-get -y install software-properties-common wget +RUN wget -O /etc/apt/trusted.gpg.d/kitware.asc \ + https://apt.kitware.com/keys/kitware-archive-latest.asc +RUN apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' +RUN apt-get update +RUN apt-get -y install cmake +# End cmake + +RUN apt-get clean && rm -rf /var/lib/apt/lists/* + RUN pip3 install sphinx sphinx_rtd_theme + +FROM ubuntu:18.04 as run +COPY --from=start / / COPY entrypoint /entrypoint RUN chmod +x /entrypoint ENTRYPOINT [ "/entrypoint" ] diff --git a/appimage/build-appimage b/appimage/build-appimage index 19a2247b..82c82812 100755 --- a/appimage/build-appimage +++ b/appimage/build-appimage @@ -82,32 +82,35 @@ appdir=$here/build/appdir rm -rf $here/build # Prepare build of QPDF from sources: -./configure --prefix=/usr --enable-werror \ - --enable-crypto-gnutls --disable-implicit-crypto \ - --enable-show-failed-test-output \ - --enable-html-doc --enable-pdf-doc "$CUSTOM_CONFIGURE" +rm -rf build.appimage +mkdir build.appimage +cd build.appimage +cmake -DWERROR=1 -DBUILD_DOC=1 -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_DOC_DIST=1 -DINSTALL_MANUAL=1 \ + -DREQUIRE_CRYPTO_GNUTLS=1 -DUSE_IMPLICIT_CRYPTO=0 \ + -DSHOW_FAILED_TEST_OUTPUT=1 -DBUILD_STATIC_LIBRARIES=0 \ + "$CUSTOM_CONFIGURE" .. # Build! -make -j$(nproc) +cmake --build . -j$(nproc) if [ "$SKIP_TESTS" = "" ]; then # Run built-in QPDF checks: - make -k check + ctest --verbose fi # Prepare AppDir which is the basis for the AppImage: mkdir -p $appdir # Install build result into AppDir: -make install DESTDIR=$appdir; find $appdir -make doc-dist DOC_DEST=appdir/usr/share/doc/qpdf +for i in lib cli doc; do + DESTDIR=$appdir cmake --install . --prefix /usr --component $i +done +find $appdir # Change into build directory: cd $here/build -# Don't bundle developer stuff -rm -rf appdir/usr/include appdir/usr/lib/pkgconfig appdir/usr/lib/*.{a,la,so} - # Copy icon which is needed for desktop integration into place: for width in 64 128 256 512; do dir=appdir/usr/share/icons/hicolor/${width}x${width}/apps diff --git a/appimage/entrypoint b/appimage/entrypoint index b1ee7eb0..12ed9387 100755 --- a/appimage/entrypoint +++ b/appimage/entrypoint @@ -1,8 +1,5 @@ #!/bin/bash set -e -if [ "$SKIP_TESTS" = "1" ]; then - touch /tmp/skip-tests -fi if [ $(id -u) = 0 ]; then if [ ! -d /tmp/build ]; then echo "/tmp/build must exist" @@ -10,6 +7,10 @@ if [ $(id -u) = 0 ]; then fi id=$(stat -c %u /tmp/build) adduser --home /tmp/build --no-create-home --uid $id --disabled-password --gecos build build + touch /tmp/.env + echo "export SKIP_TESTS=$SKIP_TESTS" >> /tmp/.env + echo "export RUN_SHELL=$RUN_SHELL" >> /tmp/.env + chown build /tmp/.env exec sudo -iu build $0 "$@" fi @@ -22,7 +23,9 @@ if [ ! -d qpdf ]; then git clone "$@" qpdf fi cd qpdf -if [ -f /tmp/skip-tests ]; then - export SKIP_TESTS=1 +source /tmp/.env +if [ "$RUN_SHELL" = "1" ]; then + bash +else + ./appimage/build-appimage fi -./appimage/build-appimage