下文中說起的inuxdeployqt patchelf appimagetool工具及示例下載地址:linux
連接: https://pan.baidu.com/s/1BGm_btMIe75uW9hOC09Xlggit
提取碼: 7ayh github
須要建立目錄及文件bash
xxx.AppDirapp
xxx.AppDir/AppRun-----------------------------------xx.AppImage運行時執行的程序,AppRun能夠是可執行程序,也能夠是腳本文件。工具
xxx.AppDir/usrui
xxx.AppDir/usr/bin/xx--------------------------------主程序this
xxx.AppDir/usr/lib-----------------------------------庫目錄.net
xxx.AppDir/usr/share/applications/xx.desktop---------界面程序啓動文件blog
xxx.AppDir/usr/share/icons/hicolor/xx.png------------界面程序圖標
打包步驟
1、準備打包文件
將 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目錄下
2、將AppRun放到xx.AppDir目錄下
3、執行打包 命令 appimagetool xx.AppDir
AppRun示例以下:
#!/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}" "$@"
xx.desktop示例以下:
[Desktop Entry]
Type=Application
Name=xx
Exec=xx
Comment=Tool to generate AppImages from AppDirs
Icon=logo
Categories=Development;
Terminal=false
參考:
一、打包步驟參考
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
Create the appdir/ directories (appdir/usr/bin, appdir/usr/share/applications, ...).
Create the wrapper script or program.
Copy the main executables, not the wrapper, into appdir/usr/bin/.
Copy the .desktop files into appdir/usr/share/applications/. Note that the desktop files' Exec=should still point to your executables, not the AppRun.
Copy the icon file into appdir/usr/share/icons/hicolor/.
Copy any other resources you may wish (Qml, etc).
Run linuxdeployqt appdir/usr/share/application/*.desktop with any options you may need.
Remove appdir/AppRun which is created by linuxdeployqt.
Copy your wrapper in appdir/AppRun (i.e. to the place of the AppRun that was there).
Run appimagetool appdir to create your image. (Note: there is a bug that may require you run this step twice).
AppRun 腳本的示例
#!/bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
export LD_LIBRARY_PATH=${HERE}/usr/lib/foobar:$LD_LIBRARY_PATH
exec "${HERE}/usr/bin/foo" "$@"
二、打包軟件下載
https://github.com/probonopd/linuxdeployqt
https://github.com/AppImage/AppImageKit ———————————————— 版權聲明:本文爲CSDN博主「愛文個人妻」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連接及本聲明。 原文連接:https://blog.csdn.net/bkbliu/article/details/88090465