在 Ubuntu 上制作 AppImage 通常有两种常见方式:
下面从「原理 → 手动方式 → 工具方式」一步步说明。
AppImage 本质上是一个 可执行的压缩文件系统(squashfs),结构如下:
yourapp.AppImage
├── AppDir/
│ ├── AppRun
│ ├── yourapp.desktop
│ ├── yourapp.png
│ └── usr/
│ ├── bin/yourapp
│ └── lib/...
运行 AppImage 时:
AppRun假设你有一个可执行文件:
mkdir -p MyApp/AppDir/usr/bin
cp yourapp MyApp/AppDir/usr/bin/
MyApp/AppDir/yourapp.desktop
[Desktop Entry]
Name=MyApp
Exec=yourapp
Icon=yourapp
Type=Application
Categories=Utility;
cp yourapp.png MyApp/AppDir/
MyApp/AppDir/AppRun
#!/bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
exec "$HERE/usr/bin/yourapp" "$@"
chmod +x MyApp/AppDir/AppRun
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage
./appimagetool-x86_64.AppImage MyApp/AppDir MyApp.AppImage
✅ 生成 MyApp.AppImage
sudo apt install libfuse2
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
./linuxdeploy-x86_64.AppImage \
--appdir AppDir \
--executable yourapp \
--desktop-file yourapp.desktop \
--icon-file yourapp.png \
--output appimage
✅ 自动生成 .AppImage
适合 Python / Qt / GTK 程序
pip install appimage-builder
appimage-builder --generate
编辑 AppImageBuilder.yml 后:
appimage-builder --build
✅ 程序必须是 Linux 可执行文件
✅ 依赖库要一起打包(linuxdeploy 会自动处理)
✅ Ubuntu 22.04+ 需要 libfuse2
✅ 不要依赖系统全局路径
| 场景 | 推荐方式 |
|---|---|
| 单个二进制 | 手动 |
| C/C++ 程序 | linuxdeploy |
| Python / Qt | appimage-builder |
| 商业发布 | appimage-builder |
如果你愿意,可以告诉我:
我可以直接给你 可复制的完整打包命令。