<commit_before>#!/bin/bash
set -e

# comparing version: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" == "$1"; }

# extract checksum for node binary
function extract_checksum()
{
	# $1: binary type, 0: in-house, 1: official.
	# $2: node version
	# $3: variable name for result

	local __resultVar=$3

	if [ $1 -eq 0 ]; then
		local __checksum=$(grep " node-v$2-linux-$binaryArch.tar.gz" SHASUMS256.txt)
	else
		curl -SLO "https://nodejs.org/dist/v$2/SHASUMS256.txt.asc" \
		&& gpg --verify SHASUMS256.txt.asc \
		&& local __checksum=$(grep " node-v$2-linux-$binaryArch.tar.gz\$" SHASUMS256.txt.asc) \
		&& rm -f SHASUMS256.txt.asc
	fi
	eval $__resultVar="'$__checksum'"
}

# gpg keys listed at https://github.com/nodejs/node
for key in \
9554F04D7259F04124DE6B476D5A82AC7E37093B \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
<KEY> \
<KEY>DE3FC1 \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
7937DFD2AB06298B2293C3187D33FF9D0246406D \
114F43EE0176B71C7BC219DD50A3051F888C628D \
56730D5401028683275BD23C23EFEFE93C4CFFFE \
; do \
	gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done

devices='raspberry-pi raspberry-pi2 beaglebone-black intel-edison intel-nuc via-vab820-quad zynq-xz702 odroid-c1 odroid-xu4 parallella nitrogen6x hummingboard ts4900 colibri-imx6dl apalis-imx6q ts7700 raspberrypi3 artik5 artik10 beaglebone-green-wifi qemux86 qemux86-64 beaglebone-green cybertan-ze250 artik710 am571x-evm up-board kitra710 imx6ul-var-dart ccon-01 kitra520 jetson-tx2'
fedora_devices=' raspberry-pi2 beaglebone-black via-vab820-quad zynq-xz702 odroid-c1 odroid-xu4 parallella nitrogen6x hummingboard ts4900 colibri-imx6dl apalis-imx6q raspberrypi3 artik5 artik10 beaglebone-green-wifi beaglebone-green intel-nuc qemux86-64 artik710 am571x-evm kitra710 up-board imx6ul-var-dart ccon-01 kitra520 jetson-tx2 '
nodeVersions='0.10.22 0.10.48 0.12.18 4.8.4 5.12.0 6.11.1 7.10.1 8.1.4'
defaultVersion='0.10.22'
resinUrl="http://resin-packages.s3.amazonaws.com/node/v\$NODE_VERSION/node-v\$NODE_VERSION-linux-#{TARGET_ARCH}.tar.gz"
nodejsUrl="http://nodejs.org/dist/v\$NODE_VERSION/node-v\$NODE_VERSION-linux-#{TARGET_ARCH}.tar.gz"

for device in $devices; do
	for nodeVersion in $nodeVersions; do
		case "$device" in
		'raspberry-pi')
			binaryUrl=$resinUrl
			binaryArch='armv6hf'
		;;
		'raspberry-pi2')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'raspberrypi3')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'beaglebone-black')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'beaglebone-green-wifi')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'beaglebone-green')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'intel-edison')
			binaryUrl=$nodejsUrl
			binaryArch='x86'
		;;
		'qemux86')
			binaryUrl=$nodejsUrl
			binaryArch='x86'
		;;
		'cybertan-ze250')
			binaryUrl=$resinUrl
			binaryArch='i386'
		;;
		'intel-nuc')
			binaryUrl=$nodejsUrl
			binaryArch='x64'
		;;
		'qemux86-64')
			binaryUrl=$nodejsUrl
			binaryArch='x64'
		;;
		'up-board')
			binaryUrl=$nodejsUrl
			binaryArch='x64'
		;;
		'via-vab820-quad')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'zynq-xz702')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'odroid-c1')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'odroid-xu4')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'parallella')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'nitrogen6x')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'hummingboard')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'ts4900')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'colibri-imx6dl')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'apalis-imx6q')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'am571x-evm')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'ts7700')
			binaryUrl=$resinUrl
			binaryArch='armel'
		;;
		'artik5')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'artik10')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'artik710')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'kitra710')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'kitra520')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'imx6ul-var-dart')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'ccon-01')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'jetson-tx2')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		esac
		if [ $nodeVersion == $defaultVersion ]; then
			baseVersion='default'
		else
			baseVersion=$(expr match "$nodeVersion" '\([0-9]*\.[0-9]*\)')
		fi

		if (version_ge "$nodeVersion" "7") && [ $binaryArch == "armel" ]; then
			continue
		fi<commit_msg>Only generate node v0.10.x armel base images<commit_after>#!/bin/bash
set -e

# comparing version: http://stackoverflow.com/questions/16989598/bash-comparing-version-numbers
function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" == "$1"; }

