diff options
| -rw-r--r-- | meta/classes/package.bbclass | 58 | ||||
| -rw-r--r-- | meta/lib/oe/package.py | 45 |
2 files changed, 58 insertions, 45 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass index d93783f83b..61d90cc12e 100644 --- a/meta/classes/package.bbclass +++ b/meta/classes/package.bbclass | |||
| @@ -309,49 +309,6 @@ def copydebugsources(debugsrcdir, d): | |||
| 309 | if os.path.exists(p) and not os.listdir(p): | 309 | if os.path.exists(p) and not os.listdir(p): |
| 310 | os.rmdir(p) | 310 | os.rmdir(p) |
| 311 | 311 | ||
| 312 | def runstrip(file, elftype, d): | ||
| 313 | # Function to strip a single file, called from split_and_strip_files below | ||
| 314 | # A working 'file' (one which works on the target architecture) | ||
| 315 | # | ||
| 316 | # The elftype is a bit pattern (explained in split_and_strip_files) to tell | ||
| 317 | # us what type of file we're processing... | ||
| 318 | # 4 - executable | ||
| 319 | # 8 - shared library | ||
| 320 | |||
| 321 | import commands, stat, subprocess | ||
| 322 | |||
| 323 | strip = d.getVar("STRIP", True) | ||
| 324 | |||
| 325 | newmode = None | ||
| 326 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): | ||
| 327 | origmode = os.stat(file)[stat.ST_MODE] | ||
| 328 | newmode = origmode | stat.S_IWRITE | stat.S_IREAD | ||
| 329 | os.chmod(file, newmode) | ||
| 330 | |||
| 331 | extraflags = "" | ||
| 332 | |||
| 333 | # .so and shared library | ||
| 334 | if elftype & 16: | ||
| 335 | extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates" | ||
| 336 | elif ".so" in file and elftype & 8: | ||
| 337 | extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded" | ||
| 338 | # shared or executable: | ||
| 339 | elif elftype & 8 or elftype & 4: | ||
| 340 | extraflags = "--remove-section=.comment --remove-section=.note" | ||
| 341 | |||
| 342 | stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) | ||
| 343 | bb.debug(1, "runstrip: %s" % stripcmd) | ||
| 344 | |||
| 345 | ret = subprocess.call(stripcmd, shell=True) | ||
| 346 | |||
| 347 | if newmode: | ||
| 348 | os.chmod(file, origmode) | ||
| 349 | |||
| 350 | if ret: | ||
| 351 | bb.error("runstrip: '%s' strip command failed" % stripcmd) | ||
| 352 | |||
| 353 | return 0 | ||
| 354 | |||
| 355 | # | 312 | # |
| 356 | # Package data handling routines | 313 | # Package data handling routines |
| 357 | # | 314 | # |
| @@ -902,13 +859,24 @@ python split_and_strip_files () { | |||
| 902 | # Now lets go back over things and strip them | 859 | # Now lets go back over things and strip them |
| 903 | # | 860 | # |
| 904 | if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'): | 861 | if (d.getVar('INHIBIT_PACKAGE_STRIP', True) != '1'): |
| 862 | strip = d.getVar("STRIP", True) | ||
| 863 | sfiles = [] | ||
| 905 | for file in file_list: | 864 | for file in file_list: |
| 906 | if file_list[file].startswith("ELF: "): | 865 | if file_list[file].startswith("ELF: "): |
| 907 | elf_file = int(file_list[file][5:]) | 866 | elf_file = int(file_list[file][5:]) |
| 908 | #bb.note("Strip %s" % file) | 867 | #bb.note("Strip %s" % file) |
| 909 | runstrip(file, elf_file, d) | 868 | sfiles.append((file, elf_file, strip)) |
| 910 | for f in kernmods: | 869 | for f in kernmods: |
| 911 | runstrip(f, 16, d) | 870 | sfiles.append((f, 16, strip)) |
| 871 | |||
| 872 | |||
| 873 | import multiprocessing | ||
| 874 | nproc = multiprocessing.cpu_count() | ||
| 875 | pool = multiprocessing.Pool(nproc) | ||
| 876 | processed = pool.imap(oe.package.runstrip, sfiles) | ||
| 877 | pool.close() | ||
| 878 | pool.join() | ||
| 879 | |||
| 912 | # | 880 | # |
| 913 | # End of strip | 881 | # End of strip |
| 914 | # | 882 | # |
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py index 6b1c1f48ce..9a0ddb8536 100644 --- a/meta/lib/oe/package.py +++ b/meta/lib/oe/package.py | |||
| @@ -1,3 +1,48 @@ | |||
| 1 | def runstrip(arg): | ||
| 2 | # Function to strip a single file, called from split_and_strip_files below | ||
| 3 | # A working 'file' (one which works on the target architecture) | ||
| 4 | # | ||
| 5 | # The elftype is a bit pattern (explained in split_and_strip_files) to tell | ||
| 6 | # us what type of file we're processing... | ||
| 7 | # 4 - executable | ||
| 8 | # 8 - shared library | ||
| 9 | # 16 - kernel module | ||
| 10 | |||
| 11 | import commands, stat, subprocess | ||
| 12 | |||
| 13 | (file, elftype, strip) = arg | ||
| 14 | |||
| 15 | newmode = None | ||
| 16 | if not os.access(file, os.W_OK) or os.access(file, os.R_OK): | ||
| 17 | origmode = os.stat(file)[stat.ST_MODE] | ||
| 18 | newmode = origmode | stat.S_IWRITE | stat.S_IREAD | ||
| 19 | os.chmod(file, newmode) | ||
| 20 | |||
| 21 | extraflags = "" | ||
| 22 | |||
| 23 | # kernel module | ||
| 24 | if elftype & 16: | ||
| 25 | extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates" | ||
| 26 | # .so and shared library | ||
| 27 | elif ".so" in file and elftype & 8: | ||
| 28 | extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded" | ||
| 29 | # shared or executable: | ||
| 30 | elif elftype & 8 or elftype & 4: | ||
| 31 | extraflags = "--remove-section=.comment --remove-section=.note" | ||
| 32 | |||
| 33 | stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) | ||
| 34 | bb.debug(1, "runstrip: %s" % stripcmd) | ||
| 35 | |||
| 36 | ret = subprocess.call(stripcmd, shell=True) | ||
| 37 | |||
| 38 | if newmode: | ||
| 39 | os.chmod(file, origmode) | ||
| 40 | |||
| 41 | if ret: | ||
| 42 | bb.error("runstrip: '%s' strip command failed" % stripcmd) | ||
| 43 | |||
| 44 | return | ||
| 45 | |||
| 1 | 46 | ||
| 2 | def file_translate(file): | 47 | def file_translate(file): |
| 3 | ft = file.replace("@", "@at@") | 48 | ft = file.replace("@", "@at@") |
