Skip to content

Instantly share code, notes, and snippets.

@ErikKalkoken
Created September 10, 2024 13:03
Show Gist options
  • Save ErikKalkoken/2faecca3d2a919fb68fce2eccbd015b9 to your computer and use it in GitHub Desktop.
Save ErikKalkoken/2faecca3d2a919fb68fce2eccbd015b9 to your computer and use it in GitHub Desktop.
This is bash script for building an AppImage with AppStream metadata from a Fyne app
#!/usr/bin/env bash
# This script builds an AppImage with AppStream metadata from a Fyne app
set -e
# Parameters
metadir="."
# Constants
dest="temp.Appdir"
source="temp.Source"
# get fynemeta
wget https://github.com/ErikKalkoken/fynemeta/releases/download/v0.1.0/fynemeta-0.1.0-linux-amd64.tar.gz -O fynemeta.tar.gz
tar xf fynemeta.tar.gz
rm fynemeta.tar.gz
# Use variables from fyne metadata
appname=$(./fynemeta lookup -k Details.Name -s "$metadir")
appid=$(./fynemeta lookup -k Details.ID -s "$metadir")
buildname=$(./fynemeta lookup -k Release.BuildName -s "$metadir")
# Initialize appdir folder
rm -rf "$source"
mkdir "$source"
rm -rf "$dest"
mkdir "$dest"
# Extract application files into appdir folder
tar xvfJ "$appname".tar.xz -C "$source"
# Rename desktop file to match AppStream requirements
mv "$source/usr/local/share/applications/$appname.desktop" "$source/usr/local/share/applications/$appid.desktop"
# Add AppStream appdata file
mkdir -p $dest/usr/share/metainfo
./fynemeta generate -t AppStream -s "$metadir" -d "$dest/usr/share/metainfo"
# Create appimage
wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -O linuxdeploy
chmod +x linuxdeploy
./linuxdeploy --appdir "$dest" -v 2 -o appimage -e "$source/usr/local/bin/$buildname" -d "$source/usr/local/share/applications/$appid.desktop" -i "$source/usr/local/share/pixmaps/$appname.png"
# Cleanup
rm -rf "$source"
rm -rf "$dest"
rm linuxdeploy
rm fynemeta
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment