Skip to content

Commit a6e81f0

Browse files
committed
feat(steamos-update): Initial support for Universal Blue updater
1 parent b97c6d7 commit a6e81f0

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed
+23-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
#!/bin/bash
22

3-
if command -v rpm-ostree > /dev/null; then
3+
if command -v ublue-update > /dev/null; then
44
if [ "$1" == "check" ]; then
55
if [ -f '/tmp/upgrade-installed' ]; then
66
exit 7 # Upgrade already installed
77
else
8-
# Perform connectivity check
9-
wget -q --spider https://github.com
8+
# Check system state
9+
ublue-update --check
1010
if [ $? -eq 0 ]; then
11-
# Compare installation digest to latest image
12-
IMAGE=$(rpm-ostree status | grep -m1 ghcr | sed 's/^.*ghcr/ghcr/')
13-
CURRENT=$(rpm-ostree status | grep -m1 Digest | tr -d '[:space:]' | sed 's/'Digest:'//g')
14-
LATEST=$(skopeo inspect docker://${IMAGE} | jq '.Digest' | tr -d '"')
15-
if [ ${CURRENT} == ${LATEST} ]; then
16-
exit 7 # Up to date
11+
# Perform connectivity check
12+
wget -q --spider https://github.com
13+
if [ $? -eq 0 ]; then
14+
# Compare installation digest to latest image
15+
IMAGE=$(rpm-ostree status | grep -m1 ghcr | sed 's/^.*ghcr/ghcr/')
16+
CURRENT=$(rpm-ostree status | grep -m1 Digest | tr -d '[:space:]' | sed 's/'Digest:'//g')
17+
LATEST=$(skopeo inspect docker://${IMAGE} | jq '.Digest' | tr -d '"')
18+
if [ ${CURRENT} == ${LATEST} ]; then
19+
exit 7 # Up to date
20+
else
21+
exit 0 # Upgrade available
22+
fi
1723
else
18-
exit 0 # Upgrade available
24+
exit 7 # Connectivity check failed
1925
fi
2026
else
21-
exit 7 # Connectivity check failed
27+
exit 7 # System in use
2228
fi
2329
fi
2430
elif [ "$1" == "--supports-duplicate-detection" ]; then
@@ -36,20 +42,20 @@ if command -v rpm-ostree > /dev/null; then
3642
echo 100%
3743
}
3844
upgrade() {
39-
# Pull exit code from rpm-ostree
40-
rpm-ostree upgrade --unchanged-exit-77
45+
# Pull exit code from ublue-update
46+
ublue-update
4147
echo $? > /tmp/upgrade-check
4248
}
4349
upgrade | fake_progress
4450
# Check if upgrade failed
4551
UPGRADE_CHECK=/tmp/upgrade-check
4652
rm /tmp/upgrade-check
47-
if [ ${UPGRADE_CHECK} -eq 77 ]; then
48-
exit 0 # Upgrade failed
49-
else
53+
if [ ${UPGRADE_CHECK} -eq 0 ]; then
5054
touch /tmp/upgrade-installed
55+
else
56+
exit 0 # Upgrade failed
5157
fi
5258
fi
5359
else
54-
exit 7 # rpm-ostree not installed
60+
exit 7 # ublue-update not installed
5561
fi

0 commit comments

Comments
 (0)