From 4688847ed0a70f31891d2cdc3b990da4c62e1058 Mon Sep 17 00:00:00 2001 From: Martin Hoehn Date: Fri, 8 Nov 2024 15:41:32 +0100 Subject: [PATCH] elbepack: use source name of pkgs with on_src_cd attribute Resolve the corresponding source name of the binary packages where the XML attribute on_src_cd="False" is set. Until now the binary name was used, which doesn't work when the source name differs to the binary name of the package. The forbidden_packages list, containing the binary package names will be resolved and the corresponding source package names are stored in the forbidden_src_packages list which is then used for the comparison inside the add_source_pkg function. Signed-off-by: Martin Hoehn --- elbepack/aptpkgutils.py | 7 ++++--- elbepack/cdroms.py | 14 ++++++++++---- elbepack/rpcaptcache.py | 4 ++-- newsfragments/+source-exclude.bugfix.rst | 1 + 4 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 newsfragments/+source-exclude.bugfix.rst diff --git a/elbepack/aptpkgutils.py b/elbepack/aptpkgutils.py index 3409128f9..8f33882db 100644 --- a/elbepack/aptpkgutils.py +++ b/elbepack/aptpkgutils.py @@ -188,7 +188,7 @@ def parse_built_using(value): yield package, version -def get_corresponding_source_packages(cache, pkg_lst=None): +def get_corresponding_source_packages(cache, pkg_lst=None, include_built_using=True): if pkg_lst is None: pkg_lst = {p.name for p in cache if p.is_installed} @@ -203,8 +203,9 @@ def get_corresponding_source_packages(cache, pkg_lst=None): src_set.add((version.source_name, version.source_version)) - for name, ver in parse_built_using(version.record.get('Built-Using')): - src_set.add((name, ver)) + if include_built_using: + for name, ver in parse_built_using(version.record.get('Built-Using')): + src_set.add((name, ver)) return list(src_set) diff --git a/elbepack/cdroms.py b/elbepack/cdroms.py index 2ac129310..c8b27c118 100644 --- a/elbepack/cdroms.py +++ b/elbepack/cdroms.py @@ -22,6 +22,7 @@ def add_source_pkg(repo, component, cache, pkg, version, forbid): if pkg in forbid: + logging.info("Ignoring source package %s", pkg) return pkg_id = f'{pkg}-{version}' try: @@ -42,12 +43,12 @@ def mk_source_cdrom(components, codename, os.makedirs('/var/cache/elbe/sources', exist_ok=True) - forbiddenPackages = [] + forbidden_packages = [] if xml is not None and xml.has('target/pkg-list'): for i in xml.node('target/pkg-list'): try: if i.tag == 'pkg' and i.et.attrib['on_src_cd'] == 'False': - forbiddenPackages.append(i.text('.').strip()) + forbidden_packages.append(i.text('.').strip()) except KeyError: pass @@ -56,6 +57,11 @@ def mk_source_cdrom(components, codename, for component in components.keys(): rfs, cache, pkg_lst = components[component] logging.info('Adding %s component', component) + + forbidden_src_packages = set() + for name, _ in cache.get_corresponding_source_packages(forbidden_packages, include_built_using=False): + forbidden_src_packages.add(name) + rfs.mkdir_p('/var/cache/elbe/sources') repo = CdromSrcRepo(codename, init_codename, os.path.join(target, f'srcrepo-{component}'), @@ -64,14 +70,14 @@ def mk_source_cdrom(components, codename, for pkg, version in pkg_lst: add_source_pkg(repo, component, cache, pkg, version, - forbiddenPackages) + forbidden_src_packages) if component == 'main' and xml is not None: for p in xml.node('debootstrappkgs'): pkg = XMLPackage(p) srcpkgs = cache.get_corresponding_source_packages([pkg]) for srcpkg, srcpkg_ver in srcpkgs: - add_source_pkg(repo, component, cache, srcpkg, srcpkg_ver, forbiddenPackages) + add_source_pkg(repo, component, cache, srcpkg, srcpkg_ver, forbidden_src_packages) # elbe fetch_initvm_pkgs has downloaded all sources to # /var/cache/elbe/sources diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py index b89b4b6de..e3bde7b91 100644 --- a/elbepack/rpcaptcache.py +++ b/elbepack/rpcaptcache.py @@ -260,8 +260,8 @@ def is_installed(self, pkgname): def get_pkg(self, pkgname): return APTPackage(self.cache[pkgname]) - def get_corresponding_source_packages(self, pkg_lst=None): - return get_corresponding_source_packages(self.cache, pkg_lst) + def get_corresponding_source_packages(self, pkg_lst=None, *, include_built_using=True): + return get_corresponding_source_packages(self.cache, pkg_lst, include_built_using) def download_binary(self, pkgname, path, version=None): p = self.cache[pkgname] diff --git a/newsfragments/+source-exclude.bugfix.rst b/newsfragments/+source-exclude.bugfix.rst new file mode 100644 index 000000000..9fbf92a02 --- /dev/null +++ b/newsfragments/+source-exclude.bugfix.rst @@ -0,0 +1 @@ +Resolve corresponding source package names for exclude source CD. \ No newline at end of file