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/lib/oe/package_manager/ipk/sdk.py | |
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/lib/oe/package_manager/ipk/sdk.py')
-rw-r--r-- | meta/lib/oe/package_manager/ipk/sdk.py | 96 |
1 files changed, 96 insertions, 0 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) | ||