diff --git a/src/oscontainer.py b/src/oscontainer.py index 2ea605c6f5..36478d1be1 100755 --- a/src/oscontainer.py +++ b/src/oscontainer.py @@ -26,6 +26,10 @@ # https://access.redhat.com/documentation/en-us/openshift_container_platform/4.1/html/builds/custom-builds-buildah NESTED_BUILD_ARGS = ['--storage-driver', 'vfs'] +# These packages have their versions as labels +IMPORTANT_PACKAGES = ['kernel', 'kernel-rt-core', 'systemd', 'ignition', 'ostree', + 'rpm-ostree', 'runc'] + def run_get_json(args): return json.loads(subprocess.check_output(args)) @@ -159,11 +163,16 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag, if ostree_version is not None: config += ['-l', 'version=' + ostree_version] + base_pkgs = RpmOstree.db_query_all(r, rev, None) + for pkg in base_pkgs: + name = pkg.get_name() + if name in IMPORTANT_PACKAGES: + config += ['-l', f"com.coreos.rpm.{name}={pkg.get_evr()}.{pkg.get_arch()}"] + # Generate pkglist.txt in to the oscontainer at / pkg_list_dest = os.path.join(mnt, 'pkglist.txt') - pkgs = RpmOstree.db_query_all(r, rev, None) # should already be sorted, but just re-sort to be sure - nevras = sorted([pkg.get_nevra() for pkg in pkgs]) + nevras = sorted([pkg.get_nevra() for pkg in base_pkgs]) with open(pkg_list_dest, 'w') as f: for nevra in nevras: f.write(nevra) @@ -200,6 +209,11 @@ def oscontainer_build(containers_storage, tmpdir, src, ref, image_name_and_tag, if obj.get('kind', 'os-extension') == 'os-extension']) config += ['-l', f"com.coreos.os-extensions={extensions_label}"] + for pkgname in meta['extensions']['manifest']: + if pkgname in IMPORTANT_PACKAGES: + evra = meta['extensions']['manifest'][pkgname] + config += ['-l', f"com.coreos.rpm.{pkgname}={evra}"] + if display_name is not None: config += ['-l', 'io.openshift.build.version-display-names=machine-os=' + display_name, '-l', 'io.openshift.build.versions=machine-os=' + ostree_version]