summary refs log tree commit diff
path: root/fetch-current.sh
blob: b8cad93c52eecaab60b77110749ca05dbbd614a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env bash
set -euxo pipefail

script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
temp_dir=$(mktemp -d)
trap 'rm -rf -- "$temp_dir"' EXIT

candidate=$(curl -fLsS https://steamdeck-atomupd.steamos.cloud/meta/steamos/amd64/snapshot/steamdeck.json \
    | jq '(.major.candidates + .minor.candidates)[0]')

curl -fLSo "$temp_dir/bundle.raucb" \
    "https://steamdeck-images.steamos.cloud/$(jq -r .update_path <<<"$candidate")"
rauc extract --keyring="$script_dir/valve-rauc-keyring.pem" --trust-environment "$temp_dir/bundle.raucb" "$temp_dir/bundle"

output_path=steamdeck-$(jq -r .image.buildid <<<"$candidate")-$(jq -r .image.version <<<"$candidate").img
casync extract \
    --store="https://steamdeck-images.steamos.cloud/$(jq -r .update_path <<<"$candidate" | sed -e 's/\.raucb$/.castr/')" \
    "$temp_dir/bundle/rootfs.img.caibx" "$output_path"
echo "$output_path"