diff options
| -rw-r--r-- | meta/classes/populate_sdk_base.bbclass | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass index 35e129b068..23dc1156bd 100644 --- a/meta/classes/populate_sdk_base.bbclass +++ b/meta/classes/populate_sdk_base.bbclass | |||
| @@ -80,7 +80,7 @@ python write_host_sdk_manifest () { | |||
| 80 | 80 | ||
| 81 | POPULATE_SDK_POST_TARGET_COMMAND_append = " write_target_sdk_manifest ; " | 81 | POPULATE_SDK_POST_TARGET_COMMAND_append = " write_target_sdk_manifest ; " |
| 82 | POPULATE_SDK_POST_HOST_COMMAND_append = " write_host_sdk_manifest; " | 82 | POPULATE_SDK_POST_HOST_COMMAND_append = " write_host_sdk_manifest; " |
| 83 | SDK_POSTPROCESS_COMMAND = " create_sdk_files; tar_sdk; ${SDK_PACKAGING_FUNC}; " | 83 | SDK_POSTPROCESS_COMMAND = " create_sdk_files; check_sdk_sysroots; tar_sdk; ${SDK_PACKAGING_FUNC}; " |
| 84 | 84 | ||
| 85 | # Some archs override this, we need the nativesdk version | 85 | # Some archs override this, we need the nativesdk version |
| 86 | # turns out this is hard to get from the datastore due to TRANSLATED_TARGET_ARCH | 86 | # turns out this is hard to get from the datastore due to TRANSLATED_TARGET_ARCH |
| @@ -120,6 +120,57 @@ fakeroot create_sdk_files() { | |||
| 120 | sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py | 120 | sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | python check_sdk_sysroots() { | ||
| 124 | # Fails build if there are broken or dangling symlinks in SDK sysroots | ||
| 125 | |||
| 126 | if d.getVar('CHECK_SDK_SYSROOTS', True) != '1': | ||
| 127 | # disabled, bail out | ||
| 128 | return | ||
| 129 | |||
| 130 | def norm_path(path): | ||
| 131 | return os.path.abspath(path) | ||
| 132 | |||
| 133 | # Get scan root | ||
| 134 | SCAN_ROOT = norm_path("${SDK_OUTPUT}/${SDKPATH}/sysroots/") | ||
| 135 | |||
| 136 | bb.note('Checking SDK sysroots at ' + SCAN_ROOT) | ||
| 137 | |||
| 138 | def check_symlink(linkPath): | ||
| 139 | if not os.path.islink(linkPath): | ||
| 140 | return | ||
| 141 | |||
| 142 | linkDirPath = os.path.dirname(linkPath) | ||
| 143 | |||
| 144 | targetPath = os.readlink(linkPath) | ||
| 145 | if not os.path.isabs(targetPath): | ||
| 146 | targetPath = os.path.join(linkDirPath, targetPath) | ||
| 147 | targetPath = norm_path(targetPath) | ||
| 148 | |||
| 149 | if SCAN_ROOT != os.path.commonprefix( [SCAN_ROOT, targetPath] ): | ||
| 150 | bb.error("Escaping symlink {0!s} --> {1!s}".format(linkPath, targetPath)) | ||
| 151 | return | ||
| 152 | |||
| 153 | if not os.path.exists(targetPath): | ||
| 154 | bb.error("Broken symlink {0!s} --> {1!s}".format(linkPath, targetPath)) | ||
| 155 | return | ||
| 156 | |||
| 157 | if os.path.isdir(targetPath): | ||
| 158 | dir_walk(targetPath) | ||
| 159 | |||
| 160 | def walk_error_handler(e): | ||
| 161 | bb.error(str(e)) | ||
| 162 | |||
| 163 | def dir_walk(rootDir): | ||
| 164 | for dirPath,subDirEntries,fileEntries in os.walk(rootDir, followlinks=False, onerror=walk_error_handler): | ||
| 165 | entries = subDirEntries + fileEntries | ||
| 166 | for e in entries: | ||
| 167 | ePath = os.path.join(dirPath, e) | ||
| 168 | check_symlink(ePath) | ||
| 169 | |||
| 170 | # start | ||
| 171 | dir_walk(SCAN_ROOT) | ||
| 172 | } | ||
| 173 | |||
| 123 | SDKTAROPTS = "--owner=root --group=root" | 174 | SDKTAROPTS = "--owner=root --group=root" |
| 124 | 175 | ||
| 125 | fakeroot tar_sdk() { | 176 | fakeroot tar_sdk() { |
