diff options
Diffstat (limited to 'meta/lib/oe')
-rw-r--r-- | meta/lib/oe/sdk.py | 76 |
1 files changed, 52 insertions, 24 deletions
diff --git a/meta/lib/oe/sdk.py b/meta/lib/oe/sdk.py index 53da0f01ad..3103f48894 100644 --- a/meta/lib/oe/sdk.py +++ b/meta/lib/oe/sdk.py | |||
@@ -5,6 +5,7 @@ from oe.package_manager import * | |||
5 | import os | 5 | import os |
6 | import shutil | 6 | import shutil |
7 | import glob | 7 | import glob |
8 | import traceback | ||
8 | 9 | ||
9 | 10 | ||
10 | class Sdk(object): | 11 | class Sdk(object): |
@@ -25,7 +26,7 @@ class Sdk(object): | |||
25 | else: | 26 | else: |
26 | self.manifest_dir = manifest_dir | 27 | self.manifest_dir = manifest_dir |
27 | 28 | ||
28 | bb.utils.remove(self.sdk_output, True) | 29 | self.remove(self.sdk_output, True) |
29 | 30 | ||
30 | self.install_order = Manifest.INSTALL_ORDER | 31 | self.install_order = Manifest.INSTALL_ORDER |
31 | 32 | ||
@@ -34,29 +35,56 @@ class Sdk(object): | |||
34 | pass | 35 | pass |
35 | 36 | ||
36 | def populate(self): | 37 | def populate(self): |
37 | bb.utils.mkdirhier(self.sdk_output) | 38 | self.mkdirhier(self.sdk_output) |
38 | 39 | ||
39 | # call backend dependent implementation | 40 | # call backend dependent implementation |
40 | self._populate() | 41 | self._populate() |
41 | 42 | ||
42 | # Don't ship any libGL in the SDK | 43 | # Don't ship any libGL in the SDK |
43 | bb.utils.remove(os.path.join(self.sdk_output, self.sdk_native_path, | 44 | self.remove(os.path.join(self.sdk_output, self.sdk_native_path, |
44 | self.d.getVar('libdir_nativesdk', True).strip('/'), | 45 | self.d.getVar('libdir_nativesdk', True).strip('/'), |
45 | "libGL*")) | 46 | "libGL*")) |
46 | 47 | ||
47 | # Fix or remove broken .la files | 48 | # Fix or remove broken .la files |
48 | bb.utils.remove(os.path.join(self.sdk_output, self.sdk_native_path, | 49 | self.remove(os.path.join(self.sdk_output, self.sdk_native_path, |
49 | self.d.getVar('libdir_nativesdk', True).strip('/'), | 50 | self.d.getVar('libdir_nativesdk', True).strip('/'), |
50 | "*.la")) | 51 | "*.la")) |
51 | 52 | ||
52 | # Link the ld.so.cache file into the hosts filesystem | 53 | # Link the ld.so.cache file into the hosts filesystem |
53 | link_name = os.path.join(self.sdk_output, self.sdk_native_path, | 54 | link_name = os.path.join(self.sdk_output, self.sdk_native_path, |
54 | self.sysconfdir, "ld.so.cache") | 55 | self.sysconfdir, "ld.so.cache") |
55 | bb.utils.mkdirhier(os.path.dirname(link_name)) | 56 | self.mkdirhier(os.path.dirname(link_name)) |
56 | os.symlink("/etc/ld.so.cache", link_name) | 57 | os.symlink("/etc/ld.so.cache", link_name) |
57 | 58 | ||
58 | execute_pre_post_process(self.d, self.d.getVar('SDK_POSTPROCESS_COMMAND', True)) | 59 | execute_pre_post_process(self.d, self.d.getVar('SDK_POSTPROCESS_COMMAND', True)) |
59 | 60 | ||
61 | def movefile(self, sourcefile, destdir): | ||
62 | try: | ||
63 | # FIXME: this check of movefile's return code to None should be | ||
64 | # fixed within the function to use only exceptions to signal when | ||
65 | # something goes wrong | ||
66 | if (bb.utils.movefile(sourcefile, destdir) == None): | ||
67 | raise OSError("moving %s to %s failed" | ||
68 | %(sourcefile, destdir)) | ||
69 | #FIXME: using umbrella exc catching because bb.utils method raises it | ||
70 | except Exception as e: | ||
71 | bb.debug(1, "printing the stack trace\n %s" %traceback.format_exc()) | ||
72 | bb.error("unable to place %s in final SDK location" % sourcefile) | ||
73 | |||
74 | def mkdirhier(self, dirpath): | ||
75 | try: | ||
76 | bb.utils.mkdirhier(dirpath) | ||
77 | except OSError as e: | ||
78 | bb.debug(1, "printing the stack trace\n %s" %traceback.format_exc()) | ||
79 | bb.fatal("cannot make dir for SDK: %s" % dirpath) | ||
80 | |||
81 | def remove(self, path, recurse=False): | ||
82 | try: | ||
83 | bb.utils.remove(path, recurse) | ||
84 | #FIXME: using umbrella exc catching because bb.utils method raises it | ||
85 | except Exception as e: | ||
86 | bb.debug(1, "printing the stack trace\n %s" %traceback.format_exc()) | ||
87 | bb.warn("cannot remove SDK dir: %s" % path) | ||
60 | 88 | ||
61 | class RpmSdk(Sdk): | 89 | class RpmSdk(Sdk): |
62 | def __init__(self, d, manifest_dir=None): | 90 | def __init__(self, d, manifest_dir=None): |
@@ -143,15 +171,15 @@ class RpmSdk(Sdk): | |||
143 | "lib", | 171 | "lib", |
144 | "rpm" | 172 | "rpm" |
145 | ) | 173 | ) |
146 | bb.utils.mkdirhier(native_rpm_state_dir) | 174 | self.mkdirhier(native_rpm_state_dir) |
147 | for f in glob.glob(os.path.join(self.sdk_output, | 175 | for f in glob.glob(os.path.join(self.sdk_output, |
148 | "var", | 176 | "var", |
149 | "lib", | 177 | "lib", |
150 | "rpm", | 178 | "rpm", |
151 | "*")): | 179 | "*")): |
152 | bb.utils.movefile(f, native_rpm_state_dir) | 180 | self.movefile(f, native_rpm_state_dir) |
153 | 181 | ||
154 | bb.utils.remove(os.path.join(self.sdk_output, "var"), True) | 182 | self.remove(os.path.join(self.sdk_output, "var"), True) |
155 | 183 | ||
156 | # Move host sysconfig data | 184 | # Move host sysconfig data |
157 | native_sysconf_dir = os.path.join(self.sdk_output, | 185 | native_sysconf_dir = os.path.join(self.sdk_output, |
@@ -159,10 +187,10 @@ class RpmSdk(Sdk): | |||
159 | self.d.getVar('sysconfdir', | 187 | self.d.getVar('sysconfdir', |
160 | True).strip('/'), | 188 | True).strip('/'), |
161 | ) | 189 | ) |
162 | bb.utils.mkdirhier(native_sysconf_dir) | 190 | self.mkdirhier(native_sysconf_dir) |
163 | for f in glob.glob(os.path.join(self.sdk_output, "etc", "*")): | 191 | for f in glob.glob(os.path.join(self.sdk_output, "etc", "*")): |
164 | bb.utils.movefile(f, native_sysconf_dir) | 192 | self.movefile(f, native_sysconf_dir) |
165 | bb.utils.remove(os.path.join(self.sdk_output, "etc"), True) | 193 | self.remove(os.path.join(self.sdk_output, "etc"), True) |
166 | 194 | ||
167 | 195 | ||
168 | class OpkgSdk(Sdk): | 196 | class OpkgSdk(Sdk): |
@@ -219,12 +247,12 @@ class OpkgSdk(Sdk): | |||
219 | target_sysconfdir = os.path.join(self.sdk_target_sysroot, self.sysconfdir) | 247 | target_sysconfdir = os.path.join(self.sdk_target_sysroot, self.sysconfdir) |
220 | host_sysconfdir = os.path.join(self.sdk_host_sysroot, self.sysconfdir) | 248 | host_sysconfdir = os.path.join(self.sdk_host_sysroot, self.sysconfdir) |
221 | 249 | ||
222 | bb.utils.mkdirhier(target_sysconfdir) | 250 | self.mkdirhier(target_sysconfdir) |
223 | shutil.copy(self.target_conf, target_sysconfdir) | 251 | shutil.copy(self.target_conf, target_sysconfdir) |
224 | os.chmod(os.path.join(target_sysconfdir, | 252 | os.chmod(os.path.join(target_sysconfdir, |
225 | os.path.basename(self.target_conf)), 0644) | 253 | os.path.basename(self.target_conf)), 0644) |
226 | 254 | ||
227 | bb.utils.mkdirhier(host_sysconfdir) | 255 | self.mkdirhier(host_sysconfdir) |
228 | shutil.copy(self.host_conf, host_sysconfdir) | 256 | shutil.copy(self.host_conf, host_sysconfdir) |
229 | os.chmod(os.path.join(host_sysconfdir, | 257 | os.chmod(os.path.join(host_sysconfdir, |
230 | os.path.basename(self.host_conf)), 0644) | 258 | os.path.basename(self.host_conf)), 0644) |
@@ -232,11 +260,11 @@ class OpkgSdk(Sdk): | |||
232 | native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, | 260 | native_opkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, |
233 | self.d.getVar('localstatedir_nativesdk', True).strip('/'), | 261 | self.d.getVar('localstatedir_nativesdk', True).strip('/'), |
234 | "lib", "opkg") | 262 | "lib", "opkg") |
235 | bb.utils.mkdirhier(native_opkg_state_dir) | 263 | self.mkdirhier(native_opkg_state_dir) |
236 | for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "opkg", "*")): | 264 | for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "opkg", "*")): |
237 | bb.utils.movefile(f, native_opkg_state_dir) | 265 | self.movefile(f, native_opkg_state_dir) |
238 | 266 | ||
239 | bb.utils.remove(os.path.join(self.sdk_output, "var"), True) | 267 | self.remove(os.path.join(self.sdk_output, "var"), True) |
240 | 268 | ||
241 | 269 | ||
242 | class DpkgSdk(Sdk): | 270 | class DpkgSdk(Sdk): |
@@ -264,7 +292,7 @@ class DpkgSdk(Sdk): | |||
264 | def _copy_apt_dir_to(self, dst_dir): | 292 | def _copy_apt_dir_to(self, dst_dir): |
265 | staging_etcdir_native = self.d.getVar("STAGING_ETCDIR_NATIVE", True) | 293 | staging_etcdir_native = self.d.getVar("STAGING_ETCDIR_NATIVE", True) |
266 | 294 | ||
267 | bb.utils.remove(dst_dir, True) | 295 | self.remove(dst_dir, True) |
268 | 296 | ||
269 | shutil.copytree(os.path.join(staging_etcdir_native, "apt"), dst_dir) | 297 | shutil.copytree(os.path.join(staging_etcdir_native, "apt"), dst_dir) |
270 | 298 | ||
@@ -306,11 +334,11 @@ class DpkgSdk(Sdk): | |||
306 | 334 | ||
307 | native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, | 335 | native_dpkg_state_dir = os.path.join(self.sdk_output, self.sdk_native_path, |
308 | "var", "lib", "dpkg") | 336 | "var", "lib", "dpkg") |
309 | bb.utils.mkdirhier(native_dpkg_state_dir) | 337 | self.mkdirhier(native_dpkg_state_dir) |
310 | for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")): | 338 | for f in glob.glob(os.path.join(self.sdk_output, "var", "lib", "dpkg", "*")): |
311 | bb.utils.movefile(f, native_dpkg_state_dir) | 339 | self.movefile(f, native_dpkg_state_dir) |
340 | self.remove(os.path.join(self.sdk_output, "var"), True) | ||
312 | 341 | ||
313 | bb.utils.remove(os.path.join(self.sdk_output, "var"), True) | ||
314 | 342 | ||
315 | 343 | ||
316 | def sdk_list_installed_packages(d, target, format=None, rootfs_dir=None): | 344 | def sdk_list_installed_packages(d, target, format=None, rootfs_dir=None): |