diff options
author | Fredrik Gustafsson <fredrik.gustafsson@axis.com> | 2020-07-24 16:42:37 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-07-27 19:58:10 +0100 |
commit | bfa8f4c098f3e8eeca7c443b7fe3c34b44dfb515 (patch) | |
tree | c59f7e1655345102d0ad95f91bb611db33b0382b /meta | |
parent | e9e2e329991a68832eff2b469101894aea1a9a9c (diff) | |
download | poky-bfa8f4c098f3e8eeca7c443b7fe3c34b44dfb515.tar.gz |
ipk: Move sdk to its own dir
This is a part of a refactor that will split the package manager
code so that it's possible to use other package managers in other
layers.
(From OE-Core rev: 3f9cec50065eec5a02ffcc8ccc2986f2027b44b5)
Signed-off-by: Fredrik Gustafsson <fredrigu@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oe/package_manager/ipk/sdk.py | 96 | ||||
-rw-r--r-- | meta/lib/oe/sdk.py | 87 |
2 files changed, 97 insertions, 86 deletions
diff --git a/meta/lib/oe/package_manager/ipk/sdk.py b/meta/lib/oe/package_manager/ipk/sdk.py new file mode 100644 index 0000000000..3d59f7a517 --- /dev/null +++ b/meta/lib/oe/package_manager/ipk/sdk.py | |||
@@ -0,0 +1,96 @@ | |||
1 | # | ||
2 | # SPDX-License-Identifier: GPL-2.0-only | ||
3 | # | ||
4 | |||
5 | from oe.utils import execute_pre_post_process | ||
6 | from oe.sdk import Sdk | ||
7 | from oe.manifest import Manifest | ||
8 | from oe.package_manager import OpkgPM | ||
9 | import shutil | ||
10 | import glob | ||
11 | |||
12 | class OpkgSdk(Sdk): | ||
13 | def __init__(self, d, manifest_dir=None): | ||
14 | super(OpkgSdk, self).__init__(d, manifest_dir) | ||
15 | |||
16 | self.target_conf = self.d.getVar("IPKGCONF_TARGET") | ||
17 | self.host_conf = self.d.getVar("IPKGCONF_SDK") | ||
18 | |||
19 | from oe.package_manager.ipk.manifest import OpkgManifest | ||
20 | self.target_manifest = OpkgManifest(d, self.manifest_dir, | ||
21 | Manifest.MANIFEST_TYPE_SDK_TARGET) | ||
22 | self.host_manifest = OpkgManifest(d, self.manifest_dir, | ||
23 | Manifest.MANIFEST_TYPE_SDK_HOST) | ||
24 | |||
25 | ipk_repo_workdir = "oe-sdk-repo" | ||
26 | if "sdk_ext" in d.getVar("BB_RUNTASK"): | ||
27 | ipk_repo_workdir = "oe-sdk-ext-repo" | ||
28 | |||
29 | self.target_pm = OpkgPM(d, self.sdk_target_sysroot, self.target_conf, | ||
30 | self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS"), | ||
31 | ipk_repo_workdir=ipk_repo_workdir) | ||
32 | |||
33 | self.host_pm = OpkgPM(d, self.sdk_host_sysroot, self.host_conf, | ||
34 | self.d.getVar("SDK_PACKAGE_ARCHS"), | ||
35 | ipk_repo_workdir=ipk_repo_workdir) | ||
36 | |||
37 | def _populate_sysroot(self, pm, manifest): | ||
38 | pkgs_to_install = manifest.parse_initial_manifest() | ||
39 | |||
40 | if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS') or "") != "1": | ||
41 | pm.write_index() | ||
42 | |||
43 | pm.update() | ||
44 | |||
45 | for pkg_type in self.install_order: | ||
46 | if pkg_type in pkgs_to_install: | ||
47 | pm.install(pkgs_to_install[pkg_type], | ||
48 | [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) | ||
49 | |||
50 | def _populate(self): | ||
51 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_PRE_TARGET_COMMAND")) | ||
52 | |||
53 | bb.note("Installing TARGET packages") | ||
54 | self._populate_sysroot(self.target_pm, self.target_manifest) | ||
55 | |||
56 | self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) | ||
57 | |||
58 | self.target_pm.run_intercepts(populate_sdk='target') | ||
59 | |||
60 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) | ||
61 | |||
62 | if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): | ||
63 | self.target_pm.remove_packaging_data() | ||
64 | |||
65 | bb.note("Installing NATIVESDK packages") | ||
66 | self._populate_sysroot(self.host_pm, self.host_manifest) | ||
67 | self.install_locales(self.host_pm) | ||
68 | |||
69 | self.host_pm.run_intercepts(populate_sdk='host') | ||
70 | |||
71 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) | ||
72 | |||
73 | if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): | ||
74 | self.host_pm.remove_packaging_data() | ||
75 | |||
76 | target_sysconfdir = os.path.join(self.sdk_target_sysroot, self.sysconfdir) | ||
77 | host_sysconfdir = os.path.join(self.sdk_host_sysroot, self.sysconfdir) | ||
78 | |||
79 | self.mkdirhier(target_sysconfdir) | ||
80 | shutil.copy(self.target_conf, target_sysconfdir) | ||
81 | os.chmod(os.path.join(target_sysconfdir, | ||
82 | os.path.basename(self.target_conf)), 0o644) | ||
83 | |||
84 | self.mkdirhier(host_sysconfdir) | ||
85 | shutil.copy(self.host_conf, host_sysconfdir) | ||
86 | os.chmod(os.path.join(host_sysconfdir, | ||
87 | os.path.basename(self.host_conf)), 0o644) | ||
88 | |||
89 | native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, | ||
90 | self.d.getVar('localstatedir_nativesdk').strip('/'), | ||
91 | "lib", "opkg") | ||
92 | self.mkdirhier(native_opkg_state_dir) | ||
93 | for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "opkg", "*")): | ||
94 | self.movefile(f, native_opkg_state_dir) | ||
95 | |||
96 | self.remove(os.path.join(self.sdk_output, "var"), True) | ||
diff --git a/meta/lib/oe/sdk.py b/meta/lib/oe/sdk.py index b675b6549c..8b97f05a29 100644 --- a/meta/lib/oe/sdk.py +++ b/meta/lib/oe/sdk.py | |||
@@ -110,92 +110,6 @@ class Sdk(object, metaclass=ABCMeta): | |||
110 | pass | 110 | pass |
111 | 111 | ||
112 | 112 | ||
113 | class OpkgSdk(Sdk): | ||
114 | def __init__(self, d, manifest_dir=None): | ||
115 | super(OpkgSdk, self).__init__(d, manifest_dir) | ||
116 | |||
117 | self.target_conf = self.d.getVar("IPKGCONF_TARGET") | ||
118 | self.host_conf = self.d.getVar("IPKGCONF_SDK") | ||
119 | |||
120 | self.target_manifest = OpkgManifest(d, self.manifest_dir, | ||
121 | Manifest.MANIFEST_TYPE_SDK_TARGET) | ||
122 | self.host_manifest = OpkgManifest(d, self.manifest_dir, | ||
123 | Manifest.MANIFEST_TYPE_SDK_HOST) | ||
124 | |||
125 | ipk_repo_workdir = "oe-sdk-repo" | ||
126 | if "sdk_ext" in d.getVar("BB_RUNTASK"): | ||
127 | ipk_repo_workdir = "oe-sdk-ext-repo" | ||
128 | |||
129 | self.target_pm = OpkgPM(d, self.sdk_target_sysroot, self.target_conf, | ||
130 | self.d.getVar("ALL_MULTILIB_PACKAGE_ARCHS"), | ||
131 | ipk_repo_workdir=ipk_repo_workdir) | ||
132 | |||
133 | self.host_pm = OpkgPM(d, self.sdk_host_sysroot, self.host_conf, | ||
134 | self.d.getVar("SDK_PACKAGE_ARCHS"), | ||
135 | ipk_repo_workdir=ipk_repo_workdir) | ||
136 | |||
137 | def _populate_sysroot(self, pm, manifest): | ||
138 | pkgs_to_install = manifest.parse_initial_manifest() | ||
139 | |||
140 | if (self.d.getVar('BUILD_IMAGES_FROM_FEEDS') or "") != "1": | ||
141 | pm.write_index() | ||
142 | |||
143 | pm.update() | ||
144 | |||
145 | for pkg_type in self.install_order: | ||
146 | if pkg_type in pkgs_to_install: | ||
147 | pm.install(pkgs_to_install[pkg_type], | ||
148 | [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) | ||
149 | |||
150 | def _populate(self): | ||
151 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_PRE_TARGET_COMMAND")) | ||
152 | |||
153 | bb.note("Installing TARGET packages") | ||
154 | self._populate_sysroot(self.target_pm, self.target_manifest) | ||
155 | |||
156 | self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) | ||
157 | |||
158 | self.target_pm.run_intercepts(populate_sdk='target') | ||
159 | |||
160 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) | ||
161 | |||
162 | if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): | ||
163 | self.target_pm.remove_packaging_data() | ||
164 | |||
165 | bb.note("Installing NATIVESDK packages") | ||
166 | self._populate_sysroot(self.host_pm, self.host_manifest) | ||
167 | self.install_locales(self.host_pm) | ||
168 | |||
169 | self.host_pm.run_intercepts(populate_sdk='host') | ||
170 | |||
171 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) | ||
172 | |||
173 | if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): | ||
174 | self.host_pm.remove_packaging_data() | ||
175 | |||
176 | target_sysconfdir = os.path.join(self.sdk_target_sysroot, self.sysconfdir) | ||
177 | host_sysconfdir = os.path.join(self.sdk_host_sysroot, self.sysconfdir) | ||
178 | |||
179 | self.mkdirhier(target_sysconfdir) | ||
180 | shutil.copy(self.target_conf, target_sysconfdir) | ||
181 | os.chmod(os.path.join(target_sysconfdir, | ||
182 | os.path.basename(self.target_conf)), 0o644) | ||
183 | |||
184 | self.mkdirhier(host_sysconfdir) | ||
185 | shutil.copy(self.host_conf, host_sysconfdir) | ||
186 | os.chmod(os.path.join(host_sysconfdir, | ||
187 | os.path.basename(self.host_conf)), 0o644) | ||
188 | |||
189 | native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, | ||
190 | self.d.getVar('localstatedir_nativesdk').strip('/'), | ||
191 | "lib", "opkg") | ||
192 | self.mkdirhier(native_opkg_state_dir) | ||
193 | for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "opkg", "*")): | ||
194 | self.movefile(f, native_opkg_state_dir) | ||
195 | |||
196 | self.remove(os.path.join(self.sdk_output, "var"), True) | ||
197 | |||
198 | |||
199 | class DpkgSdk(Sdk): | 113 | class DpkgSdk(Sdk): |
200 | def __init__(self, d, manifest_dir=None): | 114 | def __init__(self, d, manifest_dir=None): |
201 | super(DpkgSdk, self).__init__(d, manifest_dir) | 115 | super(DpkgSdk, self).__init__(d, manifest_dir) |
@@ -305,6 +219,7 @@ def populate_sdk(d, manifest_dir=None): | |||
305 | 219 | ||
306 | img_type = d.getVar('IMAGE_PKGTYPE') | 220 | img_type = d.getVar('IMAGE_PKGTYPE') |
307 | from oe.package_manager.rpm.sdk import RpmSdk | 221 | from oe.package_manager.rpm.sdk import RpmSdk |
222 | from oe.package_manager.ipk.sdk import OpkgSdk | ||
308 | if img_type == "rpm": | 223 | if img_type == "rpm": |
309 | RpmSdk(d, manifest_dir).populate() | 224 | RpmSdk(d, manifest_dir).populate() |
310 | elif img_type == "ipk": | 225 | elif img_type == "ipk": |