]> git.wh0rd.org - home.git/blob - .bin/update-vapier-nodejs
add update-vapier-nodejs
[home.git] / .bin / update-vapier-nodejs
1 #!/bin/bash
2
3 # Update node install & modules from Chromium project.
4
5 set -e
6
7 cd /usr/local/src/chrome-ext
8 if [[ ! -d nodejs ]]; then
9 mkdir nodejs
10 fi
11 cd nodejs
12
13 URL_GS_BASE='https://storage.googleapis.com/chromium-nodejs'
14 URL_HASH_NODE='https://chromium.googlesource.com/chromium/src/+/master/third_party/node/linux/node-linux-x64.tar.gz.sha1?format=TEXT'
15 URL_HASH_MOD='https://chromium.googlesource.com/chromium/src/+/master/third_party/node/node_modules.tar.gz.sha1?format=TEXT'
16
17 hash=$(curl -s "${URL_HASH_NODE}" | base64 -d)
18 dir='node-linux-x64'
19 cur_hash=$(cat "${dir}/hash" 2>/dev/null)
20 if [[ ${cur_hash} != "${hash}" ]]; then
21 rm -rf "${dir}" "${cur_hash}"
22 wget -m -nd "${URL_GS_BASE}/6.9.4/${hash}"
23 echo "Unpacking ${hash} into ${dir}"
24 tar xf "${hash}"
25 echo "${hash}" >"${dir}/hash"
26 fi
27
28 ln -sfT "${dir}" current
29
30
31 hash=$(curl -s "${URL_HASH_MOD}" | base64 -d)
32 dir='node_modules'
33 cur_hash=$(cat "${dir}/hash" 2>/dev/null)
34 if [[ ${cur_hash} != "${hash}" ]]; then
35 rm -rf "${dir}" "${cur_hash}"
36 wget -m -nd "${URL_GS_BASE}/${hash}"
37 echo "Unpacking ${hash} into ${dir}"
38 tar xf "${hash}"
39 echo "${hash}" >"${dir}/hash"
40 fi
41
42 ln -sfT ../../node_modules/eslint/bin/eslint.js current/bin/eslint
43
44
45 echo "Up-to-date now"
46
47
48 exit 0
49 # This is for nodejs directly.
50 URL_BASE='https://nodejs.org/dist/latest-v6.x'
51 SUMS='SHASUMS256.txt'
52 URL_SUMS="${URL_BASE}/${SUMS}"
53
54 wget -m -nd "${URL_SUMS}"
55
56 read sum tar < <(grep 'linux-x64.tar.xz' "${SUMS}")
57 dir=${tar%.tar.xz}
58
59 URL_TAR="${URL_BASE}/${tar}"
60 wget -m -nd "${URL_TAR}"
61
62 if [[ ! -d ${dir} ]] ; then
63 tar xf "${tar}"
64 ln -sfT "${dir}" current
65 fi