Skip to content

[Ubuntu] Add select_by_arch helper and use it in build scripts#14190

Open
enescakir wants to merge 1 commit into
actions:mainfrom
ubicloud:add-select_by_arch-helper
Open

[Ubuntu] Add select_by_arch helper and use it in build scripts#14190
enescakir wants to merge 1 commit into
actions:mainfrom
ubicloud:add-select_by_arch-helper

Conversation

@enescakir

Copy link
Copy Markdown
Contributor

Add a select_by_arch helper to images/ubuntu/scripts/helpers/os.sh that returns the caller-provided value for the current architecture, removing the duplicated x64/arm64 if/else blocks scattered across the build scripts.

This is similar to the macOS get_arch helper in
images/macos/scripts/helpers/utils.sh, but instead of returning a fixed arch string it lets the caller pass the value to return for each architecture, so the same helper covers the many different per-arch values (suffixes, URLs, asset names) the scripts need.

Description

Improvement

Related issue:

Check list

  • Related issue / work item is attached
  • Tests are written (if applicable)
  • Documentation is updated (if applicable)
  • Changes are tested and related VM images are successfully generated

Add a select_by_arch helper to images/ubuntu/scripts/helpers/os.sh that
returns the caller-provided value for the current architecture, removing
the duplicated x64/arm64 if/else blocks scattered across the build
scripts.

This is similar to the macOS get_arch helper in
images/macos/scripts/helpers/utils.sh, but instead of returning a fixed
arch string it lets the caller pass the value to return for each
architecture, so the same helper covers the many different per-arch
values (suffixes, URLs, asset names) the scripts need.
Copilot AI review requested due to automatic review settings June 8, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR centralizes Ubuntu image architecture selection logic by introducing a shared helper and replacing repeated per-script is_x64/is_arm64 branching.

Changes:

  • Added select_by_arch helper to os.sh for choosing architecture-specific values.
  • Replaced duplicated if is_x64 ... elif is_arm64 ... blocks across multiple install/config scripts with select_by_arch(...) calls.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
images/ubuntu/scripts/helpers/os.sh Adds shared select_by_arch helper used by build scripts.
images/ubuntu/scripts/build/install-yq.sh Uses select_by_arch to select yq arch string.
images/ubuntu/scripts/build/install-terraform.sh Uses select_by_arch to select Terraform arch string.
images/ubuntu/scripts/build/install-swift.sh Uses select_by_arch for Swift release name and download URL selection.
images/ubuntu/scripts/build/install-pulumi.sh Uses select_by_arch to select Pulumi arch string.
images/ubuntu/scripts/build/install-powershell.sh Uses select_by_arch to select PowerShell arch string.
images/ubuntu/scripts/build/install-packer.sh Uses select_by_arch to select Packer arch string.
images/ubuntu/scripts/build/install-oc-cli.sh Uses select_by_arch to select oc client download URL.
images/ubuntu/scripts/build/install-ninja.sh Uses select_by_arch to select Ninja asset name.
images/ubuntu/scripts/build/install-kubernetes-tools.sh Uses select_by_arch to select tools arch string.
images/ubuntu/scripts/build/install-java-tools.sh Uses select_by_arch to select Java arch string.
images/ubuntu/scripts/build/install-github-cli.sh Uses select_by_arch to select GitHub CLI arch string.
images/ubuntu/scripts/build/install-firefox.sh Uses select_by_arch to select Firefox driver arch string.
images/ubuntu/scripts/build/install-docker.sh Uses select_by_arch to select Docker repo arch string.
images/ubuntu/scripts/build/install-cmake.sh Uses select_by_arch to select CMake arch string.
images/ubuntu/scripts/build/install-azcopy.sh Uses select_by_arch to select AzCopy download URL.
images/ubuntu/scripts/build/install-aws-tools.sh Uses select_by_arch for multiple AWS-related architecture suffixes.
images/ubuntu/scripts/build/configure-image-data.sh Uses select_by_arch to select image labels and URLs based on arch.

Comment on lines +51 to +60
select_by_arch() {
if is_x64; then
echo "$1"
elif is_arm64; then
echo "$2"
else
echo "Unsupported architecture"
exit 1
fi
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

هل توجد على windows

echo "Unsupported architecture"
exit 1
fi
yq_arch=$(select_by_arch "amd64" "arm64")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants