From 648729624a38cf0b48a47737530a79d5e7b7ca94 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 22 Jan 2025 19:28:30 +0100 Subject: [PATCH] crosvm.updateScript: update to latest git commit crosvm upstream have advised that we do this rather than tracking Chrome OS. Link: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5921156/1#message-900e2002e62f3f0d0aeeab996bf14ccf17f9d1c9 --- .../virtualization/crosvm/default.nix | 13 ++++- .../virtualization/crosvm/update.py | 57 ------------------- 2 files changed, 12 insertions(+), 58 deletions(-) delete mode 100755 pkgs/applications/virtualization/crosvm/update.py diff --git a/pkgs/applications/virtualization/crosvm/default.nix b/pkgs/applications/virtualization/crosvm/default.nix index c74c24050c10..f30c0ff5298e 100644 --- a/pkgs/applications/virtualization/crosvm/default.nix +++ b/pkgs/applications/virtualization/crosvm/default.nix @@ -14,6 +14,9 @@ virglrenderer, wayland, wayland-protocols, + writeShellScript, + unstableGitUpdater, + nix-update, pkgsCross, }: @@ -69,7 +72,15 @@ rustPlatform.buildRustPackage rec { buildFeatures = [ "virgl_renderer" ]; passthru = { - updateScript = ./update.py; + updateScript = writeShellScript "update-crosvm.sh" '' + set -ue + ${lib.escapeShellArgs (unstableGitUpdater { + url = "https://chromium.googlesource.com/crosvm/crosvm.git"; + hardcodeZeroVersion = true; + })} + exec ${lib.getExe nix-update} --version=skip + ''; + tests = { musl = pkgsCross.musl64.crosvm; }; diff --git a/pkgs/applications/virtualization/crosvm/update.py b/pkgs/applications/virtualization/crosvm/update.py deleted file mode 100755 index 92444d287478..000000000000 --- a/pkgs/applications/virtualization/crosvm/update.py +++ /dev/null @@ -1,57 +0,0 @@ -#! /usr/bin/env nix-shell -#! nix-shell -p common-updater-scripts nix-update python3 -#! nix-shell -i python - -import csv -import json -import re -import shlex -import subprocess -from os.path import abspath, dirname, splitext -from urllib.request import urlopen - -# CrOS version numbers look like this: -# [.].. -# -# As far as I can tell, branches are where internal Google -# modifications are added to turn Chromium OS into Chrome OS, and -# branch branches are used for fixes for specific devices. So for -# Chromium OS they will always be 0. This is a best guess, and is not -# documented. -with urlopen('https://chromiumdash.appspot.com/cros/download_serving_builds_csv?deviceCategory=ChromeOS') as resp: - reader = csv.reader(map(bytes.decode, resp)) - header = reader.__next__() - cr_stable_index = header.index('cr_stable') - cros_stable_index = header.index('cros_stable') - chrome_version = [] - platform_version = [] - - for line in reader: - if line[cr_stable_index] == "no update": - continue - this_chrome_version = list(map(int, line[cr_stable_index].split('.'))) - this_platform_version = list(map(int, line[cros_stable_index].split('.'))) - chrome_version = max(chrome_version, this_chrome_version) - platform_version = max(platform_version, this_platform_version) - -chrome_major_version = chrome_version[0] -chromeos_tip_build = platform_version[0] -release_branch = f'release-R{chrome_major_version}-{chromeos_tip_build}.B' - -# Determine the git revision. -with urlopen(f'https://chromium.googlesource.com/chromiumos/platform/crosvm/+/refs/heads/{release_branch}?format=JSON') as resp: - resp.readline() # Remove )]}' header - rev = json.load(resp)['commit'] - -# Determine the patch version by counting the commits that have been -# added to the release branch since it forked off the chromeos branch. -with urlopen(f'https://chromium.googlesource.com/chromiumos/platform/crosvm/+log/refs/heads/chromeos..{rev}?format=JSON') as resp: - resp.readline() # Remove )]}' header - branch_commits = json.load(resp)['log'] - version = f'{chrome_major_version}.{len(branch_commits)}' - -# Update the version, git revision, and hash in crosvm's default.nix. -subprocess.run(['update-source-version', 'crosvm', f'--rev={rev}', version]) - -# Update cargoHash. -subprocess.run(['nix-update', '--version=skip', 'crosvm'])