diff --git a/CHANGELOG.md b/CHANGELOG.md index c3dd3d335..90719b3bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ Categories Used: - List: show symlink targets (for tar and zip) (https://github.com/ouch-org/ouch/pull/934) - Add aliases for ebooks (`.epub`) (https://github.com/ouch-org/ouch/pull/981) +- Add appimage binary to releases (https://github.com/ouch-org/ouch/pull/992) ### Improvements diff --git a/scripts/build-appimage.sh b/scripts/build-appimage.sh new file mode 100755 index 000000000..e80fb4897 --- /dev/null +++ b/scripts/build-appimage.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +set -e + +# Builds a single-file AppImage from a compiled ouch binary. +# Usage: build-appimage.sh + +BINARY="$1" +APPIMAGE_ARCH="$2" +OUTPUT="$3" + +if [ -z "$BINARY" ] || [ -z "$APPIMAGE_ARCH" ] || [ -z "$OUTPUT" ]; then + echo "usage: build-appimage.sh " >&2 + exit 1 +fi + +case "$APPIMAGE_ARCH" in + x86_64 | aarch64) ;; + *) + echo "unsupported AppImage arch: $APPIMAGE_ARCH" >&2 + exit 1 + ;; +esac + +APPIMAGETOOL_VERSION="1.9.0" + +WORKDIR="$(mktemp -d)" +trap 'rm -rf "$WORKDIR"' EXIT + +APPDIR="$WORKDIR/ouch.AppDir" +mkdir -p "$APPDIR/usr/bin" + +cp "$BINARY" "$APPDIR/usr/bin/ouch" +chmod +x "$APPDIR/usr/bin/ouch" + +cat > "$APPDIR/ouch.desktop" <<'EOF' +[Desktop Entry] +Type=Application +Name=ouch +Comment=A command-line utility for easily compressing and decompressing files and directories +Exec=ouch +Icon=ouch +Categories=Utility; +Terminal=true +EOF + +# dummy 1x1 transparent PNG +base64 -d > "$APPDIR/ouch.png" <<'EOF' +iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR4nGNgAAIAAAUAAeImBZsAAAAASUVORK5CYII= +EOF +ln -s ouch.png "$APPDIR/.DirIcon" + +cat > "$APPDIR/AppRun" <<'EOF' +#!/bin/sh +HERE="$(dirname "$(readlink -f "$0")")" +exec "$HERE/usr/bin/ouch" "$@" +EOF +chmod +x "$APPDIR/AppRun" + +APPIMAGETOOL="$WORKDIR/appimagetool" +wget -q -O "$APPIMAGETOOL" \ + "https://github.com/AppImage/appimagetool/releases/download/${APPIMAGETOOL_VERSION}/appimagetool-x86_64.AppImage" +chmod +x "$APPIMAGETOOL" + +RUNTIME="$WORKDIR/runtime-$APPIMAGE_ARCH" +wget -q -O "$RUNTIME" \ + "https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-$APPIMAGE_ARCH" + +# extract-and-run: no FUSE in CI. SOURCE_DATE_EPOCH: reproducible squashfs. +ARCH="$APPIMAGE_ARCH" APPIMAGE_EXTRACT_AND_RUN=1 "$APPIMAGETOOL" \ + --no-appstream \ + --runtime-file "$RUNTIME" \ + "$APPDIR" "$OUTPUT" + +echo "Created $OUTPUT" diff --git a/scripts/package-release-assets.sh b/scripts/package-release-assets.sh index 80c8464e8..18e28c85c 100755 --- a/scripts/package-release-assets.sh +++ b/scripts/package-release-assets.sh @@ -64,6 +64,17 @@ for platform in "${PLATFORMS[@]}"; do rm -rf "$path/target" chmod +x "$path/ouch" + # Portable single-file AppImage from the static musl binaries + # (zero shared-library dependencies, runs on any Linux). + case "$platform" in + x86_64-unknown-linux-musl) + ../scripts/build-appimage.sh "$path/ouch" x86_64 "../output_assets/${path}.AppImage" + ;; + aarch64-unknown-linux-musl) + ../scripts/build-appimage.sh "$path/ouch" aarch64 "../output_assets/${path}.AppImage" + ;; + esac + # --sort=name pins file order, --owner/--group/--numeric-owner pin uids, # --mtime pins timestamps. piping through gzip -n drops the gzip header # timestamp and original-name field.