<commit_before>#!/usr/bin/env bash
set -Eeuo pipefail

cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

source '.architectures-lib'

# see http://stackoverflow.com/a/2705678/433558
sed_escape_rhs() {
	echo "$@" | sed -e 's/[\/&]/\\&/g' | sed -e ':a;N;$!ba;s/\n/\\n/g'
}

travisEnv=
appveyorEnv=
for version in '.'; do
	pattern='.*/julia-([0-9]+\.[0-9]+\.[0-9]+)-linux-x86_64\.tar\.gz.*'
	fullVersion="$(curl -fsSL 'https://julialang.org/downloads/' | sed -rn "s!${pattern}!\1!gp" | sort -ruV | head -1)"
	if [ -z "$fullVersion" ]; then
		echo >&2 "error: failed to determine latest release for '$version'"
		exit 1
	fi

	sha256s="$(curl -fsSL "https://julialang-s3.julialang.org/bin/checksums/julia-${fullVersion}.sha256")"

	linuxArchCase='dpkgArch="$(dpkg --print-architecture)"; '$'\\\n'
	linuxArchCase+=$'\t''case "${dpkgArch##*-}" in '$'\\\n'
	for dpkgArch in $(dpkgArches "$version"); do
		tarArch="$(dpkgToJuliaTarArch "$version" "$dpkgArch")"
		dirArch="$(dpkgToJuliaDirArch "$version" "$dpkgArch")"
		sha256="$(echo "$sha256s" | grep "*julia-${fullVersion}-linux-${tarArch}.tar.gz$" | cut -d' ' -f1)"
		if [ -z "$sha256" ]; then
			echo >&2 "error: cannot find sha256 for $fullVersion on arch $tarArch / $dirArch ($dpkgArch)"
			exit 1
		fi
		linuxArchCase+=$'\t\t'"$dpkgArch) tarArch='$tarArch'; dirArch='$dirArch'; sha256='$sha256' ;; "$'\\\n'
	done
	linuxArchCase+=$'\t\t''*) echo >&2 "error: current architecture ($dpkgArch) does not have a corresponding Julia binary release"; exit 1 ;; '$'\\\n'
	linuxArchCase+=$'\t''esac'

	winSha256="$(echo "$sha256s" | grep "*julia-${fullVersion}-win64.exe$" | cut -d' ' -f1)"

	echo "$version: $fullVersion"

	for v in \
		{jessie,stretch} \
		windows/windowsservercore-{1709,ltsc2016} \
	; do
		dir="$version/$v"
		variant="$(basename "$v")"

		mkdir -p "$dir"

		case "$variant" in
			windowsservercore-*) template='windowsservercore'; tag="${variant#*-}" ;;
			*) template='debian'; tag="$variant" ;;
		esac

		sed -r \
			-e 's!%%JULIA_VERSION%%!'"$fullVersion"'!g' \
			-e 's!%%TAG%%!'"$tag"'!g' \
			-e 's!%%JULIA_WINDOWS_SHA256%%!'"$winSha256"'!g' \
			-e 's!%%ARCH-CASE%%!'"$(sed_escape_rhs "$linuxArchCase")"'!g' \
			"Dockerfile-$template.template" > "$dir/Dockerfile"<commit_msg>Fix sha256 grep<commit_after>#!/usr/bin/env bash
set -Eeuo pipefail

cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

source '.architectures-lib'

# see http://stackoverflow.com/a/2705678/433558
sed_escape_rhs() {
	echo "$@" | sed -e 's/[\/&]/\\&/g' | sed -e ':a;N;$!ba;s/\n/\\n/g'
}

travisEnv=
appveyorEnv=
for version in '.'; do
	pattern='.*/julia-([0-9]+\.[0-9]+\.[0-9]+)-linux-x86_64\.tar\.gz.*'
	fullVersion="$(curl -fsSL 'https://julialang.org/downloads/' | sed -rn "s!${pattern}!\1!gp" | sort -ruV | head -1)"
	if [ -z "$fullVersion" ]; then
		echo >&2 "error: failed to determine latest release for '$version'"
		exit 1
	fi

	sha256s="$(curl -fsSL "https://julialang-s3.julialang.org/bin/checksums/julia-${fullVersion}.sha256")"

	linuxArchCase='dpkgArch="$(dpkg --print-architecture)"; '$'\\\n'
	linuxArchCase+=$'\t''case "${dpkgArch##*-}" in '$'\\\n'
	for dpkgArch in $(dpkgArches "$version"); do
		tarArch="$(dpkgToJuliaTarArch "$version" "$dpkgArch")"
		dirArch="$(dpkgToJuliaDirArch "$version" "$dpkgArch")"
		sha256="$(echo "$sha256s" | grep "julia-${fullVersion}-linux-${tarArch}.tar.gz$" | cut -d' ' -f1)"
		if [ -z "$sha256" ]; then
			echo >&2 "error: cannot find sha256 for $fullVersion on arch $tarArch / $dirArch ($dpkgArch)"
			exit 1
		fi
		linuxArchCase+=$'\t\t'"$dpkgArch) tarArch='$tarArch'; dirArch='$dirArch'; sha256='$sha256' ;; "$'\\\n'
	done
	linuxArchCase+=$'\t\t''*) echo >&2 "error: current architecture ($dpkgArch) does not have a corresponding Julia binary release"; exit 1 ;; '$'\\\n'
	linuxArchCase+=$'\t''esac'

	winSha256="$(echo "$sha256s" | grep "julia-${fullVersion}-win64.exe$" | cut -d' ' -f1)"

	echo "$version: $fullVersion"

	for v in \
		{jessie,stretch} \
		windows/windowsservercore-{1709,ltsc2016} \
	; do
		dir="$version/$v"
		variant="$(basename "$v")"

		mkdir -p "$dir"

		case "$variant" in
			windowsservercore-*) template='windowsservercore'; tag="${variant#*-}" ;;
			*) template='debian'; tag="$variant" ;;
		esac

		sed -r \
			-e 's!%%JULIA_VERSION%%!'"$fullVersion"'!g' \
			-e 's!%%TAG%%!'"$tag"'!g' \
			-e 's!%%JULIA_WINDOWS_SHA256%%!'"$winSha256"'!g' \
			-e 's!%%ARCH-CASE%%!'"$(sed_escape_rhs "$linuxArchCase")"'!g' \
			"Dockerfile-$template.template" > "$dir/Dockerfile"
{'fraction_non_alphanumeric': 0.24386981720909495, 'fraction_numerical': 0.036335265269728044, 'mean_word_length': 4.285041224970554, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '39281', 'n_tokens_mistral': 2057, 'n_tokens_neox': 1817, 'n_words': 351}