summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurentiu Palcu <laurentiu.palcu@intel.com>2013-12-18 17:32:18 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-02-11 11:53:38 +0000
commit5d34962d1542aec0073fae48cef5f82db292db8e (patch)
treea61b216d9d746eb85f41cb745058ac218e4328ad
parent8cfe5555a2977ab503cfc843520884d45c1e9338 (diff)
downloadpoky-5d34962d1542aec0073fae48cef5f82db292db8e.tar.gz
lib/oe/manifest.py: add library for image manifest creation
This new library allows for the creation of 2 types of manifests: * initial manifest - used by the new rootfs creation routines to generate the rootfs; * final_manifest - this will contain all the packages in the image, after all installations finished; Usage: Manifest(d, manifest_dir).create_initial() Manifest(d, manifest_dir).create_final() or using the provided wrapper function: create_manifest(d, False, manifest_dir) -> creates initial manifest create_manifest(d, True, manifest_dir) -> creates final manifest If manifest_dir argument is ommited, it defaults to ${WORKDIR}. NOTE: this commit creates fixed manifests for minimal/sato/sato-sdk images, for Rpm & Opkg backends, in order to help speed up development of rootfs refactoring. Dpkg initial manifest creation is implemented. (From OE-Core rev: a9d8e5e5878d14b4804317a7f7ea6394fca5e010) Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oe/manifest.py165
1 files changed, 165 insertions, 0 deletions
diff --git a/meta/lib/oe/manifest.py b/meta/lib/oe/manifest.py
new file mode 100644
index 0000000000..5d01022c36
--- /dev/null
+++ b/meta/lib/oe/manifest.py
@@ -0,0 +1,165 @@
1from abc import ABCMeta, abstractmethod
2import os
3import re
4
5
6class Manifest(object):
7 """
8 This is an abstract class. Do not instantiate this directly.
9 """
10 __metaclass__ = ABCMeta
11
12 initial_manifest_file_header = \
13 "# This file was generated automatically and contains the packages\n" \
14 "# passed on to the package manager in order to create the rootfs.\n\n" \
15 "# Format:\n" \
16 "# <package_type>,<package_name>\n" \
17 "# where:\n" \
18 "# <package_type> can be:\n" \
19 "# 'mip' = must install package\n" \
20 "# 'aop' = attempt only package\n" \
21 "# 'mlp' = multilib package\n" \
22 "# 'lgp' = language package\n\n"
23
24 def __init__(self, d, manifest_dir=None):
25 self.d = d
26 self.image_rootfs = d.getVar('IMAGE_ROOTFS', True)
27
28 if manifest_dir is None:
29 self.manifest_dir = self.d.getVar('WORKDIR', True)
30 else:
31 self.manifest_dir = manifest_dir
32
33 self.initial_manifest = os.path.join(self.manifest_dir, "initial_manifest")
34 self.final_manifest = os.path.join(self.manifest_dir, "final_manifest")
35
36 """
37 This creates a standard initial manifest for core-image-(minimal|sato|sato-sdk).
38 This will be used for testing until the class is implemented properly!
39 """
40 def _create_dummy_initial(self):
41 pkg_list = dict()
42 if self.image_rootfs.find("core-image-sato-sdk") > 0:
43 pkg_list['mip'] = \
44 "packagegroup-core-x11-sato-games packagegroup-base-extended " \
45 "packagegroup-core-x11-sato packagegroup-core-x11-base " \
46 "packagegroup-core-sdk packagegroup-core-tools-debug " \
47 "packagegroup-core-boot packagegroup-core-tools-testapps " \
48 "packagegroup-core-eclipse-debug packagegroup-core-qt-demoapps " \
49 "apt packagegroup-core-tools-profile psplash " \
50 "packagegroup-core-standalone-sdk-target " \
51 "packagegroup-core-ssh-openssh dpkg kernel-dev"
52 pkg_list['lgp'] = \
53 "locale-base-en-us locale-base-en-gb"
54 elif self.image_rootfs.find("core-image-sato") > 0:
55 pkg_list['mip'] = \
56 "packagegroup-core-ssh-dropbear packagegroup-core-x11-sato-games " \
57 "packagegroup-core-x11-base psplash apt dpkg packagegroup-base-extended " \
58 "packagegroup-core-x11-sato packagegroup-core-boot"
59 pkg_list['lgp'] = \
60 "locale-base-en-us locale-base-en-gb"
61 elif self.image_rootfs.find("core-image-minimal") > 0:
62 pkg_list['mip'] = "run-postinsts packagegroup-core-boot"
63
64 with open(self.initial_manifest, "w+") as manifest:
65 manifest.write(self.initial_manifest_file_header)
66
67 for pkg_type in pkg_list:
68 for pkg in pkg_list[pkg_type].split():
69 manifest.write("%s,%s\n" % (pkg_type, pkg))
70
71 """
72 This will create the initial manifest which will be used by Rootfs class to
73 generate the rootfs
74 """
75 @abstractmethod
76 def create_initial(self):
77 pass
78
79 """
80 This creates the manifest after everything has been installed.
81 """
82 @abstractmethod
83 def create_final(self):
84 pass
85
86 """
87 The following function parses an initial manifest and returns a dictionary
88 object with the must install, attempt only, multilib and language packages.
89 """
90 def parse_initial_manifest(self):
91 pkgs = dict()
92
93 with open(self.initial_manifest) as manifest:
94 for line in manifest.read().split('\n'):
95 comment = re.match("^#.*", line)
96 pkg = re.match("^(mip|aop|mlp|lgp),(.*)$", line)
97
98 if comment is not None:
99 continue
100
101 if pkg is not None:
102 pkg_type = pkg.group(1)
103 pkg_name = pkg.group(2)
104
105 if not pkg_type in pkgs:
106 pkgs[pkg_type] = [pkg_name]
107 else:
108 pkgs[pkg_type].append(pkg_name)
109
110 return pkgs
111
112
113class RpmManifest(Manifest):
114 def create_initial(self):
115 self._create_dummy_initial()
116
117 def create_final(self):
118 pass
119
120
121class OpkgManifest(Manifest):
122 def create_initial(self):
123 self._create_dummy_initial()
124
125 def create_final(self):
126 pass
127
128
129class DpkgManifest(Manifest):
130 def create_initial(self):
131 var_map = {"PACKAGE_INSTALL": "mip",
132 "PACKAGE_INSTALL_ATTEMPTONLY": "aop",
133 "LINGUAS_INSTALL": "lgp"}
134
135 with open(self.initial_manifest, "w+") as manifest:
136 manifest.write(self.initial_manifest_file_header)
137
138 for var in var_map:
139 pkg_list = self.d.getVar(var, True)
140
141 if pkg_list is None:
142 continue
143
144 for pkg in pkg_list.split():
145 manifest.write("%s,%s\n" % (var_map[var], pkg))
146
147 def create_final(self):
148 pass
149
150
151def create_manifest(d, final_manifest=False, manifest_dir=None):
152 manifest_map = {'rpm': RpmManifest,
153 'ipk': OpkgManifest,
154 'deb': DpkgManifest}
155
156 manifest = manifest_map[d.getVar('IMAGE_PKGTYPE', True)](d, manifest_dir)
157
158 if final_manifest:
159 manifest.create_final()
160 else:
161 manifest.create_initial()
162
163
164if __name__ == "__main__":
165 pass