]> git.wh0rd.org - home.git/blob - .bin/update-vapier-nodejs
update extensions path
[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/extensions
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_CHROMIUM_BASE='https://chromium.googlesource.com/chromium/src/+/master'
15 URL_DEPS="${URL_CHROMIUM_BASE}/DEPS?format=TEXT"
16 URL_HASH_NODE="${URL_CHROMIUM_BASE}/third_party/node/linux/node-linux-x64.tar.gz.sha1?format=TEXT"
17 URL_HASH_MOD="${URL_CHROMIUM_BASE}/third_party/node/node_modules.tar.gz.sha1?format=TEXT"
18
19 hash=$(curl -s "${URL_DEPS}" | base64 -d)
20 VER=$(echo "${hash}" | grep -o 'chromium-nodejs/[0-9.]*' | sort -u | cut -d/ -f2)
21
22 hash=$(curl -s "${URL_HASH_NODE}" | base64 -d)
23 dir='node-linux-x64'
24 cur_hash=$(cat "${dir}/hash" 2>/dev/null || :)
25 if [[ ${cur_hash} != "${hash}" ]]; then
26 rm -rf "${dir}" "${cur_hash}"
27 wget -m -nd "${URL_GS_BASE}/${VER}/${hash}"
28 echo "Unpacking ${hash} into ${dir}"
29 tar xf "${hash}"
30 echo "${hash}" >"${dir}/hash"
31 fi
32
33 ln -sfT "${dir}" current
34
35
36 hash=$(curl -s "${URL_HASH_MOD}" | base64 -d)
37 dir='node_modules'
38 cur_hash=$(cat "${dir}/hash" 2>/dev/null || :)
39 if [[ ${cur_hash} != "${hash}" ]]; then
40 rm -rf "${dir}" "${cur_hash}"
41 wget -m -nd "${URL_GS_BASE}/${hash}"
42 echo "Unpacking ${hash} into ${dir}"
43 tar xf "${hash}"
44 echo "${hash}" >"${dir}/hash"
45 fi
46
47 ln -sfT ../../node_modules/eslint/bin/eslint.js current/bin/eslint
48
49
50 echo "Up-to-date now"
51
52
53 exit 0
54 # This is for nodejs directly.
55 URL_BASE='https://nodejs.org/dist/latest-v6.x'
56 SUMS='SHASUMS256.txt'
57 URL_SUMS="${URL_BASE}/${SUMS}"
58
59 wget -m -nd "${URL_SUMS}"
60
61 read sum tar < <(grep 'linux-x64.tar.xz' "${SUMS}")
62 dir=${tar%.tar.xz}
63
64 URL_TAR="${URL_BASE}/${tar}"
65 wget -m -nd "${URL_TAR}"
66
67 if [[ ! -d ${dir} ]] ; then
68 tar xf "${tar}"
69 ln -sfT "${dir}" current
70 fi