blob: 469e14c3c6b8ea33aa92b7a95a8530d490670e1f [file] [log] [blame]
Andrew Geissler635e0e42020-08-21 15:58:33 -05001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Andrew Geissler635e0e42020-08-21 15:58:33 -05004# SPDX-License-Identifier: GPL-2.0-only
5#
6
7from oe.manifest import Manifest
Andrew Geissler9aee5002022-03-30 16:27:02 +00008import re
Andrew Geissler635e0e42020-08-21 15:58:33 -05009
Andrew Geissler6ce62a22020-11-30 19:58:47 -060010class PkgManifest(Manifest):
Andrew Geissler635e0e42020-08-21 15:58:33 -050011 """
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
Andrew Geissler9aee5002022-03-30 16:27:02 +000067 output = pm.dummy_install(pkgs_to_install).decode('utf-8')
Andrew Geissler635e0e42020-08-21 15:58:33 -050068
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