Signed-off-by: geraldo netto <geraldone...@gmail.com>
---
 scripts/mkbootfs.py | 70 ++++++++---------------------------------------------
 1 file changed, 10 insertions(+), 60 deletions(-)

diff --git a/scripts/mkbootfs.py b/scripts/mkbootfs.py
index 94835e9..f6ad663 100755
--- a/scripts/mkbootfs.py
+++ b/scripts/mkbootfs.py
@@ -5,65 +5,15 @@ try:
     import configparser
 except ImportError:
     import ConfigParser as configparser
+try:
+    import manifest_common
+except Exception, ex:
+    sys.exit(str(ex))
 
-defines = {}
-def add_var(option, opt, value, parser):
-    var, val = value.split('=')
-    defines[var] = val
-
-def expand(items):
-    for name, hostname in items:
-        if name.endswith('/**') and hostname.endswith('/**'):
-            name = name[:-2]
-            hostname = hostname[:-2]
-            for dirpath, dirnames, filenames in os.walk(hostname):
-                for filename in filenames:
-                    relpath = dirpath[len(hostname):]
-                    if relpath != "":
-                        relpath += "/"
-                    yield (name + relpath + filename,
-                           hostname + relpath + filename)
-        elif '/&/' in name and hostname.endswith('/&'):
-            prefix, suffix = name.split('/&/', 1)
-            yield (prefix + '/' + suffix, hostname[:-1] + suffix)
-        else:
-            yield (name, hostname)
-
-def unsymlink(f):
-    if f.startswith('!'):
-        f = f[1:]
-    try:
-        link = os.readlink(f)
-        if link.startswith('/'):
-            # try to find a match
-            base = os.path.dirname(f)
-            while not os.path.exists(base + link):
-                base = os.path.dirname(base)
-        else:
-            base = os.path.dirname(f) + '/'
-        return unsymlink(base + link)
-    except Exception:
-        return f
-
-def read_manifest(fn):
-    manifest = configparser.SafeConfigParser()
-    manifest.optionxform = str # avoid lowercasing
-    manifest.read(fn)
-
-    files = dict([(f, manifest.get('manifest', f, vars=defines))
-                  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):
+    if filename.endswith(".so") and manifest_common.strip_file(filename):
         stripped_filename = filename[:-3] + "-stripped.so"
         if not os.path.exists(stripped_filename) \
                 or (os.path.getmtime(stripped_filename) < \
@@ -93,7 +43,7 @@ def main():
                         help='define VAR=DATA',
                         metavar='VAR=DATA',
                         action='callback',
-                        callback=add_var),
+                        callback=manifest_common.add_var),
     ])
 
     (options, args) = opt.parse_args()
@@ -104,12 +54,12 @@ def main():
     if options.depends:
         depends = open(options.depends, 'w')
     out = open(options.output, 'wb')
-    
+
     depends.write(u'%s: \\\n' % (options.output,))
 
-    files = read_manifest(options.manifest)
-    files = list(expand(files.items()))
-    files = [(x, unsymlink(y)) for (x, y) in files]
+    files = manifest_common.read_manifest(options.manifest)
+    files = list(manifest_common.expand(files))
+    files = [(x, manifest_common.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]
 
-- 
2.7.4

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