2 # -*- coding: utf-8 -*-
4 ## This utility takes the debian directory from an unpacked debian mono source
5 ## tree (e.g. apt-get source mono), parses the *.install files and generates a
6 ## bitbake include file with the file and package lists. It tries to handle -dbg
7 ## packages by creating additional glob patterns for *.mdb and */.debug/*. Most
8 ## of these will not match, but that's fine (I think).
9 ## -- Henryk Plötz <henryk@openmoko.org>
11 ##The output looks like:
12 ##FILES_mono-jit-dbg = "/usr/bin/mono*.mdb \
13 ## /usr/bin/mono*/*.mdb"
14 ##FILES_mono-jit = "/usr/bin/mono"
15 ##FILES_mono-gac-dbg = "/usr/bin/gacutil*.mdb \
16 ## /usr/bin/gacutil*/*.mdb \
17 ## /usr/lib/mono/1.0/gacutil.exe*.mdb \
18 ## /usr/lib/mono/1.0/gacutil.exe*/*.mdb"
19 ##FILES_mono-gac = "/usr/bin/gacutil \
20 ## /usr/lib/mono/1.0/gacutil.exe"
22 ##PACKAGES = "mono-jit-dbg \
30 def collect_paths(dir):
34 for filename in os.listdir("."):
35 if filename.endswith(".install"):
36 fp = file(filename, "r")
37 lines = fp.readlines()
43 if line.startswith("#"): continue
44 if line == "": continue
46 lineparts = line.split()
47 if lineparts[0].startswith("debian/tmp"):
48 pattern = lineparts[0][ len("debian/tmp"): ]
49 if len(lineparts) == 2:
50 if not pattern.startswith(lineparts[1]):
51 print >>sys.stderr, "Warning: Apparently I don't fully understand the format in file %s" % filename
52 elif len(lineparts) > 2:
53 print >>sys.stderr, "Warning: Apparently I don't fully understand the format in file %s" % filename
55 contents.append( pattern )
57 print >>sys.stderr, "Note: Ignoring %s in %s" % (lineparts, filename)
59 paths[ filename[ :-len(".install") ] ] = contents
63 def collect_packages(paths):
64 # These packages should be populated first (e.g. because their files will otherwise end up
66 PACKAGES_FIRST = ("mono-jit", "mono-gac", "mono-mjs", "mono-gmcs", "mono-utils", "mono-doc")
67 # These should be populated last (because their spec is very broad)
68 PACKAGES_LAST = ("mono-mcs", "libmono-system1.0-cil", "libmono-system2.0-cil", "libmono1.0-cil", "libmono2.0-cil")
71 packages = paths.keys()
72 for packagename in PACKAGES_FIRST + PACKAGES_LAST:
73 if packagename in packages:
74 packages.remove(packagename)
75 if packagename in PACKAGES_FIRST:
76 first.append(packagename)
78 last.append(packagename)
79 packagenames = first + packages + last
81 return packagenames, paths
83 def debugify(packagenames, paths):
85 for pkg in packagenames:
86 if not pkg.endswith("-dbg"):
88 for path in paths[pkg]:
89 if not path.endswith("*"):
90 result.append(path + "*.mdb")
91 result.append(path + "*/*.mdb")
93 result.append(path + ".mdb")
94 result.append(path + "/*.mdb")
95 if path.endswith("/"):
96 result.append(path + ".debug/")
97 result.append(path + "../.debug/")
98 paths[pkg + "-dbg"] = result
99 pnames.append(pkg + "-dbg")
103 if __name__ == "__main__":
104 packagenames, paths = collect_packages( collect_paths(".") )
105 packagenames, paths = debugify(packagenames, paths)
107 print "# This is a generated file, please do not edit directly"
108 print "# Use collect-files.py instead. -- Henryk <henryk@openmoko.org>"
111 for pkg in packagenames:
112 if not paths[pkg]: continue
114 print 'FILES_%s = "%s"' % (pkg, " \\\n\t".join(paths[pkg]))
118 print 'PACKAGES = "%s"' % (" \\\n\t".join(packages))