at 24.05-pre 62 lines 2.1 kB view raw
1#!/usr/bin/env nix-shell 2#! nix-shell -i bash -p curl -p nix-prefetch-git -p jq 3VERSION_OVERVIEW=https://omahaproxy.appspot.com/all?os=linux 4TARGET_CHANNEL=stable 5 6set -eo pipefail 7 8if [ -n "$1" ]; then 9 v8_version="$1" 10 shift 11else 12 v8_version=$(curl -s "$VERSION_OVERVIEW" | awk -F "," "\$2 ~ /${TARGET_CHANNEL}/ { print \$11 }") 13fi 14 15if [ -n "$1" ]; then 16 file_path="$1" 17else 18 file_path=default.nix 19fi 20 21echo "Using V8 version --> $v8_version" 22 23prefetched=$(nix-prefetch-git --no-deepClone https://chromium.googlesource.com/v8/v8 "refs/tags/${v8_version}") 24 25path=$(echo "$prefetched" | jq -r .path) 26sha256=$(echo "$prefetched" | jq -r .sha256) 27sed -e "s#\\(version = \\)\"[0-9\.]*\"#\1\"$v8_version\"#" -i ${file_path} 28sed -e "/v8Src = fetchgit/ { n; n; n; s/\".*\"/\"${sha256}\"/ }" -i ${file_path} 29 30deps="$path/DEPS" 31 32echo "$deps" 33 34echo "Processing gn" 35gn_rev=$(sed -ne "s/.*'gn_version': 'git_revision:\([^']*\).*/\1/p" < "$deps") 36gn_sha256=$(nix-prefetch-git --no-deepClone https://gn.googlesource.com/gn "$gn_rev" 2>/dev/null | jq -r .sha256) 37sed -e "/gnSrc = fetchgit/ { n; n; s/\".*\"/\"${gn_rev}\"/; n; s/\".*\"/\"${gn_sha256}\"/ }" -i ${file_path} 38 39sed -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") 43 44 if [ "$dep_rev" = "" ]; then 45 echo "Failed to resolve dependency $dep, not listed in DEPS file" 46 rm -f "$deps" 47 exit 2 48 fi 49 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) 52 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 57 fi 58 59 sed -e "/\"${escaped_dep}\" = fetchgit/ { n; n; s/\".*\"/\"${dep_rev}\"/; n; s/\".*\"/\"${sha256}\"/ }" -i ${file_path} 60done 61 62echo done.