63 lines
2.2 KiB
Bash
63 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
# SPDX-License-Identifier: MIT
|
|
# Run in a Fedora build environment with the application's dependencies.
|
|
set -euo pipefail
|
|
if (( $# != 2 )); then
|
|
printf 'Usage: %s OLD_RPM NEW_RPM\n' "$0" >&2
|
|
exit 2
|
|
fi
|
|
old_rpm=$(realpath "$1")
|
|
new_rpm=$(realpath "$2")
|
|
work=$(mktemp -d)
|
|
trap 'rm -rf -- "$work"' EXIT
|
|
mkdir -p "$work/root" "$work/runtime"
|
|
export XDG_CONFIG_HOME="$work/config" XDG_CACHE_HOME="$work/cache"
|
|
export XDG_DATA_HOME="$work/data" XDG_DATA_DIRS="$work/root/usr/share:/usr/share"
|
|
export XDG_RUNTIME_DIR="$work/runtime"
|
|
export QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software
|
|
unset QML_DISABLE_DISK_CACHE QML_FORCE_DISK_CACHE QML_DISK_CACHE_PATH QML_DISK_CACHE
|
|
|
|
launch_settings() {
|
|
if timeout 3s dbus-run-session -- "$work/root/usr/bin/plasma-panel-actions" --settings > "$work/launch.log" 2>&1; then
|
|
printf 'Settings exited before the test timeout.\n' >&2
|
|
cat "$work/launch.log" >&2
|
|
exit 1
|
|
else
|
|
status=$?
|
|
if (( status != 124 )); then
|
|
cat "$work/launch.log" >&2
|
|
exit "$status"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
cache_for() {
|
|
for file in "$XDG_CACHE_HOME"/plasma-panel-actions/qmlcache/*.qmlc; do
|
|
[[ -f $file ]] || continue
|
|
if strings -el "$file" | grep -Fx "file://$1" > /dev/null; then
|
|
printf '%s\n' "$file"
|
|
return
|
|
fi
|
|
done
|
|
printf 'No QML cache was generated for %s\n' "$1" >&2
|
|
return 1
|
|
}
|
|
|
|
rpm2cpio "$old_rpm" | (cd "$work/root" && cpio -idm --quiet)
|
|
launch_settings
|
|
old_ui="$work/root/usr/share/plasma-panel-actions/ConfigGeneral.qml"
|
|
old_cache=$(cache_for "$old_ui")
|
|
old_checksum=$(sha256sum "$old_cache")
|
|
|
|
# Extract over the same location and keep the old cache intact. Changing
|
|
# the staging directory would hide the cache-collision regression.
|
|
rpm2cpio "$new_rpm" | (cd "$work/root" && cpio -idmu --quiet)
|
|
new_ui="$work/root$(rpm -qpl "$new_rpm" | grep '/ConfigGeneral.qml$')"
|
|
[[ $(stat -c %Y "$old_ui") == "$(stat -c %Y "$new_ui")" ]]
|
|
launch_settings
|
|
new_cache=$(cache_for "$new_ui")
|
|
[[ $new_cache != "$old_cache" ]]
|
|
[[ $(sha256sum "$old_cache") == "$old_checksum" ]]
|
|
strings -el "$new_cache" | grep -Fx twinFormLayouts > /dev/null
|
|
printf 'PASS: updated settings loaded with identical source timestamps and the old cache intact.\n'
|