<commit_before>#!/bin/bash
set -eo pipefail

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

versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
	versions=( */ )
fi
versions=( "${versions[@]%/}" )

tags="$(git ls-remote --tags https://github.com/elastic/kibana.git | cut -d/ -f3 | cut -d^ -f1 | cut -dv -f2 | sort -rV)"
debArch="$(dpkg --print-architecture)"

travisEnv=
for version in "${versions[@]}"; do
	# major.minor.patch
	majorVersion="${version%%.*}"
	minorVersion="${version#$majorVersion.}"
	[ "$minorVersion" != "$version" ] || minorVersion=
	minorVersion="${minorVersion%%.*}"


	aptBucket="${majorVersion}.x"
	if [ "$rcVersion" != "$version" ]; then
		aptBucket+='-prerelease'
	fi
	debRepo="https://artifacts.elastic.co/packages/$aptBucket/apt"
	tarballUrlBase='https://artifacts.elastic.co/downloads'
	if [ "$majorVersion" -eq 2 ]; then
		debRepo="http://packages.elasticsearch.org/elasticsearch/$aptBucket/debian"
		tarballUrlBase='https://download.elastic.co/elasticsearch'
	fi

	fullVersion="$(curl -fsSL "$debRepo/dists/stable/main/binary-amd64/Packages" | awk -F ': ' '$1 == "Package" { pkg = $2 } pkg == "elasticsearch" && $1 == "Version" && $2 ~ /^([0-9]+:)?'"$rcVersion"'/ { print $2 }' | sort -rV | head -n1)"
	if [ -z "$fullVersion" ]; then
		echo >&2 "warning: cannot find full version for $version"
		continue
	fi
	# convert "1:5.0.2-1" over to "5.0.2"
	plainVersion="${fullVersion%%-*}" # strip non-upstream-version
	plainVersion="${plainVersion##*:}" # strip epoch
	tilde='~'; plainVersion="${plainVersion//$tilde/-}" # replace '~' with '-'
    
    sha1= 

    
    
    if [ $majorVersion -ge 6 ]; then
		# Use the "upstream" Dockerfile, which rebundles the existing image from Elastic.
		upstreamImage="docker.elastic.co/elasticsearch/kibana:$plainVersion"
		
		# Parse image manifest for sha
		authToken="$(curl -fsSL 'https://docker-auth.elastic.co/auth?service=token-service&scope=repository:kibana/kibana:pull' | jq -r .token)"
        digest="$(curl --head -fsSL -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' -H "Authorization: Bearer $authToken" "https://docker.elastic.co/v2/kibana/kibana/manifests/$plainVersion" | tr -d '\r' | gawk -F ':[[:space:]]+' '$1 == "Docker-Content-Digest" { print $2 }')"
        
        # Format image reference (image@sha)
        upstreamImageDigest="$upstreamImage@$digest"
        
		(
			set -x
			sed '
				s!%%ELASTICSEARCH_VERSION%%!'"$plainVersion"'!g;
				s!%%UPSTREAM_IMAGE_DIGEST%%!'"$upstreamImageDigest"'!g;
			' Dockerfile-upstream.template > "$version/Dockerfile"
		)<commit_msg>Fixed update.sh<commit_after>#!/bin/bash
set -eo pipefail

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

versions=( "$@" )
if [ ${#versions[@]} -eq 0 ]; then
	versions=( */ )
fi
versions=( "${versions[@]%/}" )

tags="$(git ls-remote --tags https://github.com/elastic/kibana.git | cut -d/ -f3 | cut -d^ -f1 | cut -dv -f2 | sort -rV)"
debArch="$(dpkg --print-architecture)"

travisEnv=
for version in "${versions[@]}"; do
	# major.minor.patch
	majorVersion="${version%%.*}"
	minorVersion="${version#$majorVersion.}"
	[ "$minorVersion" != "$version" ] || minorVersion=
	minorVersion="${minorVersion%%.*}"


	aptBucket="${majorVersion}.x"
	if [ "$rcVersion" != "$version" ]; then
		aptBucket+='-prerelease'
	fi
	debRepo="https://artifacts.elastic.co/packages/$aptBucket/apt"
	tarballUrlBase='https://artifacts.elastic.co/downloads'
	if [ "$majorVersion" -eq 2 ]; then
		debRepo="http://packages.kibana.org/kibana/$aptBucket/debian"
		tarballUrlBase='https://download.elastic.co/kibana'
	fi

	fullVersion="$(curl -fsSL "$debRepo/dists/stable/main/binary-amd64/Packages" | awk -F ': ' '$1 == "Package" { pkg = $2 } pkg == "kibana" && $1 == "Version" && $2 ~ /^([0-9]+:)?'"$rcVersion"'/ { print $2 }' | sort -rV | head -n1)"
	if [ -z "$fullVersion" ]; then
		echo >&2 "warning: cannot find full version for $version"
		continue
	fi
	# convert "1:5.0.2-1" over to "5.0.2"
	plainVersion="${fullVersion%%-*}" # strip non-upstream-version
	plainVersion="${plainVersion##*:}" # strip epoch
	tilde='~'; plainVersion="${plainVersion//$tilde/-}" # replace '~' with '-'
    
    sha1= 



    if [ $majorVersion -ge 6 ]; then
		# Use the "upstream" Dockerfile, which rebundles the existing image from Elastic.
		upstreamImage="docker.elastic.co/kibana/kibana:$plainVersion"
		
		# Parse image manifest for sha
		authToken="$(curl -fsSL 'https://docker-auth.elastic.co/auth?service=token-service&scope=repository:kibana/kibana:pull' | jq -r .token)"
        digest="$(curl --head -fsSL -H 'Accept: application/vnd.docker.distribution.manifest.v2+json' -H "Authorization: Bearer $authToken" "https://docker.elastic.co/v2/kibana/kibana/manifests/$plainVersion" | tr -d '\r' | gawk -F ':[[:space:]]+' '$1 == "Docker-Content-Digest" { print $2 }')"
        
        # Format image reference (image@sha)
        upstreamImageDigest="$upstreamImage@$digest"
        
		(
			set -x
			sed '
				s!%%KIBANA_VERSION%%!'"$plainVersion"'!g;
				s!%%UPSTREAM_IMAGE_DIGEST%%!'"$upstreamImageDigest"'!g;
			' Dockerfile-upstream.template > "$version/Dockerfile"
		)
{'fraction_non_alphanumeric': 0.20558375634517767, 'fraction_numerical': 0.011714174150722375, 'mean_word_length': 4.087388282025819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1612314', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1804, 'n_words': 361}