diff options
author | Fredrik Gustafsson <fredrik.gustafsson@axis.com> | 2020-07-24 16:42:38 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-07-27 19:58:10 +0100 |
commit | 635305fe27b12fca554d694da00ba31d4b552d39 (patch) | |
tree | 9e6cb164ed831ba9340e49f9196cd04be6c9774c /meta/lib | |
parent | bfa8f4c098f3e8eeca7c443b7fe3c34b44dfb515 (diff) | |
download | poky-635305fe27b12fca554d694da00ba31d4b552d39.tar.gz |
deb: 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: 2b305d5f48be84b6362be850d6e0b2bd7f4691ce)
Signed-off-by: Fredrik Gustafsson <fredrigu@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/package_manager/deb/sdk.py | 95 | ||||
-rw-r--r-- | meta/lib/oe/sdk.py | 87 |
2 files changed, 96 insertions, 86 deletions
diff --git a/meta/lib/oe/package_manager/deb/sdk.py b/meta/lib/oe/package_manager/deb/sdk.py new file mode 100644 index 0000000000..aafcd259e5 --- /dev/null +++ b/meta/lib/oe/package_manager/deb/sdk.py | |||
@@ -0,0 +1,95 @@ | |||
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 DpkgPM | ||
9 | import shutil | ||
10 | |||
11 | class DpkgSdk(Sdk): | ||
12 | def __init__(self, d, manifest_dir=None): | ||
13 | super(DpkgSdk, self).__init__(d, manifest_dir) | ||
14 | |||
15 | self.target_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt") | ||
16 | self.host_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt-sdk") | ||
17 | |||
18 | from oe.package_manager.deb.manifest import DpkgManifest | ||
19 | |||
20 | self.target_manifest = DpkgManifest(d, self.manifest_dir, | ||
21 | Manifest.MANIFEST_TYPE_SDK_TARGET) | ||
22 | self.host_manifest = DpkgManifest(d, self.manifest_dir, | ||
23 | Manifest.MANIFEST_TYPE_SDK_HOST) | ||
24 | |||
25 | deb_repo_workdir = "oe-sdk-repo" | ||
26 | if "sdk_ext" in d.getVar("BB_RUNTASK"): | ||
27 | deb_repo_workdir = "oe-sdk-ext-repo" | ||
28 | |||
29 | self.target_pm = DpkgPM(d, self.sdk_target_sysroot, | ||
30 | self.d.getVar("PACKAGE_ARCHS"), | ||
31 | self.d.getVar("DPKG_ARCH"), | ||
32 | self.target_conf_dir, | ||
33 | deb_repo_workdir=deb_repo_workdir) | ||
34 | |||
35 | self.host_pm = DpkgPM(d, self.sdk_host_sysroot, | ||
36 | self.d.getVar("SDK_PACKAGE_ARCHS"), | ||
37 | self.d.getVar("DEB_SDK_ARCH"), | ||
38 | self.host_conf_dir, | ||
39 | deb_repo_workdir=deb_repo_workdir) | ||
40 | |||
41 | def _copy_apt_dir_to(self, dst_dir): | ||
42 | staging_etcdir_native = self.d.getVar("STAGING_ETCDIR_NATIVE") | ||
43 | |||
44 | self.remove(dst_dir, True) | ||
45 | |||
46 | shutil.copytree(os.path.join(staging_etcdir_native, "apt"), dst_dir) | ||
47 | |||
48 | def _populate_sysroot(self, pm, manifest): | ||
49 | pkgs_to_install = manifest.parse_initial_manifest() | ||
50 | |||
51 | pm.write_index() | ||
52 | pm.update() | ||
53 | |||
54 | for pkg_type in self.install_order: | ||
55 | if pkg_type in pkgs_to_install: | ||
56 | pm.install(pkgs_to_install[pkg_type], | ||
57 | [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) | ||
58 | |||
59 | def _populate(self): | ||
60 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_PRE_TARGET_COMMAND")) | ||
61 | |||
62 | bb.note("Installing TARGET packages") | ||
63 | self._populate_sysroot(self.target_pm, self.target_manifest) | ||
64 | |||
65 | self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) | ||
66 | |||
67 | self.target_pm.run_intercepts(populate_sdk='target') | ||
68 | |||
69 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) | ||
70 | |||
71 | self._copy_apt_dir_to(os.path.join(self.sdk_target_sysroot, "etc", "apt")) | ||
72 | |||
73 | if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): | ||
74 | self.target_pm.remove_packaging_data() | ||
75 | |||
76 | bb.note("Installing NATIVESDK packages") | ||
77 | self._populate_sysroot(self.host_pm, self.host_manifest) | ||
78 | self.install_locales(self.host_pm) | ||
79 | |||
80 | self.host_pm.run_intercepts(populate_sdk='host') | ||
81 | |||
82 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) | ||
83 | |||
84 | self._copy_apt_dir_to(os.path.join(self.sdk_output, self.sdk_native_path, | ||
85 | "etc", "apt")) | ||
86 | |||
87 | if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): | ||
88 | self.host_pm.remove_packaging_data() | ||
89 | |||
90 | native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, | ||
91 | "var", "lib", "dpkg") | ||
92 | self.mkdirhier(native_dpkg_state_dir) | ||
93 | for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")): | ||
94 | self.movefile(f, native_dpkg_state_dir) | ||
95 | 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 8b97f05a29..2f8cbd03d7 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 DpkgSdk(Sdk): | ||
114 | def __init__(self, d, manifest_dir=None): | ||
115 | super(DpkgSdk, self).__init__(d, manifest_dir) | ||
116 | |||
117 | self.target_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt") | ||
118 | self.host_conf_dir = os.path.join(self.d.getVar("APTCONF_TARGET"), "apt-sdk") | ||
119 | |||
120 | self.target_manifest = DpkgManifest(d, self.manifest_dir, | ||
121 | Manifest.MANIFEST_TYPE_SDK_TARGET) | ||
122 | self.host_manifest = DpkgManifest(d, self.manifest_dir, | ||
123 | Manifest.MANIFEST_TYPE_SDK_HOST) | ||
124 | |||
125 | deb_repo_workdir = "oe-sdk-repo" | ||
126 | if "sdk_ext" in d.getVar("BB_RUNTASK"): | ||
127 | deb_repo_workdir = "oe-sdk-ext-repo" | ||
128 | |||
129 | self.target_pm = DpkgPM(d, self.sdk_target_sysroot, | ||
130 | self.d.getVar("PACKAGE_ARCHS"), | ||
131 | self.d.getVar("DPKG_ARCH"), | ||
132 | self.target_conf_dir, | ||
133 | deb_repo_workdir=deb_repo_workdir) | ||
134 | |||
135 | self.host_pm = DpkgPM(d, self.sdk_host_sysroot, | ||
136 | self.d.getVar("SDK_PACKAGE_ARCHS"), | ||
137 | self.d.getVar("DEB_SDK_ARCH"), | ||
138 | self.host_conf_dir, | ||
139 | deb_repo_workdir=deb_repo_workdir) | ||
140 | |||
141 | def _copy_apt_dir_to(self, dst_dir): | ||
142 | staging_etcdir_native = self.d.getVar("STAGING_ETCDIR_NATIVE") | ||
143 | |||
144 | self.remove(dst_dir, True) | ||
145 | |||
146 | shutil.copytree(os.path.join(staging_etcdir_native, "apt"), dst_dir) | ||
147 | |||
148 | def _populate_sysroot(self, pm, manifest): | ||
149 | pkgs_to_install = manifest.parse_initial_manifest() | ||
150 | |||
151 | pm.write_index() | ||
152 | pm.update() | ||
153 | |||
154 | for pkg_type in self.install_order: | ||
155 | if pkg_type in pkgs_to_install: | ||
156 | pm.install(pkgs_to_install[pkg_type], | ||
157 | [False, True][pkg_type == Manifest.PKG_TYPE_ATTEMPT_ONLY]) | ||
158 | |||
159 | def _populate(self): | ||
160 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_PRE_TARGET_COMMAND")) | ||
161 | |||
162 | bb.note("Installing TARGET packages") | ||
163 | self._populate_sysroot(self.target_pm, self.target_manifest) | ||
164 | |||
165 | self.target_pm.install_complementary(self.d.getVar('SDKIMAGE_INSTALL_COMPLEMENTARY')) | ||
166 | |||
167 | self.target_pm.run_intercepts(populate_sdk='target') | ||
168 | |||
169 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_TARGET_COMMAND")) | ||
170 | |||
171 | self._copy_apt_dir_to(os.path.join(self.sdk_target_sysroot, "etc", "apt")) | ||
172 | |||
173 | if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): | ||
174 | self.target_pm.remove_packaging_data() | ||
175 | |||
176 | bb.note("Installing NATIVESDK packages") | ||
177 | self._populate_sysroot(self.host_pm, self.host_manifest) | ||
178 | self.install_locales(self.host_pm) | ||
179 | |||
180 | self.host_pm.run_intercepts(populate_sdk='host') | ||
181 | |||
182 | execute_pre_post_process(self.d, self.d.getVar("POPULATE_SDK_POST_HOST_COMMAND")) | ||
183 | |||
184 | self._copy_apt_dir_to(os.path.join(self.sdk_output, self.sdk_native_path, | ||
185 | "etc", "apt")) | ||
186 | |||
187 | if not bb.utils.contains("SDKIMAGE_FEATURES", "package-management", True, False, self.d): | ||
188 | self.host_pm.remove_packaging_data() | ||
189 | |||
190 | native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, | ||
191 | "var", "lib", "dpkg") | ||
192 | self.mkdirhier(native_dpkg_state_dir) | ||
193 | for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")): | ||
194 | self.movefile(f, native_dpkg_state_dir) | ||
195 | self.remove(os.path.join(self.sdk_output, "var"), True) | ||
196 | |||
197 | |||
198 | |||
199 | def sdk_list_installed_packages(d, target, rootfs_dir=None): | 113 | def sdk_list_installed_packages(d, target, rootfs_dir=None): |
200 | if rootfs_dir is None: | 114 | if rootfs_dir is None: |
201 | sdk_output = d.getVar('SDK_OUTPUT') | 115 | sdk_output = d.getVar('SDK_OUTPUT') |
@@ -220,6 +134,7 @@ def populate_sdk(d, manifest_dir=None): | |||
220 | img_type = d.getVar('IMAGE_PKGTYPE') | 134 | img_type = d.getVar('IMAGE_PKGTYPE') |
221 | from oe.package_manager.rpm.sdk import RpmSdk | 135 | from oe.package_manager.rpm.sdk import RpmSdk |
222 | from oe.package_manager.ipk.sdk import OpkgSdk | 136 | from oe.package_manager.ipk.sdk import OpkgSdk |
137 | from oe.package_manager.deb.sdk import DpkgSdk | ||
223 | if img_type == "rpm": | 138 | if img_type == "rpm": |
224 | RpmSdk(d, manifest_dir).populate() | 139 | RpmSdk(d, manifest_dir).populate() |
225 | elif img_type == "ipk": | 140 | elif img_type == "ipk": |