mirror of
https://github.com/pepaskopec-blip/Graduately.git
synced 2026-10-27 15:14:35 +00:00
Each installer carries no application of its own and resolves /releases/latest/download/ at the moment it runs, so the file never goes stale and the same download keeps working across future releases. macOS installs into /Applications, falling back to the user's own folder when that is not writable, and clears the quarantine flag the unsigned build would otherwise trip over. Windows extracts over any existing install rather than replacing the folder, so the progress files kept inside it survive, and adds a Start menu entry. Linux drops the AppImage in ~/Applications with a desktop entry and its icon. Publish the macOS one zipped, because a release asset loses its executable bit and a .command needs one to be double-clicked. The .cmd also had to be excluded from the *.cmd ignore rule, which comes from the kernel section of the template and targets build artifacts. Co-authored-by: Cursor <cursoragent@cursor.com>
79 lines
2.4 KiB
Bash
Executable file
79 lines
2.4 KiB
Bash
Executable file
#!/bin/sh
|
|
# maturita.c installer for Linux.
|
|
#
|
|
# Carries no application of its own: it downloads whatever the newest release
|
|
# is at the moment you run it, so this file never goes stale. GitHub resolves
|
|
# the /releases/latest/download/ path to the current tag on every request.
|
|
#
|
|
# Run it with: sh maturita-installer-linux.sh
|
|
# The app updates itself from then on.
|
|
|
|
set -eu
|
|
|
|
REPO="pepaskopec-blip/maturita.c"
|
|
ASSET="maturita-linux-x86_64.AppImage"
|
|
URL="https://github.com/$REPO/releases/latest/download/$ASSET"
|
|
|
|
# ~/Applications is where desktop environments look for AppImages, and the app
|
|
# keeps its progress/ directory next to its own file.
|
|
DEST_DIR="$HOME/Applications"
|
|
DEST="$DEST_DIR/maturita.AppImage"
|
|
DESKTOP_DIR="$HOME/.local/share/applications"
|
|
ICON_DIR="$HOME/.local/share/icons/hicolor/512x512/apps"
|
|
|
|
say() { printf '%s\n' "$*"; }
|
|
die() { printf '\nError: %s\n' "$*" >&2; exit 1; }
|
|
|
|
say "Installing maturita.C"
|
|
say "---------------------"
|
|
|
|
arch=$(uname -m)
|
|
if [ "$arch" != "x86_64" ]; then
|
|
die "only x86_64 builds are published, but this machine reports '$arch'.
|
|
Build from source instead: https://github.com/$REPO"
|
|
fi
|
|
|
|
command -v curl >/dev/null 2>&1 || die "curl was not found. Install it first."
|
|
|
|
mkdir -p "$DEST_DIR"
|
|
|
|
tmp=$(mktemp -d)
|
|
trap 'rm -rf "$tmp"' EXIT INT TERM
|
|
|
|
say "Downloading the latest release..."
|
|
curl -fL --progress-bar -o "$tmp/$ASSET" "$URL" ||
|
|
die "the download failed. Check your internet connection."
|
|
|
|
say "Installing to $DEST"
|
|
chmod +x "$tmp/$ASSET"
|
|
mv -f "$tmp/$ASSET" "$DEST" || die "could not write to $DEST_DIR."
|
|
|
|
# A menu entry needs the icon as a separate file, which the AppImage can
|
|
# unpack without FUSE. Losing the icon is not worth failing the install over.
|
|
if (cd "$tmp" && "$DEST" --appimage-extract \
|
|
'usr/share/icons/hicolor/512x512/apps/maturita.png' >/dev/null 2>&1); then
|
|
icon="$tmp/squashfs-root/usr/share/icons/hicolor/512x512/apps/maturita.png"
|
|
if [ -f "$icon" ]; then
|
|
mkdir -p "$ICON_DIR"
|
|
cp -f "$icon" "$ICON_DIR/maturita.png"
|
|
fi
|
|
fi
|
|
|
|
mkdir -p "$DESKTOP_DIR"
|
|
cat > "$DESKTOP_DIR/maturita.desktop" <<EOF
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=maturita.C
|
|
Comment=Practice app for the Czech maturita exam
|
|
Exec=$DEST
|
|
Icon=maturita
|
|
Terminal=false
|
|
Categories=Education;
|
|
EOF
|
|
|
|
command -v update-desktop-database >/dev/null 2>&1 &&
|
|
update-desktop-database "$DESKTOP_DIR" >/dev/null 2>&1 || true
|
|
|
|
say ""
|
|
say "Done. Starting the app..."
|
|
"$DEST" >/dev/null 2>&1 &
|