Skip to content

Commit

Permalink
chromium: resolve ref to rev for blink version string
Browse files Browse the repository at this point in the history
This allows us to match the version the binaries use more closely.

For example, chromedriver darwin (binary) reports the following:

~~~bash
chromedriver --version
ChromeDriver 131.0.6778.85 (3d81e41b6f3ac8bcae63b32e8145c9eb0cd60a2d-refs/branch-heads/6778@{#2285})
~~~

while on Linux, where we build chromedriver based on the chromium
derivation from source and control the string ourselves:

~~~bash
chromedriver --version
ChromeDriver 131.0.6778.85 (131.0.6778.85-refs/heads/master@{#0})
~~~

With this commit, the version string now reports:

~~~bash
chromedriver --version
ChromeDriver 131.0.6778.85 (3d81e41b6f3ac8bcae63b32e8145c9eb0cd60a2d-refs/tags/131.0.6778.85@{#0})
~~~

This may seem like a small and unimportant detail, but turns out an
internal function within chromedriver depends on the git hash.

See https://chromium.googlesource.com/chromium/src/+/131.0.6778.85/chrome/test/chromedriver/chrome/browser_info.cc#172

This caused the tests of one package (single-file-cli) that use
selenium with chromium and chromedriver to fail in 24.05.

Only in 24.05, because 24.11 and unstable removed their test dependency
on chromedriver because it wasn't available for aarch64-linux at that
time.

~~~
Running phase: checkPhase
Serving HTTP on 127.0.0.1 port 8000 (http://127.0.0.1:8000/) ...
session not created
from unknown error: unrecognized Blink revision: 131.0.6778.85 URL: http://127.0.0.1:8000
Stack: SessionNotCreatedError: session not created
from unknown error: unrecognized Blink revision: 131.0.6778.85
    at Object.throwDecodedError (/build/source/node_modules/selenium-webdriver/lib/error.js:524:15)
    at parseHttpResponse (/build/source/node_modules/selenium-webdriver/lib/http.js:601:13)
    at Executor.execute (/build/source/node_modules/selenium-webdriver/lib/http.js:529:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
~~~

(cherry picked from commit 2a765df)
  • Loading branch information
emilylange committed Nov 25, 2024
1 parent 2a396b1 commit 2891716
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkgs/applications/networking/browsers/chromium/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ let
postPatch = lib.optionalString (!isElectron) ''
ln -s ${./files/gclient_args.gni} build/config/gclient_args.gni
echo 'LASTCHANGE=${upstream-info.DEPS."src".rev}-refs/heads/master@{#0}' > build/util/LASTCHANGE
echo 'LASTCHANGE=${upstream-info.DEPS."src".rev}-refs/tags/${version}@{#0}' > build/util/LASTCHANGE
echo "$SOURCE_DATE_EPOCH" > build/util/LASTCHANGE.committime
cat << EOF > gpu/config/gpu_lists_version.h
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/networking/browsers/chromium/info.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"DEPS": {
"src": {
"url": "https://chromium.googlesource.com/chromium/src.git",
"rev": "131.0.6778.85",
"rev": "3d81e41b6f3ac8bcae63b32e8145c9eb0cd60a2d",
"hash": "sha256-fREToEHVbTD0IVGx/sn7csSju4BYajWZ+LDCiKWV4cI=",
"recompress": true
},
Expand Down Expand Up @@ -785,7 +785,7 @@
"DEPS": {
"src": {
"url": "https://chromium.googlesource.com/chromium/src.git",
"rev": "131.0.6778.85",
"rev": "3d81e41b6f3ac8bcae63b32e8145c9eb0cd60a2d",
"hash": "sha256-fREToEHVbTD0IVGx/sn7csSju4BYajWZ+LDCiKWV4cI=",
"recompress": true
},
Expand Down
16 changes: 13 additions & 3 deletions pkgs/applications/networking/browsers/chromium/update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ for (const attr_path of Object.keys(lockfile)) {
// unconditionally remove ungoogled-chromium's epoch/sub-version (e.g. 130.0.6723.116-1 -> 130.0.6723.116)
const version_chromium = version_upstream.split('-')[0]

const chromium_rev = await chromium_resolve_tag_to_rev(version_chromium)

lockfile[attr_path] = {
version: version_chromium,
chromedriver: !ungoogled ? await fetch_chromedriver_binaries(version_chromium) : undefined,
Expand All @@ -62,20 +64,20 @@ for (const attr_path of Object.keys(lockfile)) {
DEPS: {},
}

const depot_tools = await fetch_depot_tools(version_chromium, lockfile_initial[attr_path].deps.depot_tools)
const depot_tools = await fetch_depot_tools(chromium_rev, lockfile_initial[attr_path].deps.depot_tools)
lockfile[attr_path].deps.depot_tools = {
rev: depot_tools.rev,
hash: depot_tools.hash,
}

const gn = await fetch_gn(version_chromium, lockfile_initial[attr_path].deps.gn)
const gn = await fetch_gn(chromium_rev, lockfile_initial[attr_path].deps.gn)
lockfile[attr_path].deps.gn = {
rev: gn.rev,
hash: gn.hash,
}

// DEPS update loop
lockfile[attr_path].DEPS = await resolve_DEPS(depot_tools.out, version_chromium)
lockfile[attr_path].DEPS = await resolve_DEPS(depot_tools.out, chromium_rev)
for (const [path, value] of Object.entries(lockfile[attr_path].DEPS)) {
delete value.fetcher
delete value.postFetch
Expand Down Expand Up @@ -147,6 +149,14 @@ async function fetch_chromedriver_binaries(chromium_version) {
}


async function chromium_resolve_tag_to_rev(tag) {
const url = `https://chromium.googlesource.com/chromium/src/+/refs/tags/${tag}?format=json`
const response = await (await fetch(url)).text()
const json = JSON.parse(response.replace(`)]}'\n`, ''))
return json.commit
}


async function resolve_DEPS(depot_tools_checkout, chromium_rev) {
const { stdout } = await $`./depot_tools.py ${depot_tools_checkout} ${chromium_rev}`
const deps = JSON.parse(stdout)
Expand Down

0 comments on commit 2891716

Please sign in to comment.