upload_manifest stripped only binaries in the build/ directory, so
binaries in modules, such as modules/httpserver/libhttpserver.so were
not stripped. Arguably, each module's Makefile could strip its own
results, but it's convenient to keep both the unstripped binary (for
debugging) and stripped one (for the image). So this patch extends to
modules/ and apps/ the already existing mechanism which when uploading
a file something.so, strips it into something-stripped.so and uploads
that.

With this patch, the image generated by "scripts/build image=httpserver"
is reduced from 25 MB to 19 MB.

Refs #822

Signed-off-by: Yuri Volchkov <iurii.volch...@neclab.eu>
Signed-off-by: Nadav Har'El <n...@scylladb.com>
---
 scripts/upload_manifest.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/scripts/upload_manifest.py b/scripts/upload_manifest.py
index c5c8202..ae96f9f 100755
--- a/scripts/upload_manifest.py
+++ b/scripts/upload_manifest.py
@@ -118,10 +118,16 @@ def upload(osv, manifest, depends):
                 + cpio_field(0, 8)                # check
                 + filename + b'\0')
 
+    def to_strip(filename):
+        ff = os.path.abspath(filename);
+        osvdir = os.path.abspath('../..');
+        return filename.startswith(os.getcwd()) or \
+            filename.startswith(osvdir + "/modules") or \
+            filename.startswith(osvdir + "/apps")
+
     def strip_file(filename):
         stripped_filename = filename
-        if filename.endswith(".so") and \
-                (filename[0] != "/" or filename.startswith(os.getcwd())):
+        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) < \
@@ -138,6 +144,8 @@ def upload(osv, manifest, depends):
             cpio_send(link.encode())
         else:
             depends.write('\t%s \\\n' % (hostname,))
+            if hostname.endswith("-stripped.so"):
+                continue
             hostname = strip_file(hostname)
             if os.path.islink(hostname):
                 perm = os.lstat(hostname).st_mode & 0o777
-- 
2.9.3

-- 
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.

Reply via email to