[elbe-devel] [PATCH 3/4] cdroms: Use SrcManager to download packages
Olivier Dion
dion at linutronix.de
Mon Mar 23 19:53:55 CET 2020
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/cdroms.py | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
diff --git a/elbepack/cdroms.py b/elbepack/cdroms.py
index 827ddf88..75f15e00 100644
--- a/elbepack/cdroms.py
+++ b/elbepack/cdroms.py
@@ -49,7 +49,7 @@ class SrcManager(object):
self.pkgs[name] = {version: [component]}
def mk_source_cdrom(rfs, arch, codename, init_codename, target,
- cdrom_size=CDROM_SIZE, xml=None):
+ cdrom_size=CDROM_SIZE, xml=None, others={}):
# pylint: disable=too-many-arguments
# pylint: disable=too-many-locals
@@ -70,30 +70,38 @@ def mk_source_cdrom(rfs, arch, codename, init_codename, target,
cache = get_rpcaptcache(rfs, arch)
cache.update()
- pkglist = cache.get_installed_pkgs()
- forbiddenPackages = []
+ man = SrcManager()
+
+ purge_main = set()
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())
-
+ purge_main.add(i.text('.').strip())
except KeyError:
pass
- for pkg in pkglist:
- # Do not include forbidden packages in src cdrom
- if pkg.name in forbiddenPackages:
- continue
- pkg_id = "%s-%s" % (pkg.name, pkg.installed_version)
+ # Do main component
+ for pkg in cache.get_installed_pkgs():
+ if pkg.name not in purge_main:
+ man.add_pkg(pkg.name, pkg.installed_version, "main")
+
+ # Do other components
+ for component in others:
+ for name, version in others[component]:
+ man.add_pkg(name, version, component)
+
+ for pkg, version, component in man:
+ logging.info('Downloading "%s-%s" for %s', pkg, version, component)
try:
- dsc = cache.download_source(pkg.name, '/var/cache/elbe/sources')
- repo.includedsc(dsc, force=True)
- except ValueError:
- logging.error("No sources for package '%s'", pkg_id)
- except FetchError:
- logging.error("Source for package '%s' could not be downloaded", pkg_id)
+ dsc = cache.download_source(pkg,
+ '/var/cache/elbe/sources',
+ version=version)
+ except Exception as E:
+ logging.exception(E)
+ else:
+ repo.includedsc(dsc, component=component, force=True)
# elbe fetch_initvm_pkgs has downloaded all sources to
# /var/cache/elbe/sources
--
2.25.1
More information about the elbe-devel
mailing list