Skip to content

Commit

Permalink
chromedriver: Switch to Chromium's upstream-info.json (NixOS#105054)
Browse files Browse the repository at this point in the history
This enables automatic updates and fixes NixOS#85629.
  • Loading branch information
primeos committed Nov 27, 2020
1 parent 33b99ef commit 6aea53c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
16 changes: 16 additions & 0 deletions pkgs/applications/networking/browsers/chromium/update.py
Expand Up @@ -38,6 +38,20 @@ def get_file_revision(revision, file_path):
with urlopen(url) as http_response:
return http_response.read()

def get_matching_chromedriver(version):
# See https://chromedriver.chromium.org/downloads/version-selection
build = re.sub('.[0-9]+$', '', version)
chromedriver_version_url = f'https://chromedriver.storage.googleapis.com/LATEST_RELEASE_{build}'
with urlopen(chromedriver_version_url) as http_response:
chromedriver_version = http_response.read().decode()
def get_chromedriver_url(system):
return f'https://chromedriver.storage.googleapis.com/{chromedriver_version}/chromedriver_{system}.zip'
return {
'version': chromedriver_version,
'sha256_linux': nix_prefetch_url(get_chromedriver_url('linux64')),
'sha256_darwin': nix_prefetch_url(get_chromedriver_url('mac64'))
}

def get_channel_dependencies(channel):
deps = get_file_revision(channel['version'], 'DEPS')
gn_pattern = b"'gn_version': 'git_revision:([0-9a-f]{40})'"
Expand Down Expand Up @@ -85,6 +99,8 @@ def get_channel_dependencies(channel):
continue

channel['deps'] = get_channel_dependencies(channel)
if channel_name == 'stable':
channel['chromedriver'] = get_matching_chromedriver(channel['version'])

channels[channel_name] = channel

Expand Down
Expand Up @@ -10,6 +10,11 @@
"rev": "e002e68a48d1c82648eadde2f6aafa20d08c36f2",
"sha256": "0x4c7amxwzxs39grqs3dnnz0531mpf1p75niq7zhinyfqm86i4dk"
}
},
"chromedriver": {
"version": "87.0.4280.20",
"sha256_linux": "1cpk7mb32z3a7c7cbaaxskpv91il3i8kgsdp2q8zw9w762kql953",
"sha256_darwin": "06mx2yk6xy46azvkbyvhqm11prxbh67pfi50fcwxb0zqllbq7scr"
}
},
"beta": {
Expand Down
29 changes: 20 additions & 9 deletions pkgs/development/tools/selenium/chromedriver/default.nix
@@ -1,17 +1,20 @@
{ stdenv, fetchurl, cairo, fontconfig, freetype, gdk-pixbuf, glib
, glibc, gtk2, libX11, makeWrapper, nspr, nss, pango, unzip, gconf
{ stdenv, fetchurl, unzip, makeWrapper
, cairo, fontconfig, freetype, gdk-pixbuf, glib
, glibc, gtk2, libX11, nspr, nss, pango, gconf
, libxcb, libXi, libXrender, libXext
}:

let
upstream-info = (stdenv.lib.importJSON ../../../../applications/networking/browsers/chromium/upstream-info.json).stable.chromedriver;
allSpecs = {
x86_64-linux = {
system = "linux64";
sha256 = "1cpk7mb32z3a7c7cbaaxskpv91il3i8kgsdp2q8zw9w762kql953";
sha256 = upstream-info.sha256_linux;
};

x86_64-darwin = {
system = "mac64";
sha256 = "06mx2yk6xy46azvkbyvhqm11prxbh67pfi50fcwxb0zqllbq7scr";
sha256 = upstream-info.sha256_darwin;
};
};

Expand All @@ -25,10 +28,10 @@ let
libX11 nspr nss pango libXrender
gconf libxcb libXext libXi
];
in
stdenv.mkDerivation rec {

in stdenv.mkDerivation rec {
pname = "chromedriver";
version = "87.0.4280.20";
version = upstream-info.version;

src = fetchurl {
url = "https://chromedriver.storage.googleapis.com/${version}/chromedriver_${spec.system}.zip";
Expand All @@ -47,10 +50,18 @@ stdenv.mkDerivation rec {
'';

meta = with stdenv.lib; {
homepage = "https://sites.google.com/a/chromium.org/chromedriver";
homepage = "https://chromedriver.chromium.org/";
description = "A WebDriver server for running Selenium tests on Chrome";
longDescription = ''
WebDriver is an open source tool for automated testing of webapps across
many browsers. It provides capabilities for navigating to web pages, user
input, JavaScript execution, and more. ChromeDriver is a standalone
server that implements the W3C WebDriver standard.
'';
license = licenses.bsd3;
maintainers = [ maintainers.goibhniu maintainers.marsam ];
maintainers = with maintainers; [ goibhniu marsam primeos ];
# Note from primeos: By updating Chromium I also update Google Chrome and
# ChromeDriver.
platforms = attrNames allSpecs;
};
}

0 comments on commit 6aea53c

Please sign in to comment.