# extract checksum for node binary
function extract_checksum()
{
	# $1: binary type, 0: in-house, 1: official.
	# $2: node version
	# $3: variable name for result

	local __resultVar=$3

	if [ $1 -eq 0 ]; then
		local __checksum=$(grep " node-v$2-linux-$binaryArch.tar.gz" SHASUMS256.txt)
	else
		curl -SLO "https://nodejs.org/dist/v$2/SHASUMS256.txt.asc" \
		&& gpg --verify SHASUMS256.txt.asc \
		&& local __checksum=$(grep " node-v$2-linux-$binaryArch.tar.gz\$" SHASUMS256.txt.asc) \
		&& rm -f SHASUMS256.txt.asc
	fi
	eval $__resultVar="'$__checksum'"
}

# gpg keys listed at https://github.com/nodejs/node
for key in \
9554F04D7259F04124DE6B476D5A82AC7E37093B \
94AE36675C464D64BAFA68DD7434390BDBE9B9C5 \
0034A06D9D9B0064CE8ADF6BF1747F4AD2306D93 \
<KEY> \
<KEY> \
DD8F2338BAE7501E3DD5AC78C273792F7D83545D \
B9AE9905FFD7803F25714661B63B535A4C206CA9 \
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8 \
7937DFD2AB06298B2293C3187D33FF9D0246406D \
<KEY> \
56730D5401028683275BD23C23EFEFE93C4CFFFE \
; do \
	gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
done

devices='raspberry-pi raspberry-pi2 beaglebone-black intel-edison intel-nuc via-vab820-quad zynq-xz702 odroid-c1 odroid-xu4 parallella nitrogen6x hummingboard ts4900 colibri-imx6dl apalis-imx6q ts7700 raspberrypi3 artik5 artik10 beaglebone-green-wifi qemux86 qemux86-64 beaglebone-green cybertan-ze250 artik710 am571x-evm up-board kitra710 imx6ul-var-dart ccon-01 kitra520 jetson-tx2'
fedora_devices=' raspberry-pi2 beaglebone-black via-vab820-quad zynq-xz702 odroid-c1 odroid-xu4 parallella nitrogen6x hummingboard ts4900 colibri-imx6dl apalis-imx6q raspberrypi3 artik5 artik10 beaglebone-green-wifi beaglebone-green intel-nuc qemux86-64 artik710 am571x-evm kitra710 up-board imx6ul-var-dart ccon-01 kitra520 jetson-tx2 '
nodeVersions='0.10.22 0.10.48 0.12.18 4.8.4 5.12.0 6.11.1 7.10.1 8.1.4'
defaultVersion='0.10.22'
resinUrl="http://resin-packages.s3.amazonaws.com/node/v\$NODE_VERSION/node-v\$NODE_VERSION-linux-#{TARGET_ARCH}.tar.gz"
nodejsUrl="http://nodejs.org/dist/v\$NODE_VERSION/node-v\$NODE_VERSION-linux-#{TARGET_ARCH}.tar.gz"

for device in $devices; do
	for nodeVersion in $nodeVersions; do
		case "$device" in
		'raspberry-pi')
			binaryUrl=$resinUrl
			binaryArch='armv6hf'
		;;
		'raspberry-pi2')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'raspberrypi3')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'beaglebone-black')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'beaglebone-green-wifi')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'beaglebone-green')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'intel-edison')
			binaryUrl=$nodejsUrl
			binaryArch='x86'
		;;
		'qemux86')
			binaryUrl=$nodejsUrl
			binaryArch='x86'
		;;
		'cybertan-ze250')
			binaryUrl=$resinUrl
			binaryArch='i386'
		;;
		'intel-nuc')
			binaryUrl=$nodejsUrl
			binaryArch='x64'
		;;
		'qemux86-64')
			binaryUrl=$nodejsUrl
			binaryArch='x64'
		;;
		'up-board')
			binaryUrl=$nodejsUrl
			binaryArch='x64'
		;;
		'via-vab820-quad')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'zynq-xz702')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'odroid-c1')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'odroid-xu4')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'parallella')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'nitrogen6x')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'hummingboard')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'ts4900')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'colibri-imx6dl')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'apalis-imx6q')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'am571x-evm')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'ts7700')
			binaryUrl=$resinUrl
			binaryArch='armel'
		;;
		'artik5')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'artik10')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'artik710')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'kitra710')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'kitra520')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'imx6ul-var-dart')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'ccon-01')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		'jetson-tx2')
			binaryUrl=$resinUrl
			binaryArch='armv7hf'
		;;
		esac
		if [ $nodeVersion == $defaultVersion ]; then
			baseVersion='default'
		else
			baseVersion=$(expr match "$nodeVersion" '\([0-9]*\.[0-9]*\)')
		fi

		if [ $baseVersion != '0.10' ] && [ $binaryArch == "armel" ]; then
			continue
		fi
{'fraction_non_alphanumeric': 0.14405480012268684, 'fraction_numerical': 0.09774051732951641, 'mean_word_length': 4.143007360672976, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3379004', 'n_tokens_mistral': 5091, 'n_tokens_neox': 4179, 'n_words': 594}