From f51f3a9522b46eb4267dab2e75063dac8c03ddf1 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 8 Dec 2015 16:46:18 -0800 Subject: [PATCH] Modify update.sh to use the JSON version of the releases endpoint for more flexibility (including extracting the exact sha256 of the release file) --- update.sh | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/update.sh b/update.sh index edfabd1d..332be002 100755 --- a/update.sh +++ b/update.sh @@ -17,18 +17,36 @@ if [ ${#versions[@]} -eq 0 ]; then fi versions=( "${versions[@]%/}" ) +jsonSh="$(curl -fsSL 'https://raw.githubusercontent.com/dominictarr/JSON.sh/ed3f9dd285ebd4183934adb54ea5a2fda6b25a98/JSON.sh')" + for version in "${versions[@]}"; do - fullVersion='' - for comp in xz bz2; do + packagesJson="$(curl -fsSL "https://secure.php.net/releases/index.php?json&max=100&version=${version%%.*}" | bash -- <(echo "$jsonSh") -l)" + fullVersion= + filename= + sha256= + for comp in xz bz2 gz; do fullVersion="$( - curl -fsSL "https://secure.php.net/releases/index.php?serialize&max=100&version=${version%%.*}" \ - | sed 's/;/;\n/g' \ - | grep -e 'php-'"$version"'.*\.tar\.'"$comp" \ - | sed -r 's/.*php-('"$version"'[^"]+)\.tar\.'"$comp"'.*/\1/' \ - | sort -V \ - | tail -1 + echo "$packagesJson" \ + | grep '^\["'"$version"'[."].*,"filename"\].*\.'"$comp"'"' \ + | cut -d'"' -f2 \ + | head -1 )" if [ "$fullVersion" ]; then + sourceNumber="$( + echo "$packagesJson" \ + | grep '^\["'"$fullVersion"'","source",.*,"filename"\].*\.'"$comp"'"' \ + | cut -d, -f3 + )" + filename="$( + echo "$packagesJson" \ + | grep '^\["'"$fullVersion"'","source",'"$sourceNumber"',"filename"\]' \ + | cut -d$'\t' -f2 | cut -d'"' -f2 + )" + sha256="$( + echo "$packagesJson" \ + | grep '^\["'"$fullVersion"'","source",'"$sourceNumber"',"sha256"\]' \ + | cut -d$'\t' -f2 | cut -d'"' -f2 + )" break fi done @@ -68,7 +86,9 @@ for version in "${versions[@]}"; do set -x sed -ri ' s/^(ENV PHP_VERSION) .*/\1 '"$fullVersion"'/; - s/^(ENV GPG_KEYS) [0-9a-fA-F ]*$/\1 '"$gpgKey"'/ + s/^(ENV PHP_FILENAME) .*/\1 '"$filename"'/; + s/^(ENV PHP_SHA256) .*/\1 '"$sha256"'/; + s/^(ENV GPG_KEYS) [0-9a-fA-F ]*$/\1 '"$gpgKey"'/; ' "$version/Dockerfile" "$version/"*/Dockerfile ) done