-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-appimage.sh
executable file
·203 lines (168 loc) · 4.94 KB
/
build-appimage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
# tested on Ubuntu 20.04 schroot
set -e
set -x
CMVER="3.26.3"
CMDIR="cmake-${CMVER}-linux-x86_64"
POPVER="23.04.0"
POPDIR="poppler-$POPVER"
GSVER="10.01.1"
GSDIR="ghostscript-$GSVER"
GSDIR_="gs10011"
SPVER="0.2.8"
SPDIR="libspectre-$SPVER"
DJVVER="3.5.28"
DJVDIR="djvulibre-$DJVVER"
VERSION="0.5.0"
VERSION_="0.5"
QPDFDIR="qpdfview-${VERSION_}"
JOBS=6
TOP="$PWD"
export PATH="$TOP/usr/bin:$TOP/qt/gcc_64/bin:$PATH"
export PKG_CONFIG_PATH="$TOP/usr/lib/pkgconfig:$TOP/qt/gcc_64/lib/pkgconfig"
export LD_LIBRARY_PATH="$TOP/usr/lib:$TOP/qt/gcc_64/lib"
sudo apt update
sudo apt upgrade
sudo apt install --no-install-recommends \
build-essential \
pkg-config \
wget \
fuse \
python3-pip \
libxcb-*0 \
libxkbcommon-x11-0 \
libgl1-mesa-dev \
libfontconfig1-dev \
libfreetype6-dev \
libidn11-dev \
libtiff5-dev \
libpng-dev \
libjpeg-turbo8-dev \
libpaper-dev \
libdbus-1-dev \
libopenjp2-7-dev \
libcairo2-dev \
liblcms2-dev \
libboost-dev \
libcups2-dev \
zlib1g-dev
# qt
if [ ! -f qt/gcc_64/bin/qmake ]; then
rm -rf qt
mkdir qt
cd qt
AQTPATH="/tmp/${RANDOM}-aqt"
pip3 install aqtinstall --target="$AQTPATH"
export PYTHONPATH="$AQTPATH"
# 5.12 branch
PYTHONPATH="$AQTPATH" QTVER=$("$AQTPATH/bin/aqt" list-qt linux desktop | tr ' ' '\n' | grep '5\.12' | tail -1)
PYTHONPATH="$AQTPATH" "$AQTPATH/bin/aqt" install-qt linux desktop $QTVER
mv $QTVER/gcc_64 .
rm -rf "$AQTPATH"
cd ..
fi
# cmake
if [ ! -f usr/bin/cmake ]; then
wget -q -c "https://github.com/Kitware/CMake/releases/download/v$CMVER/${CMDIR}.tar.gz"
rm -rf $CMDIR
tar xf ${CMDIR}.tar.gz
mv $CMDIR usr
fi
# djvulibre
if [ ! -f usr/lib/pkgconfig/ddjvuapi.pc ]; then
rm -rf $DJVDIR ${DJVDIR}.tar.gz
wget -q "http://downloads.sourceforge.net/djvu/${DJVDIR}.tar.gz"
tar xf ${DJVDIR}.tar.gz
cd $DJVDIR
./configure --prefix="$TOP/usr" --disable-static --disable-xmltools
make -j $JOBS
make install
cd ..
fi
# poppler
if [ ! -f usr/lib/pkgconfig/poppler-qt5.pc ]; then
rm -rf $POPDIR
wget -q -c "https://poppler.freedesktop.org/${POPDIR}.tar.xz"
tar xf ${POPDIR}.tar.xz
mkdir -p $POPDIR/build
cd $POPDIR/build
cmake .. -DCMAKE_INSTALL_PREFIX="$TOP/usr" \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_QT5=ON \
-DENABLE_QT6=OFF \
-DBUILD_GTK_TESTS=OFF \
-DBUILD_QT5_TESTS=OFF \
-DBUILD_QT6_TESTS=OFF \
-DBUILD_CPP_TESTS=OFF
make -j $JOBS
make install
cd ../..
if [ ! -f usr/lib/pkgconfig/poppler-qt5.pc ]; then
exit 1
fi
fi
# ghostscript
if [ ! -f usr/lib/pkgconfig/ghostscript.pc ]; then
rm -rf $GSDIR
wget -q -c "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/$GSDIR_/${GSDIR}.tar.xz"
tar xf ${GSDIR}.tar.xz
cd $GSDIR
rm -rf freetype jpeg lcms2mt libpng tiff openjpeg zlib
./configure --prefix="$TOP/usr" --without-x --disable-gtk
make -j $JOBS so-only
make soinstall
cd ..
cat <<EOF > usr/lib/pkgconfig/ghostscript.pc
Name: ghostscript
Version: $GSVER
Description: Ghostscript library
Cflags: -I"$TOP/usr/include/ghostscript"
Libs: -L"$TOP/usr/lib" -lgs
EOF
fi
# libspectre
if [ ! -f usr/lib/pkgconfig/libspectre.pc ]; then
rm -rf $SPDIR
wget -q -c "http://libspectre.freedesktop.org/releases/${SPDIR}.tar.gz"
tar xf ${SPDIR}.tar.gz
cd $SPDIR
CFLAGS="-O2 -I$TOP/usr/include" LDFLAGS="-L$TOP/usr/lib -s" \
./configure --prefix="$TOP/usr" --disable-static
make -j $JOBS
make install
cd ..
fi
# qpdfview
if [ ! -d $QPDFDIR ]; then
wget -q -c https://launchpad.net/qpdfview/trunk/$VERSION/+download/${QPDFDIR}.tar.gz
tar xf ${QPDFDIR}.tar.gz
fi
cd $QPDFDIR
lrelease qpdfview.pro
static_cfg="static_resources static_pdf_plugin static_ps_plugin static_djvu_plugin static_image_plugin"
qmake CONFIG+="$static_cfg" qpdfview.pro
make -j $JOBS
cd ..
# bundle
rm -rf appdir
mkdir -p appdir/usr/{bin,lib} appdir/usr/share/{applications,metainfo}
cp $QPDFDIR/qpdfview appdir/usr/bin
cp $QPDFDIR/miscellaneous/qpdfview.desktop appdir/usr/share/applications
cp $QPDFDIR/miscellaneous/qpdfview.appdata.xml appdir/usr/share/metainfo
cp $QPDFDIR/icons/qpdfview.svg appdir
# bundling these will fail
rm -f qt/gcc_64/plugins/sqldrivers/libqsqlodbc.so
rm -f qt/gcc_64/plugins/sqldrivers/libqsqlpsql.so
wget -q -c -O deploy.AppImage "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x deploy.AppImage
./deploy.AppImage appdir/usr/share/applications/qpdfview.desktop -verbose=2 -bundle-non-qt-libs -extra-plugins=iconengines,imageformats
doc="appdir/usr/share/doc"
mkdir -p $doc/{$POPDIR,$GSDIR,$SPDIR,$DJVDIR,qpdfview}
cp $DJVDIR/COPYRIGHT $doc/$DJVDIR
cp $GSDIR/doc/COPYING $doc/$GSDIR
cp $POPDIR/COPYING $doc/$POPDIR
cp $SPDIR/COPYING $doc/$SPDIR
cp $QPDFDIR/{CONTRIBUTORS,COPYING,CHANGES} $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