Skip to content

Commit

Permalink
Adjust "latest" to be automatic based on "release status"
Browse files Browse the repository at this point in the history
  • Loading branch information
tianon committed Mar 1, 2019
1 parent a6b2cc1 commit 93f1e9c
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .architectures-lib
Expand Up @@ -3,7 +3,7 @@
hasBashbrewArch() {
local version="$1"; shift
local bashbrewArch="$1"; shift
local arches="$(grep 'bashbrew-architectures:' "$version/Dockerfile" | cut -d':' -f2)"
local arches="$(grep -m1 'bashbrew-architectures:' "$version/Dockerfile" | cut -d':' -f2)"
[[ " $arches " == *" $bashbrewArch "* ]]
}

Expand Down
2 changes: 2 additions & 0 deletions 10.0/Dockerfile
Expand Up @@ -91,6 +91,8 @@ RUN set -ex; \
# bashbrew-architectures: amd64 arm64v8 i386 ppc64le
ENV MARIADB_MAJOR 10.0
ENV MARIADB_VERSION 10.0.38+maria-1~xenial
# release-status:Stable
# (https://downloads.mariadb.org/mariadb/+releases/)

RUN set -e;\
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu xenial main" > /etc/apt/sources.list.d/mariadb.list; \
Expand Down
2 changes: 2 additions & 0 deletions 10.1/Dockerfile
Expand Up @@ -91,6 +91,8 @@ RUN set -ex; \
# bashbrew-architectures: amd64 arm64v8 ppc64le
ENV MARIADB_MAJOR 10.1
ENV MARIADB_VERSION 1:10.1.38+maria-1~bionic
# release-status:Stable
# (https://downloads.mariadb.org/mariadb/+releases/)

RUN set -e;\
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu bionic main" > /etc/apt/sources.list.d/mariadb.list; \
Expand Down
2 changes: 2 additions & 0 deletions 10.2/Dockerfile
Expand Up @@ -91,6 +91,8 @@ RUN set -ex; \
# bashbrew-architectures: amd64 arm64v8 ppc64le
ENV MARIADB_MAJOR 10.2
ENV MARIADB_VERSION 1:10.2.22+maria~bionic
# release-status:Stable
# (https://downloads.mariadb.org/mariadb/+releases/)

RUN set -e;\
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu bionic main" > /etc/apt/sources.list.d/mariadb.list; \
Expand Down
2 changes: 2 additions & 0 deletions 10.3/Dockerfile
Expand Up @@ -91,6 +91,8 @@ RUN set -ex; \
# bashbrew-architectures: amd64 arm64v8 ppc64le
ENV MARIADB_MAJOR 10.3
ENV MARIADB_VERSION 1:10.3.13+maria~bionic
# release-status:Stable
# (https://downloads.mariadb.org/mariadb/+releases/)

RUN set -e;\
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu bionic main" > /etc/apt/sources.list.d/mariadb.list; \
Expand Down
2 changes: 2 additions & 0 deletions 10.4/Dockerfile
Expand Up @@ -91,6 +91,8 @@ RUN set -ex; \
# bashbrew-architectures: amd64 arm64v8 ppc64le
ENV MARIADB_MAJOR 10.4
ENV MARIADB_VERSION 1:10.4.3+maria~bionic
# release-status:RC
# (https://downloads.mariadb.org/mariadb/+releases/)

RUN set -e;\
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu bionic main" > /etc/apt/sources.list.d/mariadb.list; \
Expand Down
2 changes: 2 additions & 0 deletions 5.5/Dockerfile
Expand Up @@ -91,6 +91,8 @@ RUN set -ex; \
# bashbrew-architectures: amd64 i386 ppc64le
ENV MARIADB_MAJOR 5.5
ENV MARIADB_VERSION 5.5.63+maria-1~trusty
# release-status:Stable
# (https://downloads.mariadb.org/mariadb/+releases/)

RUN set -e;\
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu trusty main" > /etc/apt/sources.list.d/mariadb.list; \
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile.template
Expand Up @@ -91,6 +91,8 @@ RUN set -ex; \
# bashbrew-architectures:%%ARCHES%%
ENV MARIADB_MAJOR %%MARIADB_MAJOR%%
ENV MARIADB_VERSION %%MARIADB_VERSION%%
# release-status:%%MARIADB_RELEASE_STATUS%%
# (https://downloads.mariadb.org/mariadb/+releases/)

