aboutsummaryrefslogtreecommitdiffstats
path: root/utils/sdk-populate-clean-broken-links.patch
blob: a0a8561248057dd4c1ba0ba90473ca1d7096dddf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
diff --git a/meta/lib/oe/sdk.py b/meta/lib/oe/sdk.py
index ca349c4..576cae8 100644
--- a/meta/lib/oe/sdk.py
+++ b/meta/lib/oe/sdk.py
@@ -49,6 +49,24 @@ class Sdk(object):
                                      self.d.getVar('libdir_nativesdk', True).strip('/'),
                                      "*.la"))
 
+        # Remove any broken links in sdk target sysroot
+        bb.note("SDK scanning Link in %s" % self.sdk_target_sysroot)
+        lnk_pths = []
+        for root, dirs, files in os.walk(self.sdk_target_sysroot):
+            lnk_pths += [os.path.join(root, d) for d in dirs
+                         if os.path.islink(os.path.join(root, d))]
+            lnk_pths += [os.path.join(root, f) for f in files
+                         if os.path.islink(os.path.join(root, f))]
+
+        for lnk in lnk_pths:
+            try:
+                os.stat(lnk)
+            except OSError:
+                bb.note("SDK Broken Link Removing: %s -> %s" %
+                        (lnk, os.readlink(lnk)))
+                os.unlink(lnk)
+                pass
+
         # Link the ld.so.cache file into the hosts filesystem
         link_name = os.path.join(self.sdk_output, self.sdk_native_path,
                                  self.sysconfdir, "ld.so.cache")