Use appimage-builder

This commit is contained in:
2025-04-15 22:43:25 -04:00
parent 6fa7df13dd
commit 0dee6d3971

View File

@@ -1018,7 +1018,7 @@ install_mc_arch() {
pkgver=$MC_VERSION pkgver=$MC_VERSION
pkgrel=1 pkgrel=1
pkgdesc="The Most Comprehensive Media Software" pkgdesc="The Most Comprehensive Media Software"
arch=('x86_64') arch=('$(uname -m)')
url="http://www.jriver.com/" url="http://www.jriver.com/"
license=('custom') license=('custom')
depends=('alsa-lib' 'ca-certificates' 'gtk3' 'gcc-libs' 'libx11' 'libxext' 'libxcb' 'libxau' 'libxdmcp' 'util-linux' 'mesa-libgl' 'webkit2gtk') depends=('alsa-lib' 'ca-certificates' 'gtk3' 'gcc-libs' 'libx11' 'libxext' 'libxcb' 'libxau' 'libxdmcp' 'util-linux' 'mesa-libgl' 'webkit2gtk')
@@ -1163,30 +1163,30 @@ install_mc_snap() {
# @description Installs MC via AppImage # @description Installs MC via AppImage
install_mc_appimage() { install_mc_appimage() {
debug "Running: ${FUNCNAME[0]}" debug "Running: ${FUNCNAME[0]}"
local appimage_dir="$OUTPUT_DIR/appimage" local builder_dir
local tool="$appimage_dir/appimagetool" builder_dir=$(mktemp -d) || { err "Failed to create temporary directory"; return 1; }
local app_dir="$appimage_dir/AppDir"
local icon_rel="usr/lib/jriver/Media Center ${MC_MVERSION}/Data/Default Art/Logo.png"
local desktop_rel="usr/share/applications/media_center_${MC_MVERSION}.desktop"
local output_appimage="$appimage_dir/${MC_PKG}-${MC_VERSION}.AppImage"
local install_dir="/opt/jriver" local install_dir="/opt/jriver"
local installed_app="$install_dir/$MC_PKG" local installed_app="$install_dir/$MC_PKG"
local config_file="$builder_dir/appimage-builder.yml"
local icon_rel="usr/lib/jriver/Media Center ${MC_MVERSION}/Data/Default Art/Logo.png"
local desktop_rel="usr/share/applications/media_center_${MC_MVERSION}.desktop"
# Create build directory and extract .deb # Generate a YAML configuration for appimage-builder.
execute mkdir -p "$app_dir" || { err "Could not create AppDir"; return 1; } cat <<-EOF > "$config_file"
execute dpkg-deb -x "$MC_DEB" "$app_dir" || { err "Failed to extract .deb"; return 1; } app:
id: $MC_PKG
# Create AppRun using a heredoc with tabs (no extra spaces) version: "$MC_VERSION"
cat <<-EOF > "$app_dir/AppRun" exec: "mediacenter${MC_MVERSION}"
app-run: |
#!/usr/bin/env bash #!/usr/bin/env bash
cmd=\$(basename "\$0") # determine the name used to invoke this AppImage cmd=\$(basename "\$0")
case "\$cmd" in case "\$cmd" in
mc${MC_MVERSION}) mc${MC_MVERSION})
# If invoked as "mc33", run the stub binary from usr/lib/jriver/Media Center 33 # If invoked as "mc${MC_MVERSION}", run the stub binary from usr/lib/jriver/Media Center ${MC_MVERSION}/mc${MC_MVERSION}
exec "\${APPDIR}/usr/lib/jriver/Media Center ${MC_MVERSION}/mc${MC_MVERSION}" "\$@" exec "\${APPDIR}/usr/lib/jriver/Media Center ${MC_MVERSION}/mc${MC_MVERSION}" "\$@"
;; ;;
mediacenter${MC_MVERSION}) mediacenter${MC_MVERSION})
# If invoked as "mediacenter33", run the main binary from usr/bin # If invoked as "mediacenter${MC_MVERSION}", run the main binary from usr/bin
exec "\${APPDIR}/usr/bin/mediacenter${MC_MVERSION}" "\$@" exec "\${APPDIR}/usr/bin/mediacenter${MC_MVERSION}" "\$@"
;; ;;
*) *)
@@ -1194,57 +1194,80 @@ install_mc_appimage() {
exec "\${APPDIR}/usr/bin/mediacenter${MC_MVERSION}" "\$@" exec "\${APPDIR}/usr/bin/mediacenter${MC_MVERSION}" "\$@"
;; ;;
esac esac
icon: "mediacenter.png"
desktop-file: "mediacenter.desktop"
ingredients:
sources:
- type: deb
url: "file://$MC_DEB"
extract: true
build: {}
output: "$builder_dir"
EOF EOF
execute chmod +x "$app_dir/AppRun" # To supply required assets, extract them from the DEB.
local temp_extract
# Prepare desktop file at AppDir root temp_extract=$(mktemp -d) || { err "Failed to create temporary extraction directory"; return 1; }
execute cp "$app_dir/$desktop_rel" "$app_dir/mediacenter.desktop" if ! dpkg-deb -x "$MC_DEB" "$temp_extract"; then
execute sed -i \ err "Failed to extract DEB for assets"
-e 's|^Icon=.*|Icon=mediacenter|' \ execute rm -rf "$temp_extract"
-e "s|^Exec=.*|Exec=mediacenter${MC_MVERSION} %U|" \
"$app_dir/mediacenter.desktop"
# Copy icon into standard location
execute mkdir -p "$app_dir/usr/share/icons/hicolor/256x256/apps"
execute cp "$app_dir/$icon_rel" "$app_dir/usr/share/icons/hicolor/256x256/apps/mediacenter.png"
execute cp "$app_dir/$icon_rel" "$app_dir/mediacenter.png"
# Get appimagetool
local arch; arch=$(uname -m) # TODO use host arch
if ! command -v appimagetool &>/dev/null && [[ ! -x "$tool" ]]; then
download "https://github.com/AppImage/AppImageKit/releases/latest/download/appimagetool-${arch}.AppImage" "$tool"
execute chmod +x "$tool"
fi
# Build the AppImage
if execute "$tool" "$app_dir" "$output_appimage"; then
echo "AppImage built: $output_appimage"
else
err "AppImage build failed"
return 1 return 1
fi fi
# Create /opt/jriver directory if needed and copy the AppImage # Copy the icon and desktop file into the builder directory
if ! cp "$temp_extract/$icon_rel" "$builder_dir/mediacenter.png"; then
err "Failed to copy icon"
execute rm -rf "$temp_extract" "$builder_dir"
return 1
fi
if ! cp "$temp_extract/$desktop_rel" "$builder_dir/mediacenter.desktop"; then
err "Failed to copy desktop file"
execute rm -rf "$temp_extract" "$builder_dir"
return 1
fi
execute rm -rf "$temp_extract"
# Run appimage-builder with the generated YAML config
if appimage-builder --config "$config_file" --verbose; then
local built_appimage
built_appimage="$builder_dir/${MC_PKG}-${MC_VERSION}-$(uname -m).AppImage"
if [[ ! -f "$built_appimage" ]]; then
err "Built AppImage not found in $builder_dir"
execute rm -rf "$builder_dir"
return 1
fi
echo "AppImage built: $built_appimage"
else
err "appimage-builder failed"
execute rm -rf "$builder_dir"
return 1
fi
# Install the AppImage
[[ -d "$install_dir" ]] || execute sudo mkdir -p "$install_dir" [[ -d "$install_dir" ]] || execute sudo mkdir -p "$install_dir"
if execute sudo cp "$output_appimage" "$installed_app"; then if execute sudo cp "$built_appimage" "$installed_app"; then
execute sudo chmod +x "$installed_app" execute sudo chmod +x "$installed_app"
echo "AppImage installed to $installed_app" echo "AppImage installed to $installed_app"
else else
err "Failed to install the AppImage to $install_dir" err "Failed to install the AppImage to $install_dir"
execute rm -rf "$builder_dir"
return 1 return 1
fi fi
# Optionally create symlinks in /usr/local/bin for easy host access to both binaries # Optionally create symlinks in /usr/local/bin for both invocation names
if ask_ok "Create symlinks for mediacenter${MC_MVERSION} and mc${MC_MVERSION} in /usr/local/bin?"; then if ask_ok "Create symlinks for mediacenter${MC_MVERSION} and mc${MC_MVERSION} in /usr/local/bin?"; then
execute sudo ln -sf "$installed_app" "/usr/local/bin/mediacenter${MC_MVERSION}" execute sudo ln -sf "$installed_app" "/usr/local/bin/mediacenter${MC_MVERSION}"
execute sudo ln -sf "$installed_app" "/usr/local/bin/mc${MC_MVERSION}" execute sudo ln -sf "$installed_app" "/usr/local/bin/mc${MC_MVERSION}"
fi fi
# Optionally run the installed AppImage immediately # Optionally run the installed AppImage immediately
if ask_ok "Do you want to run $MC_PKG now?"; then if ask_ok "Do you want to run the $MC_PKG AppImage now?"; then
execute "$installed_app" || { err "Running $MC_PKG failed"; return 1; } execute "$installed_app" || { err "Running $MC_PKG failed"; execute rm -rf "$builder_dir"; return 1; }
fi fi
execute rm -rf "$builder_dir"
return 0
} }
# @description Copy the RPM to createrepo-webroot and run createrepo as the createrepo-user # @description Copy the RPM to createrepo-webroot and run createrepo as the createrepo-user