1# 2# Copyright OpenEmbedded Contributors 3# 4# SPDX-License-Identifier: GPL-2.0-only 5# 6 7from oe.manifest import Manifest 8import re 9 10class PkgManifest(Manifest): 11 """ 12 Returns a dictionary object with mip and mlp packages. 13 """ 14 def _split_multilib(self, pkg_list): 15 pkgs = dict() 16 17 for pkg in pkg_list.split(): 18 pkg_type = self.PKG_TYPE_MUST_INSTALL 19 20 ml_variants = self.d.getVar('MULTILIB_VARIANTS').split() 21 22 for ml_variant in ml_variants: 23 if pkg.startswith(ml_variant + '-'): 24 pkg_type = self.PKG_TYPE_MULTILIB 25 26 if not pkg_type in pkgs: 27 pkgs[pkg_type] = pkg 28 else: 29 pkgs[pkg_type] += " " + pkg 30 31 return pkgs 32 33 def create_initial(self): 34 pkgs = dict() 35 36 with open(self.initial_manifest, "w+") as manifest: 37 manifest.write(self.initial_manifest_file_header) 38 39 for var in self.var_maps[self.manifest_type]: 40 if var in self.vars_to_split: 41 split_pkgs = self._split_multilib(self.d.getVar(var)) 42 if split_pkgs is not None: 43 pkgs = dict(list(pkgs.items()) + list(split_pkgs.items())) 44 else: 45 pkg_list = self.d.getVar(var) 46 if pkg_list is not None: 47 pkgs[self.var_maps[self.manifest_type][var]] = self.d.getVar(var) 48 49 for pkg_type in sorted(pkgs): 50 for pkg in sorted(pkgs[pkg_type].split()): 51 manifest.write("%s,%s\n" % (pkg_type, pkg)) 52 53 def create_final(self): 54 pass 55 56 def create_full(self, pm): 57 if not os.path.exists(self.initial_manifest): 58 self.create_initial() 59 60 initial_manifest = self.parse_initial_manifest() 61 pkgs_to_install = list() 62 for pkg_type in initial_manifest: 63 pkgs_to_install += initial_manifest[pkg_type] 64 if len(pkgs_to_install) == 0: 65 return 66 67 output = pm.dummy_install(pkgs_to_install).decode('utf-8') 68 69 with open(self.full_manifest, 'w+') as manifest: 70 pkg_re = re.compile('^Installing ([^ ]+) [^ ].*') 71 for line in set(output.split('\n')): 72 m = pkg_re.match(line) 73 if m: 74 manifest.write(m.group(1) + '\n') 75 76 return 77