From 981fed49ee80560fb067b3f47aeada1fdee792ca Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 1 Feb 2013 15:03:41 +0000 Subject: package: Process package stripping in parallel Signed-off-by: Richard Purdie --- meta/lib/oe/package.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'meta/lib/oe') 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 @@ +def runstrip(arg): + # Function to strip a single file, called from split_and_strip_files below + # A working 'file' (one which works on the target architecture) + # + # The elftype is a bit pattern (explained in split_and_strip_files) to tell + # us what type of file we're processing... + # 4 - executable + # 8 - shared library + # 16 - kernel module + + import commands, stat, subprocess + + (file, elftype, strip) = arg + + newmode = None + if not os.access(file, os.W_OK) or os.access(file, os.R_OK): + origmode = os.stat(file)[stat.ST_MODE] + newmode = origmode | stat.S_IWRITE | stat.S_IREAD + os.chmod(file, newmode) + + extraflags = "" + + # kernel module + if elftype & 16: + extraflags = "--strip-debug --remove-section=.comment --remove-section=.note --preserve-dates" + # .so and shared library + elif ".so" in file and elftype & 8: + extraflags = "--remove-section=.comment --remove-section=.note --strip-unneeded" + # shared or executable: + elif elftype & 8 or elftype & 4: + extraflags = "--remove-section=.comment --remove-section=.note" + + stripcmd = "'%s' %s '%s'" % (strip, extraflags, file) + bb.debug(1, "runstrip: %s" % stripcmd) + + ret = subprocess.call(stripcmd, shell=True) + + if newmode: + os.chmod(file, origmode) + + if ret: + bb.error("runstrip: '%s' strip command failed" % stripcmd) + + return + def file_translate(file): ft = file.replace("@", "@at@") -- cgit 1.2.3-korg