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