]> git.wh0rd.org - home.git/commitdiff
add update-vapier-nodejs
authorMike Frysinger <vapier@gentoo.org>
Thu, 21 Dec 2017 06:30:59 +0000 (01:30 -0500)
committerMike Frysinger <vapier@gentoo.org>
Thu, 21 Dec 2017 06:31:11 +0000 (01:31 -0500)
.bin/update-vapier-nodejs [new file with mode: 0755]
.profile.d/nodejs.sh [new file with mode: 0644]

diff --git a/.bin/update-vapier-nodejs b/.bin/update-vapier-nodejs
new file mode 100755 (executable)
index 0000000..41ddc2d
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# Update node install & modules from Chromium project.
+
+set -e
+
+cd /usr/local/src/chrome-ext
+if [[ ! -d nodejs ]]; then
+       mkdir nodejs
+fi
+cd nodejs
+
+URL_GS_BASE='https://storage.googleapis.com/chromium-nodejs'
+URL_HASH_NODE='https://chromium.googlesource.com/chromium/src/+/master/third_party/node/linux/node-linux-x64.tar.gz.sha1?format=TEXT'
+URL_HASH_MOD='https://chromium.googlesource.com/chromium/src/+/master/third_party/node/node_modules.tar.gz.sha1?format=TEXT'
+
+hash=$(curl -s "${URL_HASH_NODE}" | base64 -d)
+dir='node-linux-x64'
+cur_hash=$(cat "${dir}/hash" 2>/dev/null)
+if [[ ${cur_hash} != "${hash}" ]]; then
+       rm -rf "${dir}" "${cur_hash}"
+       wget -m -nd "${URL_GS_BASE}/6.9.4/${hash}"
+       echo "Unpacking ${hash} into ${dir}"
+       tar xf "${hash}"
+       echo "${hash}" >"${dir}/hash"
+fi
+
+ln -sfT "${dir}" current
+
+
+hash=$(curl -s "${URL_HASH_MOD}" | base64 -d)
+dir='node_modules'
+cur_hash=$(cat "${dir}/hash" 2>/dev/null)
+if [[ ${cur_hash} != "${hash}" ]]; then
+       rm -rf "${dir}" "${cur_hash}"
+       wget -m -nd "${URL_GS_BASE}/${hash}"
+       echo "Unpacking ${hash} into ${dir}"
+       tar xf "${hash}"
+       echo "${hash}" >"${dir}/hash"
+fi
+
+ln -sfT ../../node_modules/eslint/bin/eslint.js current/bin/eslint
+
+
+echo "Up-to-date now"
+
+
+exit 0
+# This is for nodejs directly.
+URL_BASE='https://nodejs.org/dist/latest-v6.x'
+SUMS='SHASUMS256.txt'
+URL_SUMS="${URL_BASE}/${SUMS}"
+
+wget -m -nd "${URL_SUMS}"
+
+read sum tar < <(grep 'linux-x64.tar.xz' "${SUMS}")
+dir=${tar%.tar.xz}
+
+URL_TAR="${URL_BASE}/${tar}"
+wget -m -nd "${URL_TAR}"
+
+if [[ ! -d ${dir} ]] ; then
+       tar xf "${tar}"
+       ln -sfT "${dir}" current
+fi
diff --git a/.profile.d/nodejs.sh b/.profile.d/nodejs.sh
new file mode 100644 (file)
index 0000000..9ca697e
--- /dev/null
@@ -0,0 +1,3 @@
+if [ -d "/usr/local/src/chrome-ext/nodejs/current/bin" ] ; then
+       PATH="/usr/local/src/chrome-ext/nodejs/current/bin:${PATH}"
+fi