RUN set -e;\
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/$MARIADB_MAJOR/ubuntu %%SUITE%% main" > /etc/apt/sources.list.d/mariadb.list; \
Expand Down
18 changes: 15 additions & 3 deletions generate-stackbrew-library.sh
Expand Up @@ -2,11 +2,13 @@
set -eu

declare -A aliases=(
# https://github.com/docker-library/mariadb/pull/83 ("alpha", "beta", "rc" tag discussion)
[10.3]='10 latest'
[5.5]='5'
#[10.3]='10 latest'
#[5.5]='5'
)

# "latest", "10", "5", etc aliases are auto-detected in the loop below
declare -A latest=()

self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

Expand Down Expand Up @@ -66,6 +68,16 @@ for version in "${versions[@]}"; do
fi
versionAliases+=( ${aliases[$version]:-} )

releaseStatus="$(grep -m1 'release-status:' "$version/Dockerfile" | cut -d':' -f2)"
if [ "$releaseStatus" = 'Stable' ]; then
for tryAlias in "${version%%.*}" latest; do
if [ -z "${latest[$tryAlias]:-}" ]; then
latest[$tryAlias]="$version"
versionAliases+=( "$tryAlias" )
fi
done
fi

from="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "FROM" { print $2; exit }')"
distro="${from%%:*}" # "debian", "ubuntu"
suite="${from#$distro:}" # "jessie-slim", "xenial"
Expand Down
41 changes: 29 additions & 12 deletions update.sh
Expand Up @@ -50,6 +50,25 @@ for version in "${versions[@]}"; do
continue
fi

mariaVersion="${fullVersion##*:}"
mariaVersion="${mariaVersion%%[-+~]*}"

# "Alpha", "Beta", "Gamma", "RC", "Stable", etc.
releaseStatus="$(
wget -qO- 'https://downloads.mariadb.org/mariadb/+releases/' \
| xargs -d '\n' \
| grep -oP '<tr>.+?</tr>' \
| grep -P '>\Q'"$mariaVersion"'\E<' \
| grep -oP '<td>[^0-9][^<]*</td>' \
| sed -r 's!^.*<td>([^0-9][^<]*)</td>.*$!\1!'
)"
case "$releaseStatus" in
Alpha | Beta | Gamma | RC | Stable ) ;; # sanity check
*) echo >&2 "error: unexpected 'release status' value for $mariaVersion: $releaseStatus"; exit 1 ;;
esac

echo "$version: $mariaVersion ($releaseStatus)"

arches=
sortedArches="$(echo "${!dpkgArchToBashbrew[@]}" | xargs -n1 | sort | xargs)"
for arch in $sortedArches; do
Expand All @@ -71,18 +90,16 @@ for version in "${versions[@]}"; do
backup="$backup-$version"
fi

(
set -x
cp docker-entrypoint.sh "$version/"
sed -i \
-e 's!%%MARIADB_VERSION%%!'"$fullVersion"'!g' \
-e 's!%%MARIADB_MAJOR%%!'"$version"'!g' \
-e 's!%%SUITE%%!'"$suite"'!g' \
-e 's!%%BACKUP_PACKAGE%%!'"$backup"'!g' \
-e 's!%%ARCHES%%!'"$arches"'!g' \
"$version/Dockerfile"
)

cp docker-entrypoint.sh "$version/"
sed -i \
-e 's!%%MARIADB_VERSION%%!'"$fullVersion"'!g' \
-e 's!%%MARIADB_MAJOR%%!'"$version"'!g' \
-e 's!%%MARIADB_RELEASE_STATUS%%!'"$releaseStatus"'!g' \
-e 's!%%SUITE%%!'"$suite"'!g' \
-e 's!%%BACKUP_PACKAGE%%!'"$backup"'!g' \
-e 's!%%ARCHES%%!'"$arches"'!g' \
"$version/Dockerfile"

travisEnv='\n - VERSION='"$version$travisEnv"
done

Expand Down

0 comments on commit 93f1e9c

Please sign in to comment.