crosvm.updateScript: update for new serving dash

The old dashboard no longer exists. Currently, the platform version
being served doesn't exist in manifest versions, but that was also a
problem we had before sometimes.

+16 -14
+16 -14
pkgs/applications/virtualization/crosvm/update.py
··· 3 3 #! nix-shell -i python 4 4 5 5 import base64 6 + import csv 6 7 import json 7 8 import re 8 9 import shlex 9 10 import subprocess 10 11 from os.path import abspath, dirname, splitext 11 - from lxml import etree 12 - from lxml.etree import HTMLParser 13 12 from urllib.request import urlopen 14 13 15 14 git_path = 'chromiumos/platform/crosvm' ··· 25 24 # branch branches are used for fixes for specific devices. So for 26 25 # Chromium OS they will always be 0. This is a best guess, and is not 27 26 # documented. 28 - with urlopen('https://cros-updates-serving.appspot.com/') as resp: 29 - document = etree.parse(resp, HTMLParser()) 30 - # bgcolor="lightgreen" is set on the most up-to-date version for 31 - # each channel, so find a lightgreen cell in the "Stable" column. 32 - (platform_version, chrome_version) = document.xpath(""" 33 - (//table[@id="cros-updates"]/tr/td[1 + count( 34 - //table[@id="cros-updates"]/thead/tr[1]/th[text() = "Stable"] 35 - /preceding-sibling::*) 36 - ][@bgcolor="lightgreen"])[1]/text() 37 - """) 27 + with urlopen('https://chromiumdash.appspot.com/cros/download_serving_builds_csv?deviceCategory=ChromeOS') as resp: 28 + reader = csv.reader(map(bytes.decode, resp)) 29 + header = reader.__next__() 30 + cr_stable_index = header.index('cr_stable') 31 + cros_stable_index = header.index('cros_stable') 32 + chrome_version = [] 33 + platform_version = [] 38 34 39 - chrome_major_version = re.match(r'\d+', chrome_version)[0] 40 - chromeos_tip_build = re.match(r'\d+', platform_version)[0] 35 + for line in reader: 36 + this_chrome_version = list(map(int, line[cr_stable_index].split('.'))) 37 + this_platform_version = list(map(int, line[cros_stable_index].split('.'))) 38 + chrome_version = max(chrome_version, this_chrome_version) 39 + platform_version = max(platform_version, this_platform_version) 40 + 41 + chrome_major_version = chrome_version[0] 42 + chromeos_tip_build = str(platform_version[0]) 41 43 42 44 # Find the most recent buildspec for the stable Chrome version and 43 45 # Chromium OS build number. Its branch build and branch branch build