-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
upload-oscontainer: Support oscontainer.yaml and extensions.yaml
Pairs with openshift/os#455 Add an `oscontainer.yaml` which allows configuring (currently) just the `FROM` line equivalent. This helps keep things declarative in the config instead of part of the pipeline. And since extensions are now a core part of OpenShift 4 (particularly RT kernel) which also uses the oscontainer, let's lift the logic to generate those bits of the oscontainer into this repo and out of the config git. Both of these are part of the general philosophy we've had that: - config git is declarative config - coreos-assembler is the mechanism - a pipeline just scripts coreos-assembler in a way that's easy to reproduce with plain podman too
- Loading branch information
1 parent
7bf455a
commit 84d2f6a
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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,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' | ||
# 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): | ||
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) |