Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 | |
| 3 # Copyright 2017 The Chromium Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 # Script for updating Node binaries. | |
| 8 # 1) Update NODE_VERSION variable below to the desired version. | |
| 9 # 2) Run this script. | |
| 10 # 3) Upload the binaries to the Google Storage bucket (commands to upload | |
| 11 # binaries are printed at step 2, look for "gsutil.py"). | |
| 12 # 4) Land a CL with the changes generated by this script. | |
| 13 | |
| 14 set -eu | |
| 15 cd "$(dirname "$0")" | |
| 16 | |
| 17 BASE_URL="https://nodejs.org/dist" | |
| 18 NODE_VERSION="v6.9.4" | |
| 19 | |
| 20 update_unix() { | |
| 21 local SUFFIX=$1 | |
| 22 local FOLDER=$2 | |
| 23 local FILENAME="node-${NODE_VERSION}-${SUFFIX}.tar.gz" | |
| 24 local URL="${BASE_URL}/${NODE_VERSION}/${FILENAME}" | |
| 25 | |
| 26 rm -f "${FOLDER}/${FILENAME}" | |
| 27 wget -P "${FOLDER}/" "${URL}" | |
| 28 | |
| 29 # Check SHASUMS256 of downloaded binary. | |
| 30 local sha256_expected | |
| 31 sha256_expected="$(cat SHASUMS256.txt | grep ${FILENAME} | cut -d ' ' -f1)" | |
| 32 local sha256_actual | |
| 33 sha256_actual="$(sha256sum ${FOLDER}/${FILENAME} | cut -d ' ' -f1)" | |
| 34 | |
| 35 if [ "${sha256_expected}" != "${sha256_actual}" ]; then | |
| 36 echo "SHA256 mismatch. Exiting..." | |
| 37 exit 1 | |
| 38 fi | |
| 39 | |
| 40 # Unpack temporarily, delete NPM symlink and re-pack. | |
| 41 tar xfz "${FOLDER}/${FILENAME}" -C "${FOLDER}/" | |
| 42 rm "${FOLDER}/${FILENAME}" | |
| 43 rm "${FOLDER}/node-${NODE_VERSION}-${SUFFIX}/bin/npm" | |
| 44 | |
| 45 # Drop the version info from the name, since it is redundant and would make | |
| 46 # rolling new versions more involved. | |
| 47 rm -rf "${FOLDER}/node-${SUFFIX}/" | |
| 48 mv "${FOLDER}/node-${NODE_VERSION}-${SUFFIX}/" "${FOLDER}/node-${SUFFIX}/" | |
| 49 tar cfz "${FOLDER}/node-${SUFFIX}.tar.gz" -C "${FOLDER}" "node-${SUFFIX}/" | |
| 50 local sha1 | |
| 51 sha1="$(sha1sum ${FOLDER}/node-${SUFFIX}.tar.gz | cut -d ' ' -f1)" | |
| 52 echo "${sha1}" > "${FOLDER}/node-${SUFFIX}.tar.gz.sha1" | |
| 53 echo "Please execute manually the following:" | |
| 54 echo "> gsutil.py cp ${FOLDER}/node-${SUFFIX}.tar.gz gs://chromium-nodejs/${NO DE_VERSION:1}/${sha1}" | |
| 55 echo "DONE updating for ${SUFFIX}." | |
| 56 } | |
| 57 | |
| 58 update_win() { | |
| 59 local FILENAME="node.exe" | |
| 60 local FOLDER="win" | |
| 61 local WINDOWS_URL="${BASE_URL}/${NODE_VERSION}/win-x64/${FILENAME}" | |
| 62 rm -f "${FOLDER}/${FILENAME}" | |
| 63 wget -P "${FOLDER}/" "${WINDOWS_URL}" | |
| 64 | |
| 65 # Check SHASUMS256 of downloaded binary. | |
| 66 local sha256_expected | |
| 67 sha256_expected="$(cat SHASUMS256.txt | grep win-x64/${FILENAME} | cut -d ' ' -f1)" | |
| 68 local sha256_actual | |
| 69 sha256_actual="$(sha256sum ${FOLDER}/${FILENAME} | cut -d ' ' -f1)" | |
| 70 echo $sha256_expected $sha256_actual | |
|
Dan Beam
2017/01/13 03:34:12
debug statement?
dpapad
2017/01/13 03:36:29
Removed.
| |
| 71 | |
| 72 if [ "${sha256_expected}" != "${sha256_actual}" ]; then | |
| 73 echo "SHA256 mismatch. Exiting..." | |
| 74 exit 1 | |
| 75 fi | |
| 76 | |
| 77 local sha1 | |
| 78 sha1="$(sha1sum ${FOLDER}/node.exe | cut -d ' ' -f1)" | |
| 79 echo "${sha1}" > "${FOLDER}/node.exe.sha1" | |
| 80 echo "Please execute manually the following:" | |
| 81 echo "> gsutil.py cp ${FOLDER}/node.exe gs://chromium-nodejs/${NODE_VERSION:1} /${sha1}" | |
| 82 echo "DONE updating Windows." | |
| 83 } | |
| 84 | |
| 85 # First download checksum file. | |
| 86 rm "SHASUMS256.txt" | |
| 87 wget "https://nodejs.org/dist/latest-v6.x/SHASUMS256.txt" | |
| 88 | |
| 89 update_unix "darwin-x64" "mac" | |
| 90 update_unix "linux-x64" "linux" | |
| 91 update_win | |
| 92 | |
| 93 # Update DEPS to point to the new Google Storage bucket subfolder. | |
| 94 sed -i "s@\(chromium-nodejs/\)\([0-9\.]\)\+@\1${NODE_VERSION:1}@" ../../DEPS | |
| OLD | NEW |