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)" | |
palmer
2017/01/13 20:56:27
You can shorten this to
sha256_expected="$(gr
dpapad
2017/01/13 22:35:15
Done.
| |
32 local sha256_actual | |
palmer
2017/01/13 20:56:27
Nit: FWIW, you can combine the declaration and the
dpapad
2017/01/13 22:35:15
I am following the styleguide, which says:
"Declar
| |
33 sha256_actual="$(sha256sum ${FOLDER}/${FILENAME} | cut -d ' ' -f1)" | |
palmer
2017/01/13 20:56:28
Quotes here too, I think.
dpapad
2017/01/13 22:35:15
Done.
| |
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 | |
71 if [ "${sha256_expected}" != "${sha256_actual}" ]; then | |
72 echo "SHA256 mismatch. Exiting..." | |
73 exit 1 | |
74 fi | |
75 | |
76 local sha1 | |
77 sha1="$(sha1sum ${FOLDER}/node.exe | cut -d ' ' -f1)" | |
78 echo "${sha1}" > "${FOLDER}/node.exe.sha1" | |
79 echo "Please execute manually the following:" | |
80 echo "> gsutil.py cp ${FOLDER}/node.exe gs://chromium-nodejs/${NODE_VERSION:1} /${sha1}" | |
81 echo "DONE updating Windows." | |
82 } | |
83 | |
84 # First download checksum file. | |
85 rm "SHASUMS256.txt" | |
86 wget "https://nodejs.org/dist/latest-v6.x/SHASUMS256.txt" | |
87 | |
88 update_unix "darwin-x64" "mac" | |
89 update_unix "linux-x64" "linux" | |
90 update_win | |
91 | |
92 # Update DEPS to point to the new Google Storage bucket subfolder. | |
93 sed -i "s@\(chromium-nodejs/\)\([0-9\.]\)\+@\1${NODE_VERSION:1}@" ../../DEPS | |
OLD | NEW |