summaryrefslogtreecommitdiffstats
path: root/meta/classes/populate_sdk_base.bbclass
diff options
context:
space:
mode:
authorHaris Okanovic <haris.okanovic@ni.com>2015-11-17 14:21:12 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-01 21:32:00 +0000
commit5ba638210cbc69a67dd2485375452b7f0df64217 (patch)
tree4b08cab7d7905f24942ff0cd0b6ed2034235c4e0 /meta/classes/populate_sdk_base.bbclass
parent7fed65564d0baf496c2dd209415afd5baa1cdb2a (diff)
downloadpoky-5ba638210cbc69a67dd2485375452b7f0df64217.tar.gz
populate_sdk_base: Add sysroot symlink check
Add optional check to do_populate_sdk() that verifies SDK sysroots don't contain dangling or escaping symlinks before attempting to tar an archive. Such links may fail a `tar -h` operation (-h => follow symlinks) or archive the build system's files. Set CHECK_SDK_SYSROOTS = "1" to enable this check. Use case: The -h option may be set via SDKTAROPTS in some configurations to create symlink-less SDK archives for Windows file systems. (From OE-Core rev: 2658200fa2b3df08880ee937a3de5cb2866f8a50) Signed-off-by: Haris Okanovic <haris.okanovic@ni.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/populate_sdk_base.bbclass')
-rw-r--r--meta/classes/populate_sdk_base.bbclass53
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
81POPULATE_SDK_POST_TARGET_COMMAND_append = " write_target_sdk_manifest ; " 81POPULATE_SDK_POST_TARGET_COMMAND_append = " write_target_sdk_manifest ; "
82POPULATE_SDK_POST_HOST_COMMAND_append = " write_host_sdk_manifest; " 82POPULATE_SDK_POST_HOST_COMMAND_append = " write_host_sdk_manifest; "
83SDK_POSTPROCESS_COMMAND = " create_sdk_files; tar_sdk; ${SDK_PACKAGING_FUNC}; " 83SDK_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
123python 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
123SDKTAROPTS = "--owner=root --group=root" 174SDKTAROPTS = "--owner=root --group=root"
124 175
125fakeroot tar_sdk() { 176fakeroot tar_sdk() {