Forgejo compares release asset size only; v1.0.5 and v1.0.6 were identical at 62933496 bytes. Co-authored-by: Cursor <[email protected]>
92 lines
2.9 KiB
Bash
Executable File
92 lines
2.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build HSRename as an AppImage.
|
|
# Requires: pip install -r requirements.txt -r requirements-build.txt
|
|
# Optional: appimagetool from https://github.com/AppImage/appimagetool/releases (for building the final .AppImage)
|
|
# Uses HSRename.png in the project folder as the app icon.
|
|
|
|
set -e
|
|
cd "$(dirname "$0")"
|
|
APP_NAME="HSRename"
|
|
APPDIR="${APP_NAME}.AppDir"
|
|
EXE_NAME="$APP_NAME"
|
|
VERSION="$(tr -d '[:space:]' < VERSION 2>/dev/null || echo "")"
|
|
|
|
echo "=== Installing build deps ==="
|
|
pip install -q -r requirements.txt -r requirements-build.txt
|
|
|
|
echo "=== Running PyInstaller (clean) ==="
|
|
rm -rf build dist HSRename.spec
|
|
pyinstaller --noconfirm --onedir --windowed \
|
|
-n "$EXE_NAME" \
|
|
--hidden-import=engine \
|
|
--hidden-import=engine.rules \
|
|
--hidden-import=engine.pipeline \
|
|
--hidden-import=engine.tvdb_client \
|
|
--hidden-import=engine.episode_match \
|
|
--hidden-import=gui \
|
|
--hidden-import=gui.main_window \
|
|
--hidden-import=gui.rule_widgets \
|
|
main.py
|
|
|
|
echo "=== Creating AppDir ==="
|
|
rm -rf "$APPDIR"
|
|
mkdir -p "$APPDIR/usr/bin"
|
|
cp -a "dist/$EXE_NAME" "$APPDIR/usr/bin/"
|
|
mkdir -p "$APPDIR/usr/share/hsrename"
|
|
echo "$VERSION" > "$APPDIR/usr/share/hsrename/VERSION"
|
|
if [[ -f "packaging/release-stamp-${VERSION}.txt" ]]; then
|
|
cp "packaging/release-stamp-${VERSION}.txt" "$APPDIR/usr/share/hsrename/release-stamp.txt"
|
|
fi
|
|
# Gear Lever (Forgejo) treats same-size AppImages as "no update". Version-scoped
|
|
# padding keeps each release a unique download size without affecting the app.
|
|
VER_MAJOR="${VERSION%%.*}"
|
|
VER_REST="${VERSION#*.}"
|
|
VER_MINOR="${VER_REST%%.*}"
|
|
VER_PATCH="${VER_REST#*.}"
|
|
VER_PATCH="${VER_PATCH%%.*}"
|
|
PAD_KB=$((300 + 10#${VER_MAJOR:-0} * 100 + 10#${VER_MINOR:-0} * 20 + 10#${VER_PATCH:-0} * 10))
|
|
dd if=/dev/urandom of="$APPDIR/usr/share/hsrename/.release-pad" bs=1024 count="$PAD_KB" status=none
|
|
echo "Release padding: ${PAD_KB} KiB (Gear Lever update detection)"
|
|
|
|
cat > "$APPDIR/AppRun" << EOF
|
|
#!/bin/sh
|
|
SELF=\$(readlink -f "\$0")
|
|
HERE=\${SELF%/*}
|
|
exec "\$HERE/usr/bin/$EXE_NAME/$EXE_NAME" "\$@"
|
|
EOF
|
|
chmod +x "$APPDIR/AppRun"
|
|
|
|
cat > "$APPDIR/hsrename.desktop" << EOF
|
|
[Desktop Entry]
|
|
Name=HSRename
|
|
Comment=Mass rename files with preview and flexible rules
|
|
Exec=HSRename
|
|
Icon=HSRename
|
|
Type=Application
|
|
Categories=Utility;FileTools;
|
|
X-AppImage-Version=${VERSION}
|
|
EOF
|
|
# Use project icon as app icon and logo
|
|
if [[ -f HSRename.png ]]; then
|
|
cp HSRename.png "$APPDIR/HSRename.png"
|
|
else
|
|
echo "Warning: HSRename.png not found; appimagetool may fail or use no icon."
|
|
fi
|
|
|
|
echo "=== Building AppImage (requires appimagetool) ==="
|
|
if command -v appimagetool &>/dev/null; then
|
|
OUT="${APP_NAME}.AppImage"
|
|
appimagetool "$APPDIR" "$OUT"
|
|
echo "Done: $OUT"
|
|
else
|
|
echo "AppDir is ready at $APPDIR/"
|
|
echo "To create the .AppImage, install appimagetool and run:"
|
|
echo " appimagetool $APPDIR ${APP_NAME}.AppImage"
|
|
exit 1
|
|
fi
|
|
|
|
if ! strings "dist/$EXE_NAME/$EXE_NAME" | grep -q "engine.tvdb_client"; then
|
|
echo "ERROR: Built executable is missing TheTVDB modules." >&2
|
|
exit 1
|
|
fi
|