下文中提及的inuxdeployqt patchelf appimagetool工具及示例下载地址:
链接: https://pan.baidu.com/s/1BGm_btMIe75uW9hOC09Xlg
提取码: 7ayh
需要创建目录及文件
xxx.AppDir
xxx.AppDir/AppRun-----------------------------------xx.AppImage运行时执行的程序,AppRun可以是可执行程序,也可以是脚本文件。
xxx.AppDir/usr
xxx.AppDir/usr/bin/xx--------------------------------主程序
xxx.AppDir/usr/lib-----------------------------------库目录
xxx.AppDir/usr/share/applications/xx.desktop---------界面程序启动文件
xxx.AppDir/usr/share/icons/hicolor/xx.png------------界面程序图标
将 linuxdeployqt patchelf appimagetool等文件 拷贝到系统目录下 /bin 并赋予可执行权限chmod a+x
将终端切换到xxx.AppDir同级的目录下
qt程序的打包先执行以下命令,将依赖库自动收集到xx.AppDir/usr目录下
linuxdeployqt xx.AppDir/usr/share/applications/xx.desktop
xx.desktop和xx.png文件会被拷贝到xx.AppDir目录下
非qt程序的打包需要先将
xx.desktop和xx.png文件手动放到xx.AppDir目录下
#!/bin/sh
SELF=$(readlink -f "$0")
HERE=${SELF%/*}
export PATH="${HERE}/usr/bin/:${HERE}/usr/sbin/:${HERE}/usr/games/:${HERE}/bin/:${HERE}/sbin/${PATH:+:$PATH}"
export LD_LIBRARY_PATH="${HERE}/usr/lib/:${HERE}/usr/lib/i386-linux-gnu/:${HERE}/usr/lib/x86_64-linux-gnu/:${HERE}/usr/lib32/:${HERE}/usr/lib64/:${HERE}/lib/:${HERE}/lib/i386-linux-gnu/:${HERE}/lib/x86_64-linux-gnu/:${HERE}/lib32/:${HERE}/lib64/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PYTHONPATH="${HERE}/usr/share/pyshared/${PYTHONPATH:+:$PYTHONPATH}"
export XDG_DATA_DIRS="${HERE}/usr/share/${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
export PERLLIB="${HERE}/usr/share/perl5/:${HERE}/usr/lib/perl5/${PERLLIB:+:$PERLLIB}"
export GSETTINGS_SCHEMA_DIR="${HERE}/usr/share/glib-2.0/schemas/${GSETTINGS_SCHEMA_DIR:+:$GSETTINGS_SCHEMA_DIR}"
export QT_PLUGIN_PATH="${HERE}/usr/lib/qt4/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt4/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt4/plugins/:${HERE}/usr/lib32/qt4/plugins/:${HERE}/usr/lib64/qt4/plugins/:${HERE}/usr/lib/qt5/plugins/:${HERE}/usr/lib/i386-linux-gnu/qt5/plugins/:${HERE}/usr/lib/x86_64-linux-gnu/qt5/plugins/:${HERE}/usr/lib32/qt5/plugins/:${HERE}/usr/lib64/qt5/plugins/:${HERE}/usr/plugins/${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}"
EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2 | cut -d " " -f 1)
exec "${EXEC}" "$@"
[Desktop Entry]
Type=Application
Name=xx
Exec=xx
Comment=Tool to generate AppImages from AppDirs
Icon=logo
Categories=Development;
Terminal=false
1、打包步骤参考
https://github.com/probonopd/linuxdeployqt/blob/master/BUILDING.md
打包过程中需要的软件 linuxdeployqt patchelf appimagetool AppRun
集成包linuxdeployqt-5-x86_64.AppImage-----集成了linuxdeployqt patchelf 等
集成包appimagetool-x86_64.AppImage----------集成了appimagetool AppRun 等
将qt5.8 打包成 QtCreator-5.8.0-x86_64.AppImage https://bintray.com/probono/AppImages/QtCreator/5.8.0#files
https://github.com/probonopd/linuxdeployqt/wiki/Custom-wrapper-script-instead-of-AppRun#example-wrapper-in-bash
AppRun 脚本的示例
#!/bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
export LD_LIBRARY_PATH=${HERE}/usr/lib/foobar:$LD_LIBRARY_PATH
exec "${HERE}/usr/bin/foo" "$@"
2、打包软件下载
https://github.com/probonopd/linuxdeployqt
https://github.com/AppImage/AppImageKit