Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
74 changes: 74 additions & 0 deletions scripts/build-appimage.sh
Original file line number Diff line number Diff line change
@@ -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> <arch:x86_64|aarch64> <output>

BINARY="$1"
APPIMAGE_ARCH="$2"
OUTPUT="$3"

if [ -z "$BINARY" ] || [ -z "$APPIMAGE_ARCH" ] || [ -z "$OUTPUT" ]; then
echo "usage: build-appimage.sh <binary> <arch> <output>" >&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"
11 changes: 11 additions & 0 deletions scripts/package-release-assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading