-
Notifications
You must be signed in to change notification settings - Fork 244
fix: fixing repodepot support for azlinux3 and ubuntu2404 as well as PMC on Ubuntu #7565
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
Open
djsly
wants to merge
2
commits into
main
Choose a base branch
from
djsly/36196878
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,27 @@ | ||
| #!/bin/bash | ||
| set -x | ||
| mkdir -p /root/AzureCACertificates | ||
|
|
||
| IS_MARINER=0 | ||
| IS_AZURELINUX=0 | ||
| if [[ -f /etc/os-release ]]; then | ||
| . /etc/os-release | ||
| if [[ $NAME == *"Mariner"* ]]; then | ||
| IS_MARINER=1 | ||
| elif [[ $NAME == *"Microsoft Azure Linux"* ]]; then | ||
| IS_AZURELINUX=1 | ||
| else | ||
| echo "Unknown Linux distribution" | ||
| exit 1 | ||
| fi | ||
| else | ||
| echo "Unsupported operating system" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "distribution is $distribution" | ||
| echo "Running on $NAME" | ||
|
|
||
| # http://168.63.129.16 is a constant for the host's wireserver endpoint | ||
| certs=$(curl "http://168.63.129.16/machine?comp=acmspackage&type=cacertificates&ext=json") | ||
| IFS_backup=$IFS | ||
|
|
@@ -17,15 +38,77 @@ cp /root/AzureCACertificates/*.crt /etc/pki/ca-trust/source/anchors/ | |
|
|
||
| cloud-init status --wait | ||
|
|
||
| function init_mariner_repo_depot { | ||
djsly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| local repodepot_endpoint=$1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this copied from somewhere? Can you please add the source?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which part are you asking if it's copied ? |
||
| echo "Adding [extended] repo" | ||
| cp /etc/yum.repos.d/mariner-extras.repo /etc/yum.repos.d/mariner-extended.repo | ||
| sed -i -e "s|extras|extended|" /etc/yum.repos.d/mariner-extended.repo | ||
| sed -i -e "s|Extras|Extended|" /etc/yum.repos.d/mariner-extended.repo | ||
|
|
||
| echo "Adding [nvidia] repo" | ||
| cp /etc/yum.repos.d/mariner-extras.repo /etc/yum.repos.d/mariner-nvidia.repo | ||
| sed -i -e "s|extras|nvidia|" /etc/yum.repos.d/mariner-nvidia.repo | ||
| sed -i -e "s|Extras|Nvidia|" /etc/yum.repos.d/mariner-nvidia.repo | ||
|
|
||
| echo "Adding [cloud-native] repo" | ||
| cp /etc/yum.repos.d/mariner-extras.repo /etc/yum.repos.d/mariner-cloud-native.repo | ||
| sed -i -e "s|extras|cloud-native|" /etc/yum.repos.d/mariner-cloud-native.repo | ||
| sed -i -e "s|Extras|Cloud-Native|" /etc/yum.repos.d/mariner-cloud-native.repo | ||
|
|
||
| echo "Pointing Mariner repos at RepoDepot..." | ||
| for f in /etc/yum.repos.d/*.repo | ||
| do | ||
| sed -i -e "s|https://packages.microsoft.com|${repodepot_endpoint}/mariner/packages.microsoft.com|" $f | ||
| echo "$f modified." | ||
| done | ||
| echo "Mariner repo setup complete." | ||
| } | ||
|
|
||
| function init_azurelinux_repo_depot { | ||
| local repodepot_endpoint=$1 | ||
| repos=("amd" "base" "cloud-native" "extended" "ms-non-oss" "ms-oss" "nvidia") | ||
|
|
||
| # tbd maybe we do this a bit nicer | ||
| rm -f /etc/yum.repos.d/azurelinux* | ||
|
|
||
| for repo in "${repos[@]}"; do | ||
| output_file="/etc/yum.repos.d/azurelinux-${repo}.repo" | ||
| repo_content=( | ||
| "[azurelinux-official-$repo]" | ||
| "name=Azure Linux Official $repo \$releasever \$basearch" | ||
| "baseurl=$repodepot_endpoint/azurelinux/\$releasever/prod/$repo/\$basearch" | ||
| "gpgkey=file:///etc/pki/rpm-gpg/MICROSOFT-RPM-GPG-KEY" | ||
| "gpgcheck=1" | ||
| "repo_gpgcheck=1" | ||
| "enabled=1" | ||
| "skip_if_unavailable=True" | ||
| "sslverify=1" | ||
| ) | ||
|
|
||
| rm -f "$output_file" | ||
|
|
||
| for line in "${repo_content[@]}"; do | ||
| echo "$line" >> "$output_file" | ||
| done | ||
|
|
||
| echo "File '$output_file' has been created." | ||
| done | ||
| } | ||
|
|
||
| marinerRepoDepotEndpoint="$(echo "${REPO_DEPOT_ENDPOINT}" | sed 's/\/ubuntu//')" | ||
| if [ -z "$marinerRepoDepotEndpoint" ]; then | ||
| >&2 echo "repo depot endpoint empty while running custom-cloud init script" | ||
| else | ||
| for f in /etc/yum.repos.d/*.repo | ||
| do | ||
| sed -i -e "s|https://packages.microsoft.com|${marinerRepoDepotEndpoint}/mariner/packages.microsoft.com|" "$f" | ||
| echo "## REPO - $f - MODIFIED" | ||
| done | ||
| # logic taken from https://repodepot.azure.com/scripts/cloud-init/setup_repodepot.sh | ||
| if [ "$IS_MARINER" -eq 1 ]; then | ||
| echo "Initializing Mariner repo depot settings..." | ||
| init_mariner_repo_depot ${marinerRepoDepotEndpoint} | ||
| elif [ "$IS_AZURELINUX" -eq 1 ]; then | ||
| echo "Initializing Azure Linux repo depot settings..." | ||
| init_azurelinux_repo_depot ${marinerRepoDepotEndpoint} | ||
| else | ||
| echo "No customizations for distribution: $NAME" | ||
| fi | ||
| fi | ||
|
|
||
| # Set the chrony config to use the PHC /dev/ptp0 clock | ||
|
|
@@ -58,4 +141,4 @@ EOF | |
|
|
||
| systemctl restart chronyd | ||
|
|
||
| #EOF | ||
| #EOF | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see that below you have mentioned
Can we keep the behaviour consistent, like log a error message/warning that we cannot determine the distribution and customization may not be applied. i feel
exit 1is a bit extreme