Add arch support! (some of amd64, arm64v8, i386, ppc64le)

This commit is contained in:
Joe Ferguson 2018-07-16 16:49:00 -07:00
parent 92a813379a
commit 852044c20c
15 changed files with 179 additions and 70 deletions

49
.architectures-lib Normal file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env bash
_awkArch() {
local version="$1"; shift
local awkExpr="$1"; shift
awk "$@" "/^#|^\$/ { next } $awkExpr" "$version/release-architectures"
}
hasBashbrewArch() {
local version="$1"; shift
local bashbrewArch="$1"; shift
_awkArch "$version" 'BEGIN { exitCode = 1 } $1 == bashbrewArch { exitCode = 0 } END { exit exitCode }' -v bashbrewArch="$bashbrewArch"
}
_generateParentRepoToArches() {
local repo="$1"; shift
local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/'
eval "declare -g -A parentRepoToArches=( $(
find -name 'Dockerfile' -exec awk '
toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ {
print "'"$officialImagesUrl"'" $2
}
' '{}' + \
| sort -u \
| xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"'
) )"
}
_generateParentRepoToArches 'mariadb'
parentArches() {
local version="$1"; shift # "1.8", etc
local parent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/Dockerfile")"
echo "${parentRepoToArches[$parent]:-}"
}
versionArches() {
local version="$1"; shift # "1.8", etc
local parentArches="$(parentArches "$version")"
local variantArches=()
for arch in $parentArches; do
if hasBashbrewArch "$version" "$arch"; then
variantArches+=( "$arch" )
fi
done
echo "${variantArches[*]}"
}

View File

