chromium: Extend update.py to automatically update gn
The gn version depends on the channel and new gn versions aren't always backward compatible. Therefore we should also include it in upstream-info.json (I've scoped it under "deps" as we'll likely have to add more like this in the future).
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python -p python3 nix
|
||||
#! nix-shell -i python -p python3 nix nix-prefetch-git
|
||||
|
||||
import csv
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from codecs import iterdecode
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
from os.path import abspath, dirname
|
||||
from urllib.request import urlopen
|
||||
|
||||
@@ -26,6 +28,30 @@ def nix_prefetch_url(url, algo='sha256'):
|
||||
out = subprocess.check_output(['nix-prefetch-url', '--type', algo, url])
|
||||
return out.decode('utf-8').rstrip()
|
||||
|
||||
def nix_prefetch_git(url, rev):
|
||||
print(f'nix-prefetch-git {url} {rev}')
|
||||
out = subprocess.check_output(['nix-prefetch-git', '--quiet', '--url', url, '--rev', rev])
|
||||
return json.loads(out)
|
||||
|
||||
def get_file_revision(revision, file_path):
|
||||
url = f'https://raw.githubusercontent.com/chromium/chromium/{revision}/{file_path}'
|
||||
with urlopen(url) as http_response:
|
||||
return http_response.read()
|
||||
|
||||
def get_channel_dependencies(channel):
|
||||
deps = get_file_revision(channel['version'], 'DEPS')
|
||||
gn_pattern = b"'gn_version': 'git_revision:([0-9a-f]{40})'"
|
||||
gn_commit = re.search(gn_pattern, deps).group(1).decode()
|
||||
gn = nix_prefetch_git('https://gn.googlesource.com/gn', gn_commit)
|
||||
return {
|
||||
'gn': {
|
||||
'version': datetime.fromisoformat(gn['date']).date().isoformat(),
|
||||
'url': gn['url'],
|
||||
'rev': gn['rev'],
|
||||
'sha256': gn['sha256']
|
||||
}
|
||||
}
|
||||
|
||||
channels = {}
|
||||
last_channels = load_json(JSON_PATH)
|
||||
|
||||
@@ -58,6 +84,8 @@ with urlopen(HISTORY_URL) as resp:
|
||||
# the next one.
|
||||
continue
|
||||
|
||||
channel['deps'] = get_channel_dependencies(channel)
|
||||
|
||||
channels[channel_name] = channel
|
||||
|
||||
with open(JSON_PATH, 'w') as out:
|
||||
|
||||
Reference in New Issue
Block a user