#!/bin/bash # Extra run on an Ubuntu runner: GIMP from Flathub (Flatpak) and the Snap Store, plus PhotoGIMP master through the # photogimp.org path finder. Commands are pasted into an interactive zsh, the way a user runs them. set -u # Flatpak apps need a D-Bus session bus (GIMP's image loaders run sandboxed through the Flatpak portal). if [ -z "${DBUS_SESSION_BUS_ADDRESS:-}" ] && [ -z "${IN_DBUS:-}" ]; then IN_DBUS=1 exec dbus-run-session -- bash "$0" "$@"; fi cd "$(dirname "$0")/.." REPO=$(pwd) OUT="$REPO/verify/${VERIFY_OUT:-results-linux-extra}"; mkdir -p "$OUT" LOG="$OUT/run-log.txt"; FACTS="$OUT/facts.txt"; : > "$FACTS" PG_URL=https://github.com/Diolinux/PhotoGIMP/releases/download/3.1/PhotoGIMP-linux.zip IMG="$REPO/assets/moraine-lake.jpg" export DISPLAY=:99 CFG="$HOME/.config/GIMP" log() { echo "[$(date +%H:%M:%S)] $*" | tee -a "$LOG"; } fact() { printf '%s\t%s\n' "$1" "$2" >> "$FACTS"; } sha() { sha256sum "$1" 2>/dev/null | cut -c1-64; } shot() { import -window root "$OUT/$1.png" 2>>"$LOG" && log "screenshot $1"; } main_win() { xdotool search --onlyvisible --name ' GIMP$|^GNU Image Manipulation Program$' 2>/dev/null | head -1; } gimp_running() { pgrep -x 'gimp|gimp-3|gimp-3[.][0-9]+|org[.]gimp[.]GIMP.*' >/dev/null || flatpak ps 2>/dev/null | grep -q org.gimp.GIMP; } start_gimp() { # tag, command... local tag=$1; shift "$@" > "$OUT/$tag-console.txt" 2>&1 & local t=0; while [ $t -lt 300 ]; do [ -n "$(main_win)" ] && break; sleep 2; t=$((t+2)); done log "$tag: window after ${t}s: $(xdotool getwindowname "$(main_win)" 2>/dev/null)" sleep 15 if xdotool search --name 'Welcome to GIMP' >/dev/null 2>&1; then fact "welcome_$tag" yes; wmctrl -c 'Welcome to GIMP'; sleep 2; fi local w; w=$(main_win); [ -n "$w" ] && wmctrl -i -r "$w" -b add,maximized_vert,maximized_horz; sleep 3 } quit_gimp() { # Ctrl+Q like a user; an unchanged image does not ask anything local w; w=$(main_win) [ -n "$w" ] && xdotool windowactivate --sync "$w" key --clearmodifiers ctrl+q for i in $(seq 1 40); do gimp_running || { log "quit gracefully"; return 0; }; sleep 1; done log "GIMP did not quit; killing"; pkill -9 -x 'gimp|gimp-3|gimp-3[.][0-9]+' ; flatpak kill org.gimp.GIMP 2>/dev/null; sleep 2; return 1 } snap_cfg() { # tag dir fact "cfg_$1_dirs" "$(ls "$(dirname "$2")" 2>/dev/null | tr '\n' ' ')" fact "cfg_$1_toolrc" "$(sha "$2/toolrc")" } paste() { zsh -i -c "$(cat "$REPO/verify/site/$1")" > "$OUT/paste-$1-$2.txt" 2>&1 /dev/null 2>&1 sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 >/dev/null 2>&1 sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq xdg-desktop-portal xdg-desktop-portal-gtk xvfb xdotool wmctrl imagemagick openbox flatpak zsh x11-xserver-utils unzip >/dev/null 2>&1 Xvfb :99 -screen 0 1600x1000x24 -nolisten tcp >/dev/null 2>&1 & sleep 2 openbox >/dev/null 2>&1 & sleep 2 fact os "$(lsb_release -ds)" curl -sSL -o /tmp/pg.zip "$PG_URL"; rm -rf /tmp/pg; mkdir -p /tmp/pg; unzip -q /tmp/pg.zip -d /tmp/pg SRC30=/tmp/pg/PhotoGIMP-linux/.config/GIMP/3.0 # ── Flatpak (Flathub) ───────────────────────────────────────────────── log '===== Flatpak: install GIMP from Flathub' flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo >>"$LOG" 2>&1 flatpak install --user -y --noninteractive flathub org.gimp.GIMP > "$OUT/flatpak-install.txt" 2>&1; fact flatpak_install_exit "$?" fact flatpak_info "$(flatpak info --user org.gimp.GIMP 2>/dev/null | grep -E 'Version|Branch|Arch' | tr -s ' ' | tr '\n' ' ')" FP=(flatpak run org.gimp.GIMP "$IMG") rm -rf "$CFG" "$HOME/.var/app/org.gimp.GIMP" start_gimp fp-first flatpak run org.gimp.GIMP; shot fp-first; quit_gimp fact fp_home_config_gimp "$(ls "$CFG" 2>/dev/null | tr '\n' ' ')" fact fp_var_app_config_gimp "$(ls "$HOME/.var/app/org.gimp.GIMP/config/GIMP" 2>/dev/null | tr '\n' ' ')" log '===== Flatpak: path finder install (Flatpak variant), pasted' paste linux-install-flatpak-32.sh fp-install; snap_cfg fp-installed "$CFG/3.2" fact fp_launcher_exec "$(grep '^Exec=' "$HOME/.local/share/applications/org.gimp.GIMP.desktop" 2>/dev/null)" EXEC=$(grep '^Exec=' "$HOME/.local/share/applications/org.gimp.GIMP.desktop" 2>/dev/null | head -1 | sed 's/^Exec=//; s/@@u %U @@//; s/%U//') start_gimp fp-launcher bash -c "$EXEC '$IMG'"; shot fp-installed; quit_gimp; snap_cfg fp-after-quit "$CFG/3.2" start_gimp fp-second "${FP[@]}"; shot fp-second; quit_gimp; snap_cfg fp-after-second-quit "$CFG/3.2" grep -h "toolrc\|not existing\|no entry" "$OUT"/fp-launcher-console.txt > "$OUT/fp-warnings.txt" 2>/dev/null; fact fp_warnings "$(wc -l < "$OUT/fp-warnings.txt")" log '===== Flatpak: refuses while GIMP runs' before=$(ls "$CFG" | tr '\n' ' ') start_gimp fp-running "${FP[@]}"; paste linux-install-flatpak-32.sh fp-running fact fp_running_unchanged "$([ "$(ls "$CFG" | tr '\n' ' ')" = "$before" ] && echo yes || echo no)"; quit_gimp log '===== Flatpak: remove PhotoGIMP only, then master through the path finder' paste linux-uninstall-files-32.sh fp-uninstall; snap_cfg fp-uninstalled "$CFG/3.2" fact fp_launcher_after_uninstall "$(ls "$HOME/.local/share/applications/" 2>/dev/null | tr '\n' ' ')" paste linux-install-master-32.sh fp-master; snap_cfg fp-master "$CFG/3.2" start_gimp fp-master "${FP[@]}"; shot fp-master; quit_gimp; snap_cfg fp-master-after-quit "$CFG/3.2" log '===== Flatpak: 3.0 folder before GIMP 3.2 first start (migration)' rm -rf "$CFG"; mkdir -p "$CFG"; cp -a "$SRC30" "$CFG/3.0" start_gimp fp-migrate "${FP[@]}"; shot fp-migrate; quit_gimp; snap_cfg fp-migrate "$CFG/3.2" flatpak kill org.gimp.GIMP 2>/dev/null if [ "${ONLY:-}" != flatpak ]; then # ── Snap ────────────────────────────────────────────────────────────── log '===== Snap: install GIMP from the Snap Store' sudo snap install gimp > "$OUT/snap-install.txt" 2>&1; fact snap_install_exit "$?" snap info gimp 2>/dev/null | grep -E '^(name|publisher|tracking|installed):' > "$OUT/snap-info.txt"; fact snap_info "$(tr '\n' ' ' < "$OUT/snap-info.txt")" SN=(/snap/bin/gimp "$IMG") rm -rf "$CFG" "$HOME/snap/gimp" start_gimp snap-first /snap/bin/gimp; shot snap-first; quit_gimp fact snap_home_config_gimp "$(ls "$CFG" 2>/dev/null | tr '\n' ' ')" fact snap_private_config_gimp "$(ls "$HOME"/snap/gimp/*/.config/GIMP 2>/dev/null | tr '\n' ' ')" fact snap_ask_gimp "$(/snap/bin/gimp-console --no-interface --batch-interpreter=plug-in-script-fu-eval --batch '(display gimp-directory)' --quit 2>/dev/null | tail -1)" log '===== Snap: path finder install (distro/AppImage/Snap variant), pasted' paste linux-install-release-32.sh snap-install; snap_cfg snap-installed "$CFG/3.2" start_gimp snap-installed "${SN[@]}"; shot snap-installed; quit_gimp; snap_cfg snap-after-quit "$CFG/3.2" start_gimp snap-second "${SN[@]}"; shot snap-second; quit_gimp; snap_cfg snap-after-second-quit "$CFG/3.2" grep -h "toolrc\|not existing\|no entry" "$OUT"/snap-installed-console.txt > "$OUT/snap-warnings.txt" 2>/dev/null; fact snap_warnings "$(wc -l < "$OUT/snap-warnings.txt")" before=$(ls "$CFG" | tr '\n' ' ') start_gimp snap-running "${SN[@]}"; paste linux-install-release-32.sh snap-running fact snap_running_unchanged "$([ "$(ls "$CFG" | tr '\n' ' ')" = "$before" ] && echo yes || echo no)"; quit_gimp fi python3 - "$FACTS" "$OUT/facts.json" <<'EOF' import json, sys d = {} for line in open(sys.argv[1], encoding='utf-8', errors='replace'): k, _, v = line.rstrip('\n').partition('\t'); d[k] = v json.dump(d, open(sys.argv[2], 'w'), indent=1) EOF log done