generated from linux-system-roles/template
-
Notifications
You must be signed in to change notification settings - Fork 2
ci: ostree wip #29
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
Draft
richm
wants to merge
1
commit into
linux-system-roles:main
Choose a base branch
from
richm:ostree
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.
Draft
ci: ostree wip #29
Changes from all commits
Commits
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 |
|---|---|---|
|
|
@@ -6,15 +6,16 @@ ostree_dir="${OSTREE_DIR:-"$(dirname "$(realpath "$0")")"}" | |
|
|
||
| if [ -z "${4:-}" ] || [ "${1:-}" = help ] || [ "${1:-}" = -h ]; then | ||
| cat <<EOF | ||
| Usage: $0 packages [runtime|testing] DISTRO-MAJOR[.MINOR] [json|yaml|raw|toml] | ||
| The script will use the packages and roles files in $ostree_dir to | ||
| construct the list of packages needed to build the ostree image. The script | ||
| will output the list of packages in the given format | ||
| Usage: $0 packages|repos runtime|testing DISTRO-MAJOR[.MINOR] json|yaml|raw|toml | ||
| The script will use the packages, repos and roles files in $ostree_dir to | ||
| construct the list of packages or repos needed to build the ostree image. The script | ||
| will output the list of packages or repos in the given format | ||
| - json is a JSON list like ["pkg1","pkg2",....,"pkgN"] | ||
| - yaml is the YAML list format | ||
| - raw is the list of packages, one per line | ||
| - raw is the list of packages, one per line, or repos in INI .repo format | ||
| - toml is a list of [[packages]] elements as in https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/composing_installing_and_managing_rhel_for_edge_images/index#creating-an-image-builder-blueprint-for-a-rhel-for-edge-image-using-the-command-line-interface_composing-a-rhel-for-edge-image-using-image-builder-command-line | ||
| The DISTRO-MAJOR.MINOR is the same format used by Ansible for distribution e.g. CentOS-8, RedHat-8.9, etc. | ||
| - toml is the repo format needed for osbuild-composer | ||
| EOF | ||
| exit 1 | ||
| fi | ||
|
|
@@ -68,7 +69,7 @@ get_packages() { | |
| local ostree_dir pkgtype pkgfile rolefile | ||
| ostree_dir="$1" | ||
| for pkgtype in "${pkgtypes[@]}"; do | ||
| for suff in "" "-$distro" "-${distro}-${major_ver}" "-${distro}-${ver}"; do | ||
| for suff in "${suffix_list[@]}"; do | ||
| pkgfile="$ostree_dir/packages-${pkgtype}${suff}.txt" | ||
| if [ -f "$pkgfile" ]; then | ||
| cat "$pkgfile" | ||
|
|
@@ -120,10 +121,81 @@ format_packages_toml() { | |
| done | ||
| } | ||
|
|
||
| get_repos() { | ||
| local ostree_dir repotype repofile rolefile | ||
| ostree_dir="$1" | ||
| for repotype in "${pkgtypes[@]}"; do | ||
| for suff in "${suffix_list[@]}"; do | ||
| repofile="$ostree_dir/repos-${repotype}${suff}.repo" | ||
| if [ -f "$repofile" ]; then | ||
| cat "$repofile" | ||
| fi | ||
| done | ||
| rolefile="$ostree_dir/roles-${repotype}.txt" | ||
| if [ -f "$rolefile" ]; then | ||
| local roles role rolepath | ||
| roles="$(cat "$rolefile")" | ||
| for role in $roles; do | ||
| rolepath="$(get_rolepath "$ostree_dir" "$role")" | ||
| if [ -z "$rolepath" ]; then | ||
| 1>&2 echo ERROR - could not find role "$role" - please use ANSIBLE_COLLECTIONS_PATH | ||
| exit 2 | ||
| fi | ||
| get_repos "$rolepath" | ||
| done | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| format_repos_json() { | ||
| python -c 'import sys; import json; import configparser | ||
| cp = configparser.ConfigParser() | ||
| cp.read_file(sys.stdin) | ||
| ret = [] | ||
| # supported is from osbuild-mpp | ||
| supported = ["baseurl", "metalink", "mirrorlist", | ||
| "enabled", "metadata_expire", "gpgcheck", "username", "password", "priority", | ||
| "sslverify", "sslcacert", "sslclientkey", "sslclientcert", | ||
| "skip_if_unavailable"] | ||
| for section in cp.sections(): | ||
| repo = {"id": section} | ||
| for option in supported: | ||
| if cp.has_option(section, option): | ||
| repo[option] = cp.get(section, option) | ||
| ret.append(repo) | ||
| repo_str = json.dumps(ret) | ||
| repo_str = repo_str.replace("$", "$$$$") | ||
| print(repo_str) | ||
| ' | ||
| } | ||
|
|
||
| format_repos_raw() { | ||
| cat | ||
| } | ||
|
|
||
| format_repos_yaml() { | ||
| python -c 'import sys; import yaml; import configparser | ||
|
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. suggestion: yaml.safe_dump may not preserve ordering of repo fields. If field order matters for downstream use, consider using OrderedDict or sorting keys before dumping. Suggested implementation: |
||
| cp = configparser.ConfigParser() | ||
| cp.read_file(sys.stdin) | ||
| ret = [] | ||
| for section in cp.sections(): | ||
| repo = {"id": section} | ||
| for option in cp.options(section): | ||
| repo[option] = cp.get(section, option) | ||
| ret.append(repo) | ||
| yaml.safe_dump(ret, sys.stdout) | ||
| ' | ||
| } | ||
|
|
||
| distro="${distro_ver%%-*}" | ||
| suffix_list=("" "-$distro") | ||
| ver="${distro_ver##*-}" | ||
| if [[ "$ver" =~ ^([0-9]*) ]]; then | ||
| major_ver="${BASH_REMATCH[1]}" | ||
| suffix_list+=("-${distro}-${major_ver}") | ||
| if [ "$ver" != "$major_ver" ]; then | ||
| suffix_list+=("-${distro}-${ver}") | ||
| fi | ||
| else | ||
| echo ERROR: cannot parse major version number from version "$ver" | ||
| exit 1 | ||
|
|
||
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| cuda-toolkit-12-9 | ||
| libnccl-2.27.5-1+cuda12.9 | ||
| libnccl-devel-2.27.5-1+cuda12.9 |
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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| [epel] | ||
| name=Extra Packages for Enterprise Linux 9 | ||
| # It is much more secure to use the metalink, but if you wish to use a local mirror | ||
| # place its address here. | ||
| baseurl=https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64 | ||
| #metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-9&arch=$basearch&infra=$infra&content=$contentdir | ||
| enabled=1 | ||
| gpgcheck=1 | ||
| countme=1 | ||
| gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9 | ||
|
|
||
| [epel-next] | ||
| name=Extra Packages for Enterprise Linux 9 - Next | ||
| # It is much more secure to use the metalink, but if you wish to use a local mirror | ||
| # place its address here. | ||
| baseurl=https://dl.fedoraproject.org/pub/epel/next/9/Everything/x86_64 | ||
| #metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-next-9&arch=$basearch&infra=$infra&content=$contentdir | ||
| enabled=1 | ||
| gpgcheck=1 | ||
| countme=1 | ||
| gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9 | ||
|
|
||
| [nvidia-cuda] | ||
| name=NVIDIA CUDA repository | ||
| gpgkey=https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64/D42D0685.pub | ||
| baseurl=https://developer.download.nvidia.com/compute/cuda/repos/rhel9/x86_64 | ||
| enabled=1 | ||
|
|
||
| [microsoft-prod] | ||
| name=Microsoft Production repository | ||
| gpgkey=https://packages.microsoft.com/keys/microsoft.asc | ||
| baseurl=https://packages.microsoft.com/rhel/9/prod/ | ||
| enabled=1 |
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.
question: Potential risk with shell variable expansion in repo_str.replace.
Review whether escaping dollar signs in repo_str is required, as it may affect legitimate values. If necessary, clarify the reasoning in the documentation.