@ -86,15 +86,6 @@ RUN set -ex; \
rm -r "$GNUPGHOME"; \
apt-key list
# add Percona's repo for xtrabackup (which is useful for Galera)
RUN set -e; \
echo "deb https://repo.percona.com/apt xenial main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona
ENV MARIADB_MAJOR 10.0
ENV MARIADB_VERSION 10.0.35+maria-1~xenial
@ -115,11 +106,29 @@ RUN set -ex; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password password 'unused'; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password_again password 'unused'; \
} | debconf-set-selections; \
XTRABACKUP='percona-xtrabackup'; \
##<autogenerated> from Dockerfile-percona-block ##
# add Percona's repo for xtrabackup (which is useful for Galera)
echo "deb [arch=amd64,i386] https://repo.percona.com/apt xenial main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona; \
# percona-xtrabackup is amd64/i386 only (mariadb-backup is on all arches that mariadb-server is)
dpkgArch="$(dpkg --print-architecture)"; \
if [[ "$XTRABACKUP" == percona* ]]; then \
case "${dpkgArch##*-}" in \
amd64|i396) ;; \
*) XTRABACKUP= ;; \
esac; \
fi; \
##</autogenerated>##
apt-get update; \
apt-get install -y \
"mariadb-server=$MARIADB_VERSION" \
# percona-xtrabackup/mariadb-backup is installed at the same time so that `mysql-common` is only installed once from just mariadb repos
percona-xtrabackup \
$XTRABACKUP \
socat \
; \
rm -rf /var/lib/apt/lists/*; \

View File

@ -0,0 +1,5 @@
# bashbrew-arches
ppc64le
i386
amd64
arm64v8

View File

@ -86,15 +86,6 @@ RUN set -ex; \
rm -r "$GNUPGHOME"; \
apt-key list
# add Percona's repo for xtrabackup (which is useful for Galera)
RUN set -e; \
echo "deb https://repo.percona.com/apt bionic main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona
ENV MARIADB_MAJOR 10.1
ENV MARIADB_VERSION 1:10.1.34+maria-1~bionic
@ -115,11 +106,12 @@ RUN set -ex; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password password 'unused'; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password_again password 'unused'; \
} | debconf-set-selections; \
XTRABACKUP='mariadb-backup-10.1'; \
apt-get update; \
apt-get install -y \
"mariadb-server=$MARIADB_VERSION" \
# percona-xtrabackup/mariadb-backup is installed at the same time so that `mysql-common` is only installed once from just mariadb repos
mariadb-backup-10.1 \
$XTRABACKUP \
socat \
; \
rm -rf /var/lib/apt/lists/*; \

View File

@ -0,0 +1,4 @@
# bashbrew-arches
ppc64le
amd64
arm64v8

View File

@ -86,15 +86,6 @@ RUN set -ex; \
rm -r "$GNUPGHOME"; \
apt-key list
# add Percona's repo for xtrabackup (which is useful for Galera)
RUN set -e; \
echo "deb https://repo.percona.com/apt bionic main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona
ENV MARIADB_MAJOR 10.2
ENV MARIADB_VERSION 1:10.2.16+maria~bionic
@ -115,11 +106,12 @@ RUN set -ex; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password password 'unused'; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password_again password 'unused'; \
} | debconf-set-selections; \
XTRABACKUP='mariadb-backup-10.2'; \
apt-get update; \
apt-get install -y \
"mariadb-server=$MARIADB_VERSION" \
# percona-xtrabackup/mariadb-backup is installed at the same time so that `mysql-common` is only installed once from just mariadb repos
mariadb-backup-10.2 \
$XTRABACKUP \
socat \
; \
rm -rf /var/lib/apt/lists/*; \

View File

@ -0,0 +1,5 @@
# bashbrew-arches
ppc64le
i386
amd64
arm64v8

View File

@ -86,15 +86,6 @@ RUN set -ex; \
rm -r "$GNUPGHOME"; \
apt-key list
# add Percona's repo for xtrabackup (which is useful for Galera)
RUN set -e; \
echo "deb https://repo.percona.com/apt bionic main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona
ENV MARIADB_MAJOR 10.3
ENV MARIADB_VERSION 1:10.3.8+maria~bionic
@ -115,11 +106,12 @@ RUN set -ex; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password password 'unused'; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password_again password 'unused'; \
} | debconf-set-selections; \
XTRABACKUP='mariadb-backup'; \
apt-get update; \
apt-get install -y \
"mariadb-server=$MARIADB_VERSION" \
# percona-xtrabackup/mariadb-backup is installed at the same time so that `mysql-common` is only installed once from just mariadb repos
mariadb-backup \
$XTRABACKUP \
socat \
; \
rm -rf /var/lib/apt/lists/*; \

View File

@ -0,0 +1,4 @@
# bashbrew-arches
ppc64le
amd64
arm64v8

View File

@ -86,15 +86,6 @@ RUN set -ex; \
rm -r "$GNUPGHOME"; \
apt-key list
# add Percona's repo for xtrabackup (which is useful for Galera)
RUN set -e; \
echo "deb https://repo.percona.com/apt trusty main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona
ENV MARIADB_MAJOR 5.5
ENV MARIADB_VERSION 5.5.60+maria-1~trusty
@ -115,11 +106,29 @@ RUN set -ex; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password password 'unused'; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password_again password 'unused'; \
} | debconf-set-selections; \
XTRABACKUP='percona-xtrabackup'; \
##<autogenerated> from Dockerfile-percona-block ##
# add Percona's repo for xtrabackup (which is useful for Galera)
echo "deb [arch=amd64,i386] https://repo.percona.com/apt trusty main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona; \
# percona-xtrabackup is amd64/i386 only (mariadb-backup is on all arches that mariadb-server is)
dpkgArch="$(dpkg --print-architecture)"; \
if [[ "$XTRABACKUP" == percona* ]]; then \
case "${dpkgArch##*-}" in \
amd64|i396) ;; \
*) XTRABACKUP= ;; \
esac; \
fi; \
##</autogenerated>##
apt-get update; \
apt-get install -y \
"mariadb-server=$MARIADB_VERSION" \
# percona-xtrabackup/mariadb-backup is installed at the same time so that `mysql-common` is only installed once from just mariadb repos
percona-xtrabackup \
$XTRABACKUP \
socat \
; \
rm -rf /var/lib/apt/lists/*; \

View File

@ -0,0 +1,4 @@
# bashbrew-arches
ppc64le
i386
amd64

17
Dockerfile-percona-block Normal file
View File

@ -0,0 +1,17 @@
##<autogenerated> from Dockerfile-percona-block ##
# add Percona's repo for xtrabackup (which is useful for Galera)
echo "deb [arch=amd64,i386] https://repo.percona.com/apt %%SUITE%% main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona; \
# percona-xtrabackup is amd64/i386 only (mariadb-backup is on all arches that mariadb-server is)
dpkgArch="$(dpkg --print-architecture)"; \
if [[ "$XTRABACKUP" == percona* ]]; then \
case "${dpkgArch##*-}" in \
amd64|i396) ;; \
*) XTRABACKUP= ;; \
esac; \
fi; \
##</autogenerated>##

View File

@ -86,15 +86,6 @@ RUN set -ex; \
rm -r "$GNUPGHOME"; \
apt-key list
# add Percona's repo for xtrabackup (which is useful for Galera)
RUN set -e; \
echo "deb https://repo.percona.com/apt %%SUITE%% main" > /etc/apt/sources.list.d/percona.list; \
{ \
echo 'Package: *'; \
echo 'Pin: release o=Percona Development Team'; \
echo 'Pin-Priority: 998'; \
} > /etc/apt/preferences.d/percona
ENV MARIADB_MAJOR %%MARIADB_MAJOR%%
ENV MARIADB_VERSION %%MARIADB_VERSION%%
@ -115,11 +106,12 @@ RUN set -ex; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password password 'unused'; \
echo "mariadb-server-$MARIADB_MAJOR" mysql-server/root_password_again password 'unused'; \
} | debconf-set-selections; \
XTRABACKUP='%%XTRABACKUP%%'; \
apt-get update; \
apt-get install -y \
"mariadb-server=$MARIADB_VERSION" \
# percona-xtrabackup/mariadb-backup is installed at the same time so that `mysql-common` is only installed once from just mariadb repos
%%XTRABACKUP%% \
$XTRABACKUP \
socat \
; \
rm -rf /var/lib/apt/lists/*; \

View File

@ -9,6 +9,8 @@ declare -A aliases=(
self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
source '.architectures-lib'
versions=( */ )
versions=( "${versions[@]%/}" )
@ -74,6 +76,7 @@ for version in "${versions[@]}"; do
echo
cat <<-EOE
Tags: $(join ', ' "${versionAliases[@]}")
Architectures: $(join ', ' $(versionArches $version))
GitCommit: $commit
Directory: $version
EOE

