Skip to content

Instantly share code, notes, and snippets.

@tpopela
Last active February 21, 2020 08:19
Show Gist options
  • Save tpopela/6cdfee17fd57d13ee897abd40281f131 to your computer and use it in GitHub Desktop.
Save tpopela/6cdfee17fd57d13ee897abd40281f131 to your computer and use it in GitHub Desktop.
Generates the diff between two Fedora Flatpak runtimes
#!/bin/bash
# Generates the diff between two Fedora Flatpak runtimes.
# Examples:
# # This will generate the diff between two given runtimes
# generate-runtime-diff.sh flatpak-runtime-f30-3020190604123149.1 flatpak-runtime-f30-3020190612151453.1
#
# # This will diff the two latest runtimes for the given Fedora version
# generate-runtime-diff.sh 29
#
# # This will diff the two latest runtimes for the currently running Fedora version
# generate-runtime-diff.sh
runtimes=""
fedora_version="$1"
if [ -z "$1" ]; then
echo "No Fedora version was specified, using the one from /etc/os-release"
. /etc/os-release
fedora_version="$VERSION_ID"
fi
if [ -z "$2" ]; then
# get two latest runtimes
runtimes=($(koji list-builds --package flatpak-runtime --state COMPLETE | grep "f$fedora_version" | grep '\.1' | tail -n 2 | awk '{ print $1 }'))
else
runtimes=("$1 $2")
fi
for runtime in "${runtimes[@]}";
do
# https://kojipkgs.fedoraproject.org//packages/flatpak-runtime/f30/3020190612151453.1/data/logs/x86_64-build.log
version_link=$(echo "$runtime" | awk -F'-' '{ print $3"/"$4 }')
rm -f /tmp/"$runtime".log
if ! wget --quiet "https://kojipkgs.fedoraproject.org//packages/flatpak-runtime/$version_link/data/logs/x86_64-build.log" -O /tmp/"$runtime".log; then
exit 1
fi
done
files_to_diff=""
for runtime in "${runtimes[@]}";
do
rm -f /tmp/"$runtime".packages
awk -v start=2 '/Installed:/{n++;next};n==start;n==start+1{exit}' /tmp/"$runtime".log | awk -v 'RS=\n\n' '1;{exit}' > /tmp/"$runtime".packages
files_to_diff="$files_to_diff /tmp/$runtime.packages"
done
echo "---${runtimes[0]}"
echo "+++${runtimes[1]}"
diff -U 0 $files_to_diff | sed '/^@@/ d' | sed '/^---/ d' | sed '/^+++/ d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment