blob: d5b3f21256b745863c234dbc7b7173dd225dd2e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#!/usr/bin/bash
set -euo pipefail
file=/usr/bin/bazzite-rollback-helper
if [[ ! -f "$file" ]]; then
echo "Unable to locate Bazzite rollback helper: $file" >&2
exit 1
fi
if grep -Fq 'current_image_prefix()' "$file"; then
exit 0
fi
patched_file=$(mktemp)
awk '
/^signing_scheme\(\) \{/ {
print "signing_scheme() {"
print " local current=$(rpm-ostree status -b --json | jq -r '\''.deployments[] | select(.booted == true) | .["container-image-reference"]'\'')"
print " local scheme=\"ostree-unverified-registry\""
print " [[ \"$current\" == *\"ostree-image-signed\"* ]] && scheme=\"ostree-image-signed\""
print " echo \"$scheme:docker://\""
print "}"
print ""
print "current_image_prefix() {"
print " local current"
print " current=$(rpm-ostree status -b --json | jq -r '\''.deployments[] | select(.booted == true) | .["container-image-reference"]'\'')"
print " current=\"${current#ostree-image-signed:}\""
print " current=\"${current#ostree-unverified-registry:}\""
print " current=\"${current#docker://}\""
print " echo \"${current%/*}\""
print "}"
skip=1
next
}
skip && /^warn_if_de_mismatch\(\) \{/ { skip=0; print; next }
skip { next }
{ gsub("ostree-image-signed:docker://ghcr.io/ublue-os/", "$(signing_scheme)/$(current_image_prefix)/"); print }
' "$file" > "$patched_file"
install -m 0755 "$patched_file" "$file"
rm -f "$patched_file"
|