Qt程序自依赖AppImage打包教材3/4(以TheNewPlayerFree为例)
Tofloor
poster avatar
已退deepin
deepin
2020-07-11 17:12
Author
本帖最后由 user0001 于 2020-7-11 15:38 编辑


1/4

https://bbs.deepin.org/post/196995

2/4
https://bbs.deepin.org/post/196996

3/4
https://bbs.deepin.org/post/196998

4/4 (end)
https://bbs.deepin.org/post/196999
准备部署动态库

前往下面的网址下载linuxdeployqt工具
https://github.com/probonopd/linuxdeployqt

下载后得到linuxdeployqt.AppImage

chmod +x linuxdeployqt.AppImage
sudo mv linuxdeployqt.AppImage /usr/local/bin/linuxdeployqt

同时还需要安装patchelf工具等()这一步请参考七主页

cd thenewplayerfree.AppDir/usr/local/thenewplayerfree

linuxdeployqt bin/thenewplayerfree -no-strip  -unsupported-allow-new-glibc -always-overwrite -bundle-non-qt-libs -no-translations
rm AppRun #我们不需要这个
rm bin/qt.conf
cd bin
ln -s ../etc/qt.conf qt.conf #使用我们自己的配置

对二进制的绝对路径进行转换
sed -i -e 's#/usr#././#g' thenewplayerfree.AppDir/usr/local/thenewplayerfree/bin/thenewplayerfree

#检查,因为没有输出为正确
strings thenewplayerfree.AppDir/usr/local/thenewplayerfree/bin/thenewplayerfree|grep /usr


find usr/local/thenewplayerfree/lib -type f -exec sed -i -e 's#/usr#././#g' {} \;
strings thenewplayerfree.AppDir/usr/local/thenewplayerfree/lib/*|grep /usr #检查

#处理GDK依赖
sh bundle-gtk2.sh thenewplayerfree.AppDir
# 请使用我提供的bundle-gtk2.sh脚本进行自动化处理



export APPDIR=$PWD/thenewplayerfree.AppDir

#
# 处理Theme引擎(获得更好的兼容性)
#
mkdir -p "$APPDIR/usr/lib/gtk-2.0"
GTK_LIBDIR=$(pkg-config --variable=libdir gtk+-2.0)
GTK_BINARY_VERSION=$(pkg-config --variable=gtk_binary_version gtk+-2.0)
cp -a "${GTK_LIBDIR}/gtk-2.0/${GTK_BINARY_VERSION}"/* "$APPDIR/usr/lib/gtk-2.0"

#
# 处理RSVG依赖(获得更好的兼容性)
#

mkdir -p "$APPDIR/usr/lib"
RSVG_LIBDIR=$(pkg-config --variable=libdir librsvg-2.0)
if [ x"${RSVG_LIBDIR}" != "x" ]; then
export GDK_PIXBUF_MODULE_FILE="${APPDIR}/usr/lib/gdk-pixbuf-2.0/loaders.cache"
     echo "cp -a ${RSVG_LIBDIR}/librsvg*.so* $APPDIR/usr/lib"
     cp -a "${RSVG_LIBDIR}"/librsvg*.so* "$APPDIR/usr/lib"
fi




Reply Favorite View the author
All Replies

No replies yet