diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-29 13:45:17 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-01 15:54:01 +0000 |
commit | afb1b3fac830595523a6d7c4a05920853bfaf760 (patch) | |
tree | 3090baf9d7b2bd1d964eb0797eece13c63b07733 /meta/classes/package.bbclass | |
parent | fed8dfff1fa697bccf1f9199c9b08bd0b7c16cb6 (diff) | |
download | poky-afb1b3fac830595523a6d7c4a05920853bfaf760.tar.gz |
package.bbclass: Improve kernel module handling
Currently the kernel module handling consists of several special cases
and has its own path walking. This refactors the code to handle them in
a more standardised way which is also a bit more efficient.
(From OE-Core rev: ad51b54f0afe8c56033137b7cf9ba398877b2651)
(From OE-Core rev: cb24a72e97afb43de5e1e79ff807fd9e184df6a2)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r-- | meta/classes/package.bbclass | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index 0be84ed74f..0f11ba9e5f 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
@@ -325,10 +325,6 @@ def runstrip(file, elftype, d): | |||
325 | pathprefix = "export PATH=%s; " % d.getVar('PATH', True) | 325 | pathprefix = "export PATH=%s; " % d.getVar('PATH', True) |
326 | strip = d.getVar("STRIP", True) | 326 | strip = d.getVar("STRIP", True) |
327 | 327 | ||
328 | # Handle kernel modules specifically - .debug directories here are pointless | ||
329 | if file.find("/lib/modules/") != -1 and file.endswith(".ko"): | ||
330 | return subprocess.call("%s'%s' --strip-debug --remove-section=.comment --remove-section=.note --preserve-dates '%s'" % (pathprefix, strip, file), shell=True) | ||
331 | |||
332 | newmode = None | 328 | newmode = None |
333 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): | 329 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): |
334 | origmode = os.stat(file)[stat.ST_MODE] | 330 | origmode = os.stat(file)[stat.ST_MODE] |
@@ -337,15 +333,14 @@ def runstrip(file, elftype, d): | |||
337 | 333 | ||
338 | extraflags = "" | 334 | extraflags = "" |
339 | 335 | ||
340 | # split_and_strip_files is calling this with elf_type None, causing: | 336 | # .so and shared library |
341 | # TypeError: unsupported operand type(s) for &: 'NoneType' and 'int' | 337 | if elftype & 16: |
342 | if elftype: | 338 | extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates" |
343 | # .so and shared library | 339 | elif ".so" in file and elftype & 8: |
344 | if ".so" in file and elftype & 8: | 340 | extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded" |
345 | extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded" | 341 | # shared or executable: |
346 | # shared or executable: | 342 | elif elftype & 8 or elftype & 4: |
347 | elif elftype & 8 or elftype & 4: | 343 | extraflags = "--remove-section=.comment --remove-section=.note" |
348 | extraflags = "--remove-section=.comment --remove-section=.note" | ||
349 | 344 | ||
350 | stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) | 345 | stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) |
351 | bb.debug(1, "runstrip: %s" % stripcmd) | 346 | bb.debug(1, "runstrip: %s" % stripcmd) |
@@ -749,6 +744,7 @@ python split_and_strip_files () { | |||
749 | # 2 - stripped | 744 | # 2 - stripped |
750 | # 4 - executable | 745 | # 4 - executable |
751 | # 8 - shared library | 746 | # 8 - shared library |
747 | # 16 - kernel module | ||
752 | def isELF(path): | 748 | def isELF(path): |
753 | type = 0 | 749 | type = 0 |
754 | pathprefix = "export PATH=%s; " % d.getVar('PATH', True) | 750 | pathprefix = "export PATH=%s; " % d.getVar('PATH', True) |
@@ -775,11 +771,16 @@ python split_and_strip_files () { | |||
775 | # | 771 | # |
776 | file_list = {} | 772 | file_list = {} |
777 | file_links = {} | 773 | file_links = {} |
774 | kernmods = [] | ||
778 | if (d.getVar('INHIBIT_PACKAGE_DEBUG_SPLIT', True) != '1') and \ | 775 | if (d.getVar('INHIBIT_PACKAGE_DEBUG_SPLIT', True) != '1') and \ |
779 | (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'): | 776 | (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'): |
780 | for root, dirs, files in os.walk(dvar): | 777 | for root, dirs, files in os.walk(dvar): |
781 | for f in files: | 778 | for f in files: |
782 | file = os.path.join(root, f) | 779 | file = os.path.join(root, f) |
780 | if file.endswith(".ko") and file.find("/lib/modules/") != -1: | ||
781 | kernmods.append(file) | ||
782 | continue | ||
783 | |||
783 | # Only process files (and symlinks)... Skip files that are obviously debug files | 784 | # Only process files (and symlinks)... Skip files that are obviously debug files |
784 | if not (debugappend != "" and file.endswith(debugappend)) and \ | 785 | if not (debugappend != "" and file.endswith(debugappend)) and \ |
785 | not (debugdir != "" and debugdir in os.path.dirname(file[len(dvar):])) and \ | 786 | not (debugdir != "" and debugdir in os.path.dirname(file[len(dvar):])) and \ |
@@ -910,14 +911,8 @@ python split_and_strip_files () { | |||
910 | elf_file = int(file_list[file][5:]) | 911 | elf_file = int(file_list[file][5:]) |
911 | #bb.note("Strip %s" % file) | 912 | #bb.note("Strip %s" % file) |
912 | runstrip(file, elf_file, d) | 913 | runstrip(file, elf_file, d) |
913 | 914 | for f in kernmods: | |
914 | 915 | runstrip(f, 16, d) | |
915 | if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'): | ||
916 | for root, dirs, files in os.walk(dvar): | ||
917 | for f in files: | ||
918 | if not f.endswith(".ko"): | ||
919 | continue | ||
920 | runstrip(os.path.join(root, f), 0, d) | ||
921 | # | 916 | # |
922 | # End of strip | 917 | # End of strip |
923 | # | 918 | # |