diff --git a/manifest-c9s.yaml b/manifest-c9s.yaml index b5e675a6d..dd3291eac 100644 --- a/manifest-c9s.yaml +++ b/manifest-c9s.yaml @@ -1,9 +1,9 @@ -# Manifest for CentOS Stream CoreOS (SCOS) +# Manifest for CentOS Stream 9 CoreOS Base rojig: license: MIT name: scos - summary: OKD 4 + summary: CentOS Stream 9 CoreOS variables: osversion: "c9s" @@ -12,7 +12,6 @@ variables: # common to RHEL 9 & C9S variants include: - common.yaml - - packages-openshift.yaml # Starting from here, everything should be specific to SCOS @@ -20,101 +19,23 @@ include: repos: - baseos - appstream - # CentOS Extras Common repo for SIG RPM GPG keys - - extras-common - # CentOS NFV SIG repo for openvswitch - - sig-nfv - # CentOS Cloud SIG repo for cri-o, cri-tools and conmon-rs - - sig-cloud-okd - # Include RHCOS 9 repo for oc, hyperkube - - rhel-9.2-server-ose-4.16 -# We include hours/minutes to avoid version number reuse -automatic-version-prefix: "416.9." -# This ensures we're semver-compatible which OpenShift wants -automatic-version-suffix: "-" -# Keep this is sync with the version in postprocess -mutate-os-release: "4.16" +# Match the format of c9s compose IDs. This field will be driven in the pipeline +# anyway to match exactly the same compose ID we're composing with so the value +# here is purely for developer builds. +automatic-version-prefix: "9-.dev" +mutate-os-release: "9" + +# Mark the OS as of the CoreOS variant. postprocess: - | - #!/usr/bin/env bash - set -xeo pipefail - - # Tweak /usr/lib/os-release - grep -v "OSTREE_VERSION" /etc/os-release > /usr/lib/os-release.stream - OCP_RELEASE="4.16" - ( - . /etc/os-release - cat > /usr/lib/os-release <> /usr/lib/os-release < /usr/lib/system-release-cpe < /usr/lib/system-release < /usr/lib/issue </ + # /os and we want to get to .../compose + return urlunparse(url._replace(path='/'.join(components[:-3]))) + + +def get_dnf_base(basedir): + base = dnf.Base() + base.conf.reposdir = basedir + base.read_all_repos() + return base + + +def setup_repos(base, treefile): + for repo in base.repos.values(): + repo.disable() + + eprint("Enabled repos:") + for repo in treefile['repos']: + base.repos[repo].enable() + eprint(f"- {repo}") + + +def get_next_iteration(composeid): + try: + with open('builds/builds.json') as f: + builds = json.load(f) + except FileNotFoundError: + builds = {'builds': []} + + if len(builds['builds']) == 0: + eprint("n: 0 (no previous builds)") + return 0 + + last_buildid = builds['builds'][0]['id'] + last_version = parse_version(last_buildid) + if not last_version: + eprint(f"n: 0 (previous version {last_buildid} does not match scheme)") + return 0 + + last_composeid, last_iteration = last_version + + if composeid != last_composeid: + eprint(f"n: 0 (previous version {last_buildid} compose ID does not match)") + return 0 + + n = last_iteration + 1 + eprint(f"n: {n} (incremented from previous version {last_buildid})") + return n + + +def parse_version(version): + m = re.match(r'^([0-9]+-[0-9]{8}\.[0-9]+)\.([0-9]+)$', version) + if m is None: + return None + composeid, iteration = m.groups() + return tuple((composeid, int(iteration))) + + +def get_manifest_path(): + if os.path.exists('src/config.json'): + config_json = json.load(open('src/config.json')) + variant = config_json['coreos-assembler.config-variant'] + return f'src/config/manifest-{variant}.yaml' + return 'src/config/manifest.yaml' + + +def get_flattened_manifest(fn): + return yaml.safe_load( + subprocess.check_output(['rpm-ostree', 'compose', 'tree', + '--print-only', fn])) + + +def eprint(*args): + print(*args, file=sys.stderr) + + +if __name__ == "__main__": + sys.exit(main())