package-linux.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env bash
  2. # Linux packages of a built LYNX binary: an AppImage (one file, runs on most distributions) and a .tar.gz
  3. # (folder with install.sh for a per-user install). Both carry the .desktop entry, the icon and the .lynx file type.
  4. #
  5. # usage: scripts/package-linux.sh <LYNX binary> <label> <output folder> [Demo.lynx]
  6. # Variables: APPIMAGETOOL (path to appimagetool; downloaded into ~/opt when missing), ARCH (default x86_64)
  7. set -euo pipefail
  8. cd "$(dirname "$0")/.."
  9. BIN="$1"; LABEL="$2"; OUTDIR="$3"; DEMO="${4:-}"
  10. ARCH="${ARCH:-x86_64}"
  11. NAME="LYNX-$LABEL-linux-$ARCH"
  12. APPIMAGETOOL_VERSION=1.9.0
  13. WORK="$(mktemp -d)"
  14. trap 'rm -rf "$WORK"' EXIT
  15. mkdir -p "$OUTDIR"
  16. # --- folder for the .tar.gz --------------------------------------------------------------------------------
  17. PKG="$WORK/$NAME"
  18. mkdir -p "$PKG"
  19. install -m 755 "$BIN" "$PKG/LYNX"
  20. strip --strip-unneeded "$PKG/LYNX" 2> /dev/null || true
  21. install -m 644 resources/linux/lynx.desktop resources/linux/lynx-mime.xml LICENSE THIRD_PARTY.md PRIVACY.md "$PKG/"
  22. install -m 644 resources/lynx_icon_256.png "$PKG/lynx.png"
  23. install -m 755 resources/linux/install.sh "$PKG/install.sh"
  24. [[ -n "$DEMO" && -f "$DEMO" ]] && install -m 644 "$DEMO" "$PKG/Demo.lynx"
  25. tar -C "$WORK" -czf "$OUTDIR/$NAME.tar.gz" "$NAME"
  26. # --- AppImage ----------------------------------------------------------------------------------------------
  27. APPDIR="$WORK/LYNX.AppDir"
  28. mkdir -p "$APPDIR/usr/bin" "$APPDIR/usr/share/applications" "$APPDIR/usr/share/icons/hicolor/256x256/apps" "$APPDIR/usr/share/mime/packages"
  29. install -m 755 "$PKG/LYNX" "$APPDIR/usr/bin/LYNX"
  30. install -m 644 resources/linux/lynx.desktop "$APPDIR/usr/share/applications/lynx.desktop"
  31. install -m 644 resources/linux/lynx.desktop "$APPDIR/lynx.desktop"
  32. install -m 644 resources/lynx_icon_256.png "$APPDIR/usr/share/icons/hicolor/256x256/apps/lynx.png"
  33. install -m 644 resources/lynx_icon_256.png "$APPDIR/lynx.png"
  34. ln -sf lynx.png "$APPDIR/.DirIcon"
  35. install -m 644 resources/linux/lynx-mime.xml "$APPDIR/usr/share/mime/packages/lynx-mime.xml"
  36. for f in LICENSE THIRD_PARTY.md PRIVACY.md; do install -m 644 "$f" "$APPDIR/usr/share/$f"; done
  37. cat > "$APPDIR/AppRun" <<'EOF'
  38. #!/bin/sh
  39. here="$(dirname "$(readlink -f "$0")")"
  40. exec "$here/usr/bin/LYNX" "$@"
  41. EOF
  42. chmod 755 "$APPDIR/AppRun"
  43. TOOL="${APPIMAGETOOL:-$HOME/opt/appimagetool-$APPIMAGETOOL_VERSION-x86_64.AppImage}"
  44. if [[ ! -x "$TOOL" ]]; then
  45. mkdir -p "$(dirname "$TOOL")"
  46. curl -fsSL -o "$TOOL" "https://github.com/AppImage/appimagetool/releases/download/$APPIMAGETOOL_VERSION/appimagetool-x86_64.AppImage"
  47. chmod +x "$TOOL"
  48. fi
  49. # no FUSE needed to run the tool itself (containers, CI)
  50. APPIMAGE_EXTRACT_AND_RUN=1 ARCH="$ARCH" "$TOOL" --no-appstream "$APPDIR" "$OUTDIR/$NAME.AppImage" > "$WORK/appimagetool.log" 2>&1 \
  51. || { cat "$WORK/appimagetool.log"; exit 1; }
  52. chmod 755 "$OUTDIR/$NAME.AppImage"
  53. ls -la "$OUTDIR/$NAME.tar.gz" "$OUTDIR/$NAME.AppImage"