AppImage is a format for distributing portable software on Linux without needing superuser permissions to install the application. It tries to be a good citizen on all major distributions, and it bundles all of its dependencies to run on a wide variety of Linux distributions.
However, AppImage files are essentially squashfs filesystems packaged with a small loader script. Because squashfs is a read-only filesystem, you cannot directly modify an existing AppImage to add additional files.
If you need to include additional files within an AppImage, you have a few options:
Option 1: Rebuild the AppImage
-
Extract the AppImage:
- First, you need to extract the contents of the existing AppImage.
mkdir appimage_extracted
AppImageExtract your-app.AppImage -d appimage_extracted
If you don't have AppImageExtract, you can download it from AppImage GitHub.
wget https://github.com/AppImageCommunity/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O AppImageExtract
chmod +x AppImageExtract
-
Add your files:
- Navigate to the extracted directory and add your additional files.
cd appimage_extracted
cp /path/to/your/additional/files .
-
Repackage the AppImage:
- Use the
appimagetool to re-create the AppImage.
wget https://github.com/AppImageCommunity/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod +x appimagetool
./appimagetool appimage_extracted/ your-new-app.AppImage
Option 2: Modify the AppDir Before Creating the AppImage
If you are creating the AppImage yourself, you can add the additional files to the AppDir before packaging it into an AppImage.
- Create/Modify the AppDir:
- Set up your AppDir with the application and its dependencies.
mkdir myapp-appdir
cp -r /path/to/your/app myapp-appdir
cp /path/to/your/additional/files myapp-appdir
- Create the AppImage:
- Use
appimagetool to create the AppImage from the AppDir.
wget https://github.com/AppImageCommunity/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod +x appimagetool
./appimagetool myapp-appdir/ myapp.AppImage
Option 3: Bundle a Script to Download Additional Files
If you don't want to rebuild the AppImage and the additional files are not needed at startup you can bundle a script inside the AppImage that will download and place the additional files on the first run.
-
Extract the AppImage:
mkdir appimage_extracted
AppImageExtract your-app.AppImage -d appimage_extracted
-
Add a startup script:
- Create a script that will check for the additional files and download them if they are missing
cd appimage_extracted
nano startup.sh
#!/bin/bash
# Check if additional files exist
if [ ! -f /path/to/check/additional/file ]; then
# Download additional files
wget -P /path/to/store/additional/files http://example.com/additional-file
fi
# Start the actual application
./YourApp
Make the script executable
chmod +x startup.sh
-
Modify the loader script
- Edit the
AppRun script to execute your startup.sh instead of directly running the application.
nano AppRun
Change the content to:
#!/bin/bash
./startup.sh
-
Repackage the AppImage:
wget https://github.com/AppImageCommunity/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool
chmod +x appimagetool
./appimagetool appimage_extracted/ your-new-app.AppImage
Conclusion
Directly modifying an existing AppImage to add files isn't possible due to the read-only nature of the squashfs filesystem. However, by extracting, modifying, and repackaging the AppImage or by modifying the AppDir before creating the AppImage, you can include additional files. Alternatively you can use a script to download the files on first run.