Skip to content

Commit 19b86d4

Browse files
committed
Replace Chrome OS code names with board names to avoid checking multiple codenames for the same recovery image.
1 parent fdab4b9 commit 19b86d4

File tree

3 files changed

+44
-80
lines changed

3 files changed

+44
-80
lines changed

lib/inputstreamhelper/config.py

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -84,53 +84,22 @@
8484
# https://www.chromium.org/chromium-os/developer-information-for-chrome-os-devices
8585
# https://chromiumdash.appspot.com/serving-builds?deviceCategory=Chrome%20OS
8686
# Last updated: 2023-03-24
87-
CHROMEOS_RECOVERY_ARM_HWIDS = [
88-
'BOB',
89-
'BURNET',
90-
'COACHZ',
91-
'COZMO',
92-
'DAMU',
93-
'DOJO-EJPG',
94-
'DRUWL',
95-
'DUMO',
96-
'ELM',
97-
'ESCHE',
98-
'FENNEL',
99-
'FENNEL14',
100-
'HANA',
101-
'HAYATO-YLRO',
102-
'HOMESTAR-MBLE',
103-
'JUNIPER-HVPU',
104-
'KAKADU-WFIQ',
105-
'KAPPA',
106-
'KAPPA-EWFK',
107-
'KATSU',
108-
'KENZO-IGRW',
109-
'KEVIN',
110-
'KODAMA',
111-
'KRANE-ZDKS',
112-
'MAKOMO-UTTX',
113-
'PICO-EXEM',
114-
'QUACKINGSTICK',
115-
'SCARLET',
116-
'SPHERION',
117-
'TOMATO-LYVN',
118-
'WILLOW-TFIY',
119-
'WORMDINGLER-JQAO',
87+
CHROMEOS_RECOVERY_ARM_BNAMES = [
88+
'asurada',
89+
'bob',
90+
'cherry',
91+
'elm',
92+
'hana',
93+
'jacuzzi',
94+
'kevin',
95+
'kukui',
96+
'scarlet',
97+
'strongbad',
12098
]
12199

122-
CHROMEOS_RECOVERY_ARM64_HWIDS = [
123-
'KINGOFTOWN-KDDA',
124-
'LAZOR',
125-
'LIMOZEEN',
126-
'MAGNETON-LCKC',
127-
'PAZQUEL-HGNV',
128-
'PAZQUEL-OPNA',
129-
'POMPOM-MZVS',
130-
'RUSTY-ZNCE',
131-
'STEELIX-VZSZ',
132-
'TENTACOOL-ZLJE',
133-
'TENTACRUEL-VAFH',
100+
CHROMEOS_RECOVERY_ARM64_BNAMES = [
101+
'corsola',
102+
'trogdor',
134103
]
135104

136105
MINIMUM_INPUTSTREAM_VERSION_ARM64 = {

lib/inputstreamhelper/widevine/arm.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,44 @@ def select_best_chromeos_image(devices):
1717
log(0, 'Find best ARM image to use from the Chrome OS recovery.json')
1818

1919
if userspace64():
20-
arm_hwids = config.CHROMEOS_RECOVERY_ARM64_HWIDS
20+
arm_bnames = config.CHROMEOS_RECOVERY_ARM64_BNAMES
2121
else:
22-
arm_hwids = config.CHROMEOS_RECOVERY_ARM_HWIDS
22+
arm_bnames = config.CHROMEOS_RECOVERY_ARM_BNAMES
2323

24-
arm_hwids = [h for arm_hwid in arm_hwids for h in ['^{} '.format(arm_hwid), '^{}-.*'.format(arm_hwid), '^{}.*'.format(arm_hwid)]]
2524
best = None
2625
for device in devices:
2726
# Select ARM hardware only
28-
for arm_hwid in arm_hwids:
29-
if arm_hwid in device['hwidmatch']:
30-
hwid = arm_hwid
27+
for arm_bname in arm_bnames:
28+
if arm_bname == device['file'].split('_')[2]:
29+
device['boardname'] = arm_bname # add this new entry to avoid extracting it from the filename all the time
3130
break # We found an ARM device, rejoice !
3231
else:
3332
continue # Not ARM, skip this device
3433

35-
device['hwid'] = hwid
36-
3734
# Select the first ARM device
3835
if best is None:
3936
best = device
4037
continue # Go to the next device
4138

42-
# Skip identical hwid
43-
if hwid == best['hwid']:
39+
# Skip identical boardname
40+
if device['boardname'] == best['boardname']:
4441
continue
4542

4643
# Select the newest version
4744
if parse_version(device['version']) > parse_version(best['version']):
48-
log(0, '{device[hwid]} ({device[version]}) is newer than {best[hwid]} ({best[version]})',
45+
log(0, '{device[boardname]} ({device[version]}) is newer than {best[boardname]} ({best[version]})',
4946
device=device,
5047
best=best)
5148
best = device
5249

5350
# Select the smallest image (disk space requirement)
5451
elif parse_version(device['version']) == parse_version(best['version']):
55-
if int(device['filesize']) + int(device['zipfilesize']) < int(best['filesize']) + int(best['zipfilesize']):
56-
log(0, '{device[hwid]} ({device_size}) is smaller than {best[hwid]} ({best_size})',
52+
if int(device['zipfilesize']) < int(best['zipfilesize']):
53+
log(0, '{device[boardname]} ({device_size}) is smaller than {best[boardname]} ({best_size})',
5754
device=device,
55+
device_size=int(device['zipfilesize']),
5856
best=best,
59-
device_size=int(device['filesize']) + int(device['zipfilesize']),
60-
best_size=int(best['filesize']) + int(best['zipfilesize']))
57+
best_size=int(best['zipfilesize']))
6158
best = device
6259

6360
return best
@@ -96,7 +93,7 @@ def install_widevine_arm(backup_path):
9693
localize(30018, diskspace=sizeof_fmt(required_diskspace)))
9794
return False
9895

99-
log(2, 'Downloading ChromeOS image for Widevine: {hwid} ({version})'.format(**arm_device))
96+
log(2, 'Downloading ChromeOS image for Widevine: {boardname} ({version})'.format(**arm_device))
10097
url = arm_device['url']
10198

10299
extracted = dl_extract_widevine(url, backup_path, arm_device)

tests/checkchromeos.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from __future__ import absolute_import, division, print_function, unicode_literals
55
from xml.etree import ElementTree as ET
66
import requests
7-
from lib.inputstreamhelper.config import CHROMEOS_RECOVERY_ARM_HWIDS, CHROMEOS_RECOVERY_ARM64_HWIDS
7+
from lib.inputstreamhelper.config import CHROMEOS_RECOVERY_ARM_BNAMES, CHROMEOS_RECOVERY_ARM64_BNAMES, CHROMEOS_RECOVERY_URL
88

99

1010
class OutdatedException(Exception):
@@ -33,9 +33,8 @@ def get_devices():
3333
device[keys[num]] = None
3434
if value.text:
3535
device[keys[num]] = value.text.strip()
36-
elif value.find('a') is not None:
37-
if value.find('a').text is not None:
38-
device[keys[num]] = value.find('a').text.strip()
36+
elif value.find('a') is not None and value.find('a').text is not None:
37+
device[keys[num]] = value.find('a').text.strip()
3938
devices.append(device)
4039
return devices
4140

@@ -61,8 +60,7 @@ def get_serves():
6160

6261
def get_recoveries():
6362
"""Get Chrome OS recovery items as json object"""
64-
url = 'https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.json'
65-
response = requests.get(url, timeout=10)
63+
response = requests.get(CHROMEOS_RECOVERY_URL, timeout=10)
6664
response.raise_for_status()
6765
recoveries = response.json()
6866
return recoveries
@@ -98,33 +96,33 @@ def get_smallest():
9896
return smallest
9997

10098

101-
def check_hwids():
102-
"""Check if hardware id's in inputstreamhelper.config are up to date"""
99+
def check_boardnames():
100+
"""Check if boardnames in inputstreamhelper.config are up to date"""
103101
compatibles = get_compatibles()
104-
hwids = []
102+
bnames = []
105103
messages = []
106104
for compatible in compatibles:
107-
hwid = compatible.get('hwidmatch').strip('^.*-').split(' ')[0]
108-
if hwid not in hwids:
109-
hwids.append(hwid)
105+
bname = compatible.get('file').split('_')[2]
106+
if bname not in bnames:
107+
bnames.append(bname)
110108

111-
for item in CHROMEOS_RECOVERY_ARM_HWIDS + CHROMEOS_RECOVERY_ARM64_HWIDS:
112-
if item not in hwids:
109+
for item in CHROMEOS_RECOVERY_ARM_BNAMES + CHROMEOS_RECOVERY_ARM64_BNAMES:
110+
if item not in bnames:
113111
messages.append('{} is end-of-life, consider removing it from inputstreamhelper config'.format(item))
114-
for item in hwids:
115-
if item not in CHROMEOS_RECOVERY_ARM_HWIDS + CHROMEOS_RECOVERY_ARM64_HWIDS:
112+
for item in bnames:
113+
if item not in CHROMEOS_RECOVERY_ARM_BNAMES + CHROMEOS_RECOVERY_ARM64_BNAMES:
116114
messages.append('{} is missing, please add it to inputstreamhelper config'.format(item))
117115
if messages:
118116
raise OutdatedException(messages)
119117

120118
smallest = get_smallest()
121-
hwid = smallest.get('hwidmatch').strip('^.*-').split(' ')[0]
122-
print('Chrome OS hardware id\'s are up to date, current smallest recovery image is {}'.format(hwid))
119+
bname = smallest.get('file').split('_')[2]
120+
print('Chrome OS boardnames are up to date, current smallest recovery image is {}'.format(bname))
123121

124122

125123
def run():
126124
"""Main function"""
127-
check_hwids()
125+
check_boardnames()
128126

129127

130128
if __name__ == '__main__':

0 commit comments

Comments
 (0)