Skip to content

Commit bc4e7ee

Browse files
yhwangSimenB
authored andcommitted
Generate 'Architectures' information (#472)
Enhance the `generate-stackbrew-library.sh` to generate `Architectures` information. Signed-off-by: Yihong Wang <[email protected]>
1 parent f547c4c commit bc4e7ee

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

architectures

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
bashbrew-arch variants
2-
x64 alpine,onbuild,slim,wheezy
3-
ppc64le onbuild,slim
2+
amd64 default,alpine,onbuild,slim,wheezy
3+
ppc64le default,onbuild,slim

functions.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function get_arch() {
1111
local arch
1212
case $(uname -m) in
1313
x86_64)
14-
arch="x64"
14+
arch="amd64"
1515
;;
1616
ppc64le)
1717
arch="ppc64le"
@@ -40,3 +40,27 @@ function get_variants() {
4040
variants=$(grep "$arch" architectures | sed -E 's/'"$arch"'\s*//' | sed -E 's/,/ /g')
4141
echo "$variants"
4242
}
43+
44+
# Get supported architectures for a specific version and variant
45+
#
46+
# Get default supported architectures from 'architectures'. Then go to the version folder
47+
# to see if there is a local architectures file. The local architectures will override the
48+
# default architectures. This will give us some benefits:
49+
# - a specific version may or may not support some architectures
50+
# - if there is no specialization for a version, just don't provide local architectures
51+
function get_supported_arches () {
52+
local version
53+
local variant
54+
local arches
55+
version="$1"; shift
56+
variant="$1"; shift
57+
58+
# Get default supported arches
59+
arches=$( grep "$variant" architectures 2>/dev/null | cut -d' ' -f1 )
60+
61+
# Get version specific supported architectures if there is specialized information
62+
if [ -a "$version"/architectures ]; then
63+
arches=$( grep "$variant" "$version"/architectures 2>/dev/null | cut -d' ' -f1 )
64+
fi
65+
echo "$arches"
66+
}

generate-stackbrew-library.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,17 @@ for version in "${versions[@]}"; do
5252
fullVersion="$(grep -m1 'ENV NODE_VERSION ' "$version/Dockerfile" | cut -d' ' -f3)"
5353

5454
versionAliases=( $fullVersion $version ${stub} )
55+
# Get supported architectures for a specific version. See details in function.sh
56+
supportedArches=( $(get_supported_arches "$version" "default") )
5557

5658
echo "Tags: $(join ', ' "${versionAliases[@]}")"
59+
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
5760
echo "GitCommit: ${commit}"
5861
echo "Directory: ${version}"
5962
echo
6063

61-
# Get supported variants according to the target architecture.
62-
# See details in function.sh
64+
# Get supported variants according to the target architecture.
65+
# See details in function.sh
6366
variants=$(get_variants | tr ' ' '\n')
6467
for variant in $variants; do
6568
# Skip non-docker directories
@@ -70,8 +73,12 @@ for version in "${versions[@]}"; do
7073
slash='/'
7174
variantAliases=( "${versionAliases[@]/%/-${variant//$slash/-}}" )
7275
variantAliases=( "${variantAliases[@]//latest-/}" )
76+
# Get supported architectures for a specific version and variant.
77+
# See details in function.sh
78+
supportedArches=( $(get_supported_arches "$version" "$variant") )
7379

7480
echo "Tags: $(join ', ' "${variantAliases[@]}")"
81+
echo "Architectures: $(join ', ' "${supportedArches[@]}")"
7582
echo "GitCommit: ${commit}"
7683
echo "Directory: ${version}/${variant}"
7784
echo

update.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function update_node_version {
3535
(
3636
cp "$template" "$dockerfile"
3737
local fromprefix=
38-
if [[ "$arch" != "x64" && "$variant" != "onbuild" ]]; then
38+
if [[ "$arch" != "amd64" && "$variant" != "onbuild" ]]; then
3939
fromprefix="$arch\/"
4040
fi
4141

@@ -55,8 +55,8 @@ for version in "${versions[@]}"; do
5555

5656
update_node_version "Dockerfile.template" "$version/Dockerfile"
5757

58-
# Get supported variants according the target architecture
59-
# See details in function.sh
58+
# Get supported variants according the target architecture
59+
# See details in function.sh
6060
variants=$(get_variants)
6161

6262
for variant in $variants; do

0 commit comments

Comments
 (0)