-
Notifications
You must be signed in to change notification settings - Fork 190
upload-oscontainer: Support oscontainer.yaml and extensions.yaml #1916
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| #!/usr/bin/env python3 | ||
| # RPMs as operating system extensions, distinct from the base ostree commit/image | ||
| # https://github.com/openshift/enhancements/blob/master/enhancements/rhcos/extensions.md | ||
|
|
||
| import os | ||
| import sys | ||
| import yaml | ||
| from cosalib import cmdlib | ||
|
|
||
| destdir = sys.argv[1] | ||
| tmpdir = 'tmp' | ||
|
miabbott marked this conversation as resolved.
|
||
| # yum wants this to be absolute | ||
| configdir = os.path.abspath('src/config') | ||
| extsrcpath = f'{configdir}/extensions.yaml' | ||
| extjson = f'{tmpdir}/extensions.json' | ||
| basearch = cmdlib.get_basearch() | ||
|
|
||
| with open(extsrcpath) as f: | ||
| extensions = yaml.safe_load(f) | ||
|
|
||
| # The "v2" format here is that there's an extensions/ directory, with subdirectories | ||
| # for each extension - except you should ignore "repodata/". | ||
| edestdir = f'{destdir}/extensions' | ||
| os.mkdir(edestdir) | ||
|
|
||
| # Stuff that's not part of the extension | ||
| dependenciesdir = f'{edestdir}/dependencies' | ||
| os.mkdir(dependenciesdir) | ||
|
|
||
|
|
||
| # Downloads packages from specified repos | ||
| def yumdownload(destdir, pkgs): | ||
| # FIXME eventually use rpm-ostree for this | ||
| # shellcheck disable=SC2068 | ||
| args = ['yum', f'--setopt=reposdir={configdir}', f'--arch={basearch}', 'download'] | ||
| args.extend(pkgs) | ||
| cmdlib.run_verbose(args, cwd=destdir) | ||
|
|
||
|
|
||
| # Reuseable function for setting up an extension | ||
| # Assumes it is running in "${destdir}/extensions" | ||
| # 1 = extension name | ||
| # 2 = package string/glob | ||
| # 3 = OPTIONAL: dependencies string/glob | ||
| def createext(extname, pkgs): | ||
|
Member
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. The previous script this is intending to replace used to link deps at the top-level for backcompat. Is it safe to drop that behaviour now?
Member
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. I'm pretty sure yes; the code which was doing (But, I didn't actually test this in a cluster yet)
Member
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. Ok tested now and works! |
||
| print(f"Creating extension {extname}") | ||
| extdir = f"{edestdir}/{extname}" | ||
| os.mkdir(extdir) | ||
| primary = pkgs[0] | ||
| yumdownload(extdir, [primary]) | ||
|
|
||
| deps = pkgs[1:] | ||
| if len(deps) > 0: | ||
| print(f"Downloading dependencies for {extname}") | ||
| yumdownload(dependenciesdir, deps) | ||
|
|
||
|
|
||
| for (name, ext) in extensions['extensions'].items(): | ||
| pkgs = ext['packages'] | ||
| extarches = ext.get('architectures') | ||
| if extarches is not None and basearch not in extarches: | ||
| print(f"Skipping extension {name} for this architecture") | ||
| continue | ||
| createext(name, pkgs) | ||
|
|
||
| # Create the yum/dnf repo | ||
| cmdlib.run_verbose(['createrepo_c', '--no-database', '.'], cwd=destdir) | ||
Uh oh!
There was an error while loading. Please reload this page.