Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / v8 / update.sh
blobc3fbab6faf198a7f0d0f84d1527b9c3022fa250c
1 #!/usr/bin/env nix-shell
2 #! nix-shell -i bash -p curl -p nix-prefetch-git -p jq
3 VERSION_OVERVIEW=https://omahaproxy.appspot.com/all?os=linux
4 TARGET_CHANNEL=stable
6 set -eo pipefail
8 if [ -n "$1" ]; then
9 v8_version="$1"
10 shift
11 else
12 v8_version=$(curl -s "$VERSION_OVERVIEW" | awk -F "," "\$2 ~ /${TARGET_CHANNEL}/ { print \$11 }")
15 if [ -n "$1" ]; then
16 file_path="$1"
17 else
18 file_path=default.nix
21 echo "Using V8 version --> $v8_version"
23 prefetched=$(nix-prefetch-git --no-deepClone https://chromium.googlesource.com/v8/v8 "refs/tags/${v8_version}")
25 path=$(echo "$prefetched" | jq -r .path)
26 sha256=$(echo "$prefetched" | jq -r .sha256)
27 sed -e "s#\\(version = \\)\"[0-9\.]*\"#\1\"$v8_version\"#" -i ${file_path}
28 sed -e "/v8Src = fetchgit/ { n; n; n; s/\".*\"/\"${sha256}\"/ }" -i ${file_path}
30 deps="$path/DEPS"
32 echo "$deps"
34 echo "Processing gn"
35 gn_rev=$(sed -ne "s/.*'gn_version': 'git_revision:\([^']*\).*/\1/p" < "$deps")
36 gn_sha256=$(nix-prefetch-git --no-deepClone https://gn.googlesource.com/gn "$gn_rev" 2>/dev/null | jq -r .sha256)
37 sed -e "/gnSrc = fetchgit/ { n; n; s/\".*\"/\"${gn_rev}\"/; n; s/\".*\"/\"${gn_sha256}\"/ }" -i ${file_path}
39 sed -ne '/" = fetchgit {/ { s/.*"\(.*\)".*/\1/; p }' < ${file_path} | while read dep; do
40 echo "Processing dependency --> $dep"
41 escaped_dep=$(echo "$dep" | sed -e 's#/#\\/#g')
42 dep_rev=$(sed -ne "/'${escaped_dep}':/ { n; s#.*+ '##; s#'.*##; p }" "$deps")
44 if [ "$dep_rev" = "" ]; then
45 echo "Failed to resolve dependency $dep, not listed in DEPS file"
46 rm -f "$deps"
47 exit 2
50 repo_url=$(sed -ne "/\"${escaped_dep}\" = fetchgit/ { n; s/.*\"\(.*\)\".*/\1/; s#\${git_url}#https://chromium.googlesource.com#; p }" ${file_path})
51 sha256=$(nix-prefetch-git --no-deepClone "$repo_url" "$dep_rev" 2>/dev/null | jq -r .sha256)
53 if [ "$sha256" = "" ]; then
54 echo "Failed to get sha256 via nix-prefetch-git $repo_url $dep_rev"
55 rm -f "$deps"
56 exit 2
59 sed -e "/\"${escaped_dep}\" = fetchgit/ { n; n; s/\".*\"/\"${dep_rev}\"/; n; s/\".*\"/\"${sha256}\"/ }" -i ${file_path}
60 done
62 echo done.