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