diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2016-08-04 12:02:11 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-08-10 10:46:31 +0100 |
commit | 961b5269cdda9d9f7a2abc36401ae484e550089d (patch) | |
tree | feab148cbc72f152afe11f3c7e9da73c7af28105 /meta/classes/package.bbclass | |
parent | 416c4bc00973f585b18262f62dbb1aee188dbee9 (diff) | |
download | poky-961b5269cdda9d9f7a2abc36401ae484e550089d.tar.gz |
package.bbclass: better handling of middle-path dir symlinks
For example in a directory structure like this
.
├── symlink -> foo/bar
└── foo
└── bar
└── file
'file' could be referenced by specifying e.g. 'foo/bar/file' or
'symlink/file'. In cases like this populate_packages() might crash if
the file was referenced (in FILES) via the symlinked directory. The
outcome depends on how the user defined FILES_pn. This patch should
make the function behave more consistently. It looks for files which are
referenced via symlinked directories and handles them separately,
failing if their parent directory is a non-existent path. For example,
defining FILES_{PN} = "symlink/file" causes a build failure because
symlinks target 'foo/bar' is not included at all.
[YOCTO #9827]
(From OE-Core rev: 29d1738329ddf4e63844a9ad1158a1d41e2ee343)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r-- | meta/classes/package.bbclass | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 81acc10367..5cb1939e54 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -259,14 +259,27 @@ def files_from_filevars(filevars): | |||
259 | continue | 259 | continue |
260 | files.append(f) | 260 | files.append(f) |
261 | 261 | ||
262 | for f in files: | 262 | symlink_paths = [] |
263 | for ind, f in enumerate(files): | ||
264 | # Handle directory symlinks. Truncate path to the lowest level symlink | ||
265 | parent = '' | ||
266 | for dirname in f.split('/')[:-1]: | ||
267 | parent = os.path.join(parent, dirname) | ||
268 | if dirname == '.': | ||
269 | continue | ||
270 | if cpath.islink(parent): | ||
271 | symlink_paths.append(f) | ||
272 | files[ind] = parent | ||
273 | f = parent | ||
274 | break | ||
275 | |||
263 | if not cpath.islink(f): | 276 | if not cpath.islink(f): |
264 | if cpath.isdir(f): | 277 | if cpath.isdir(f): |
265 | newfiles = [ os.path.join(f,x) for x in os.listdir(f) ] | 278 | newfiles = [ os.path.join(f,x) for x in os.listdir(f) ] |
266 | if newfiles: | 279 | if newfiles: |
267 | files += newfiles | 280 | files += newfiles |
268 | 281 | ||
269 | return files | 282 | return files, symlink_paths |
270 | 283 | ||
271 | # Called in package_<rpm,ipk,deb>.bbclass to get the correct list of configuration files | 284 | # Called in package_<rpm,ipk,deb>.bbclass to get the correct list of configuration files |
272 | def get_conffiles(pkg, d): | 285 | def get_conffiles(pkg, d): |
@@ -281,7 +294,7 @@ def get_conffiles(pkg, d): | |||
281 | if conffiles == None: | 294 | if conffiles == None: |
282 | conffiles = "" | 295 | conffiles = "" |
283 | conffiles = conffiles.split() | 296 | conffiles = conffiles.split() |
284 | conf_orig_list = files_from_filevars(conffiles) | 297 | conf_orig_list = files_from_filevars(conffiles)[0] |
285 | 298 | ||
286 | # Remove links and directories from conf_orig_list to get conf_list which only contains normal files | 299 | # Remove links and directories from conf_orig_list to get conf_list which only contains normal files |
287 | conf_list = [] | 300 | conf_list = [] |
@@ -1111,7 +1124,7 @@ python populate_packages () { | |||
1111 | filesvar.replace("//", "/") | 1124 | filesvar.replace("//", "/") |
1112 | 1125 | ||
1113 | origfiles = filesvar.split() | 1126 | origfiles = filesvar.split() |
1114 | files = files_from_filevars(origfiles) | 1127 | files, symlink_paths = files_from_filevars(origfiles) |
1115 | 1128 | ||
1116 | if autodebug and pkg.endswith("-dbg"): | 1129 | if autodebug and pkg.endswith("-dbg"): |
1117 | files.extend(debug) | 1130 | files.extend(debug) |
@@ -1157,6 +1170,15 @@ python populate_packages () { | |||
1157 | if ret is False or ret == 0: | 1170 | if ret is False or ret == 0: |
1158 | raise bb.build.FuncFailed("File population failed") | 1171 | raise bb.build.FuncFailed("File population failed") |
1159 | 1172 | ||
1173 | # Check if symlink paths exist | ||
1174 | for file in symlink_paths: | ||
1175 | if not os.path.exists(os.path.join(root,file)): | ||
1176 | bb.fatal("File '%s' cannot be packaged into '%s' because its " | ||
1177 | "parent directory structure does not exist. One of " | ||
1178 | "its parent directories is a symlink whose target " | ||
1179 | "directory is not included in the package." % | ||
1180 | (file, pkg)) | ||
1181 | |||
1160 | os.umask(oldumask) | 1182 | os.umask(oldumask) |
1161 | os.chdir(workdir) | 1183 | os.chdir(workdir) |
1162 | 1184 | ||