Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
set -e
set -x
GSDIR="ghostscript-9.26"
GSDIR2="gs926"
SPVER="0.2.8"
SPDIR="libspectre-$SPVER"
DJVVER="3.5.27"
DJVDIR="djvulibre-$DJVVER"
JOBS=6
sudo apt install build-essential wget git fuse \
libfontconfig1-dev libfreetype6-dev libidn11-dev libtiff5-dev libpng-dev \
libjpeg-turbo8-dev zlib1g-dev libpaper-dev libdbus-1-dev \
libpoppler-qt5-dev libdjvulibre-dev libgs-dev libspectre-dev \
qt5-default qttools5-dev-tools qt5-qmake libqt5svg5-dev
# qpdfview
rm -rf qpdfview-git
git clone "https://github.com/darealshinji/qpdfview" qpdfview-git
cd qpdfview-git
VERSION="$(git describe --tags | sed 's|^qpdfview-||')"
lrelease qpdfview.pro
conf="static_resources with_lto static_pdf_plugin static_ps_plugin static_djvu_plugin static_image_plugin"
qmake CONFIG+="$conf" APPLICATION_VERSION="$VERSION" qpdfview.pro
sed -i "s|LIBSPECTRE_VERSION|\"$SPVER\"|g" sources/mainwindow.cpp
sed -i "s|DJVULIBRE_VERSION|\"$DJVVER\"|g" sources/mainwindow.cpp
make -j$JOBS
strip qpdfview
# ghostscript
wget -q -c "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/$GSDIR2/${GSDIR}.tar.gz"
rm -rf $GSDIR
tar xf ${GSDIR}.tar.gz
cd $GSDIR
rm -rf freetype jpeg libpng tiff zlib
CFLAGS="-O2 -fvisibility=hidden -DGSDLLEXPORT=\"__attribute__((visibility(\\\"default\\\")))\"" \
./configure --with-drivers="ALL,display" --without-x --disable-gtk --disable-cups --disable-contrib --without-ijs
make -j$JOBS so-only-stripped
cp -f sobin/libgs.so.9 ..
cd ..
# libspectre
wget -q -c "http://libspectre.freedesktop.org/releases/${SPDIR}.tar.gz"
rm -rf $SPDIR
tar xf ${SPDIR}.tar.gz
cd $SPDIR
./configure --disable-static
make -j$jobs
cp -f libspectre/.libs/libspectre.so.1 ..
cd ..
# djvulibre
wget -q -c "http://downloads.sourceforge.net/djvu/${DJVDIR}.tar.gz"
rm -rf $DJVDIR
tar xf ${DJVDIR}.tar.gz
cd $DJVDIR
./configure --disable-static --disable-xmltools
make -j$jobs
cp -f libdjvu/.libs/libdjvulibre.so.21 ..
cd ../..
# bundle
mkdir -p appdir/usr/bin appdir/usr/lib appdir/usr/share/applications appdir/usr/share/metainfo
cp qpdfview-git/qpdfview appdir/usr/bin
cp qpdfview-git/lib*.so.* appdir/usr/lib
cp qpdfview-git/miscellaneous/qpdfview.desktop appdir/usr/share/applications
cp qpdfview-git/miscellaneous/qpdfview.appdata.xml appdir/usr/share/metainfo
cp qpdfview-git/icons/qpdfview.svg appdir
wget -q -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt-continuous-x86_64.AppImage
LD_LIBRARY_PATH="$PWD/qpdfview-git" ARCH=x86_64 ./linuxdeployqt-continuous-x86_64.AppImage \
appdir/usr/share/applications/qpdfview.desktop -bundle-non-qt-libs -extra-plugins="imageformats/libqsvg.so"
mkdir -p appdir/usr/share/doc/$GSDIR appdir/usr/share/doc/$SPDIR appdir/usr/share/doc/$DJVDIR appdir/usr/share/doc/qpdfview
cp qpdfview-git/$GSDIR/LICENSE appdir/usr/share/doc/$GSDIR
cp qpdfview-git/$SPDIR/README appdir/usr/share/doc/$SPDIR
cp qpdfview-git/$DJVDIR/COPYRIGHT appdir/usr/share/doc/$DJVDIR
cp qpdfview-git/CONTRIBUTORS appdir/usr/share/doc/qpdfview
cp qpdfview-git/COPYING appdir/usr/share/doc/qpdfview
wget -q -c "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod a+x appimagetool-x86_64.AppImage
VERSION="$VERSION" ./appimagetool-x86_64.AppImage appdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment