Skip to content

Generate 'Architectures' information #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions architectures
Original file line number Diff line number Diff line change
@@ -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
26 changes: 25 additions & 1 deletion functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function get_arch() {
local arch
case $(uname -m) in
x86_64)
arch="x64"
arch="amd64"
;;
ppc64le)
arch="ppc64le"
Expand Down Expand Up @@ -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"
}
11 changes: 9 additions & 2 deletions generate-stackbrew-library.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down