update scripts for depots

This commit is contained in:
Robin Appelman 2026-07-09 00:17:59 +02:00
commit 6bbab5abe1
9 changed files with 113 additions and 10 deletions

View file

@ -1,6 +1,8 @@
#! /usr/bin/env nu
def main [] {
update_all_depots
nix-update --flake --use-update-script ambuild
nix build .#ambuild
@ -17,6 +19,8 @@ def main [] {
nix-update --flake --use-update-script sourcemod-include-library
nix-update --flake --use-update-script sourcemod-include-steamworks
nix-update --flake --use-update-script sourcemod-includes
nix fmt
}
def update_sdk [sdk: string] {
@ -36,3 +40,56 @@ def get_metamod_version [] {
let build = $html | query web --as-table [Build] | get Build | first
$"($branch).0.($build)"
}
def get_manifest [app: int, depot: int] {
let info = DepotDownloader -app $app -depot $depot -manifest-only | parse -r 'Manifest (?P<manifest>[0-9]+) \((?P<date>[^)]+)\)' | first
# builting rm doesn't work for some reason?
env rm -r ./depots
let manifest = $info | get manifest | into int
let date = $info | get date | into datetime | format date '%+'
{
app_id: $app,
depot_id: $depot,
manifest: $manifest,
date: $date,
}
}
def update_all_depots [] {
let $depots = open nix/srcds/depots.json
let updated = $depots | each {|manifest| update_manifest $manifest}
# save, so the nix build for determining the hashes sees the new manifest id
$updated | save -f nix/srcds/depots.json
let with_hashes = $updated | each {|manifest| update_manifest_hash $manifest}
$with_hashes | save -f nix/srcds/depots.json
}
def update_manifest [manifest: record] {
let new = get_manifest $manifest.app_id $manifest.depot_id
if ($new.manifest != $manifest.manifest) {
$manifest | merge $new | merge {hash: ""}
} else {
$manifest
}
}
def update_manifest_hash [manifest: record] {
if $manifest.hash == "" {
let new = get_manifest_hash $manifest
$manifest | merge {hash: $new}
} else {
$manifest
}
}
def get_manifest_hash [manifest: record] {
nix build $".#steam-depots.steam-depot-($manifest.app_id)-($manifest.depot_id)" | complete | get 'stderr' | extract_hash
}
def extract_hash [] {
parse -r "got: (?P<hash>sha256-[A-Za-z0-9+\/=]+)" | first | get 'hash'
}