From: Nadav Har'El <n...@scylladb.com> Committer: Nadav Har'El <n...@scylladb.com> Branch: master
build: strip binaries in bootfs as well Before this patch, mkbootfs.py, unlike upload_manifest.py, did not do stripping. This was leading to unnecessary inflating of the bootfs. With this patch, shared objects copied to the bootfs are also stripped. As an example, the image created by "scripts/build image=httpserver" goes down from 17 MB to 16 MB. Fixes #667. Refs #820. Signed-off-by: Yuri Volchkov <iurii.volch...@neclab.eu> Signed-off-by: Nadav Har'El <n...@scylladb.com> --- diff --git a/scripts/mkbootfs.py b/scripts/mkbootfs.py --- a/scripts/mkbootfs.py +++ b/scripts/mkbootfs.py @@ -1,6 +1,6 @@ #!/usr/bin/python -import os, struct, optparse, io +import os, struct, optparse, io, subprocess try: import configparser except ImportError: @@ -52,6 +52,23 @@ def read_manifest(fn): for f in manifest.options('manifest')]) return files +def to_strip(filename): + ff = os.path.abspath(filename) + osvdir = os.path.abspath('../..') + return ff.startswith(os.getcwd()) or \ + ff.startswith(osvdir + "/modules") or \ + ff.startswith(osvdir + "/apps") + +def strip_file(filename): + stripped_filename = filename + if filename.endswith(".so") and to_strip(filename): + stripped_filename = filename[:-3] + "-stripped.so" + if not os.path.exists(stripped_filename) \ + or (os.path.getmtime(stripped_filename) < \ + os.path.getmtime(filename)): + subprocess.call(["strip", "-o", stripped_filename, filename]) + return stripped_filename + def main(): make_option = optparse.make_option @@ -90,6 +107,8 @@ def main(): files = read_manifest(options.manifest) files = list(expand(files.items())) files = [(x, unsymlink(y)) for (x, y) in files] + files = [(x, y) for (x, y) in files if not x.endswith("-stripped.so")] + files = [(x, strip_file(y)) for (x, y) in files] pos = (len(files) + 1) * metadata_size -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.