View File

@ -11,6 +11,27 @@ declare -A xtrabackups=(
[5.5]='percona-xtrabackup'
[10.0]='percona-xtrabackup'
)
declare -A dpkArchToBashbrew=(
[amd64]='amd64'
[armel]='arm32v5'
[armhf]='arm32v7'
[arm64]='arm64v8'
[i386]='i386'
[ppc64el]='ppc64le'
[s390x]='s390x'
)
getRemoteVersion() {
local version="$1"; shift # 10.3
local suite="$1"; shift # bionic
local dpkgArch="$1" shift # arm64
echo "$(
curl -fsSL "http://ftp.osuosl.org/pub/mariadb/repo/$version/ubuntu/dists/$suite/main/binary-$dpkgArch/Packages" 2>/dev/null \
| tac|tac \
| awk -F ': ' '$1 == "Package" { pkg = $2; next } $1 == "Version" && pkg == "mariadb-server" { print $2; exit }'
)"
}
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
@ -23,31 +44,42 @@ versions=( "${versions[@]%/}" )
travisEnv=
for version in "${versions[@]}"; do
suite="${suites[$version]:-$defaultSuite}"
fullVersion="$(
curl -fsSL "http://ftp.osuosl.org/pub/mariadb/repo/$version/ubuntu/dists/$suite/main/binary-amd64/Packages" \
| tac|tac \
| awk -F ': ' '$1 == "Package" { pkg = $2; next } $1 == "Version" && pkg == "mariadb-server" { print $2; exit }'
)"
fullVersion="$(getRemoteVersion "$version" "$suite" 'amd64')"
if [ -z "$fullVersion" ]; then
echo >&2 "warning: cannot find $version in $suite"
continue
fi
echo '# bashbrew-arches' > "$version/release-architectures"
for arch in "${!dpkArchToBashbrew[@]}"; do
if ver="$(getRemoteVersion "$version" "$suite" "$arch")" && [ -n "$ver" ]; then
echo "${dpkArchToBashbrew[$arch]}" >> "$version/release-architectures"
fi
done
backup="${xtrabackups[$version]:-$defaultXtrabackup}"
# 10.1 and 10.2 have mariadb major version in the package name
if [ "$backup" == 'mariadb-backup' ] && [[ "$version" < 10.3 ]]; then
cp Dockerfile.template "$version/Dockerfile"
if [ "$backup" == 'percona-xtrabackup' ]; then
gawk -i inplace '
{ print }
/%%XTRABACKUP%%/ && c == 0 { c = 1; system("cat Dockerfile-percona-block") }
' "$version/Dockerfile"
elif [ "$backup" == 'mariadb-backup' ] && [[ "$version" < 10.3 ]]; then
# 10.1 and 10.2 have mariadb major version in the package name
backup="$backup-$version"
fi
(
set -x
cp docker-entrypoint.sh "$version/"
sed \
sed -i \
-e 's!%%MARIADB_VERSION%%!'"$fullVersion"'!g' \
-e 's!%%MARIADB_MAJOR%%!'"$version"'!g' \
-e 's!%%SUITE%%!'"$suite"'!g' \
-e 's!%%XTRABACKUP%%!'"$backup"'!g' \
Dockerfile.template \
> "$version/Dockerfile"
"$version/Dockerfile"
)
travisEnv='\n - VERSION='"$version$travisEnv"