Generate 'Architectures' information (#472)

Enhance the `generate-stackbrew-library.sh` to generate `Architectures`
information.

Signed-off-by: Yihong Wang <yh.wang@ibm.com>
This commit is contained in:
Yihong Wang 2017-07-23 00:24:35 -07:00 committed by Simen Bekkhus
parent f547c4c728
commit bc4e7eecfe
4 changed files with 39 additions and 8 deletions

View File

@ -1,3 +1,3 @@
bashbrew-arch variants
x64 alpine,onbuild,slim,wheezy
ppc64le onbuild,slim
amd64 default,alpine,onbuild,slim,wheezy
ppc64le default,onbuild,slim

View File

@ -11,7 +11,7 @@ function get_arch() {
local arch
case $(uname -m) in
x86_64)
arch="x64"
arch="amd64"
;;
ppc64le)
arch="ppc64le"
@ -40,3 +40,27 @@ function get_variants() {
variants=$(grep "$arch" architectures | sed -E 's/'"$arch"'\s*//' | sed -E 's/,/ /g')
echo "$variants"
}
# Get supported architectures for a specific version and variant
#
# Get default supported architectures from 'architectures'. Then go to the version folder
# to see if there is a local architectures file. The local architectures will override the
# default architectures. This will give us some benefits:
# - a specific version may or may not support some architectures
# - if there is no specialization for a version, just don't provide local architectures
function get_supported_arches () {
local version
local variant
local arches
version="$1"; shift
variant="$1"; shift
# Get default supported arches
arches=$( grep "$variant" architectures 2>/dev/null | cut -d' ' -f1 )
# Get version specific supported architectures if there is specialized information
if [ -a "$version"/architectures ]; then
arches=$( grep "$variant" "$version"/architectures 2>/dev/null | cut -d' ' -f1 )
fi
echo "$arches"
}

View File

@ -52,14 +52,17 @@ for version in "${versions[@]}"; do
fullVersion="$(grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3)"
versionAliases=( $fullVersion $version ${stub} )
# Get supported architectures for a specific version. See details in function.sh
supportedArches=( $(get_supported_arches "$version" "default") )
echo "Tags: $(join ', ' "${versionAliases[@]}")"
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
echo "GitCommit: ${commit}"
echo "Directory: ${version}"
echo
# Get supported variants according to the target architecture.
# See details in function.sh
# Get supported variants according to the target architecture.
# See details in function.sh
variants=$(get_variants | tr ' ' '\n')
for variant in $variants; do
# Skip non-docker directories
@ -70,8 +73,12 @@ for version in "${versions[@]}"; do
slash='/'
variantAliases=( "${versionAliases[@]/%/-${variant//$slash/-}}" )
variantAliases=( "${variantAliases[@]//latest-/}" )
# Get supported architectures for a specific version and variant.
# See details in function.sh
supportedArches=( $(get_supported_arches "$version" "$variant") )
echo "Tags: $(join ', ' "${variantAliases[@]}")"
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
echo "GitCommit: ${commit}"
echo "Directory: ${version}/${variant}"
echo

View File

@ -35,7 +35,7 @@ function update_node_version {
(
cp "$template" "$dockerfile"
local fromprefix=
if [[ "$arch" != "x64" && "$variant" != "onbuild" ]]; then
if [[ "$arch" != "amd64" && "$variant" != "onbuild" ]]; then
fromprefix="$arch\/"
fi
@ -55,8 +55,8 @@ for version in "${versions[@]}"; do
update_node_version "Dockerfile.template" "$version/Dockerfile"
# Get supported variants according the target architecture
# See details in function.sh
# Get supported variants according the target architecture
# See details in function.sh
variants=$(get_variants)
for variant in $variants; do