commit d8448da5a7e9f5f831a57ec4ecc51b46b8d49e74
Author: Alexander Kurtakov <akurtako(a)redhat.com>
Date: Wed Jun 29 13:09:02 2011 +0300
Add exploded OSGi bundles provides generation.
Add requires generator - disabled for now.
depgenerators/fileattrs/osgi.attr | 3 +-
depgenerators/osgi.prov | 24 +++++++---
depgenerators/osgi.req | 88 +++++++++++++++++++++++++++++++++++++
3 files changed, 106 insertions(+), 9 deletions(-)
---
diff --git a/depgenerators/fileattrs/osgi.attr b/depgenerators/fileattrs/osgi.attr
index 78ae38b..31690bd 100644
--- a/depgenerators/fileattrs/osgi.attr
+++ b/depgenerators/fileattrs/osgi.attr
@@ -1,3 +1,4 @@
%__osgi_provides %{_rpmconfigdir}/osgi.prov
-%__osgi_path ^.*\.jar
+#%__osgi_requires %{_rpmconfigdir}/osgi.req
+%__osgi_path ^(.*\.jar|((%{_libdir}|%{_datadir}).*/MANIFEST.MF))
diff --git a/depgenerators/osgi.prov b/depgenerators/osgi.prov
old mode 100644
new mode 100755
index 9bb70de..2548adf
--- a/depgenerators/osgi.prov
+++ b/depgenerators/osgi.prov
@@ -58,19 +58,27 @@ class TagBuilder:
paths = map (lambda x: x.rstrip (), filelist.readlines ())
for path in paths:
self.get_osgi_provide (path)
-
+
+
+ def handle_manifest(self, manifest):
+ provideInfo = OsgiProvideInfo()
+ for line in manifest.readlines():
+ if line.startswith("Bundle-SymbolicName:"):
+ provideInfo.setSymbolicName(line.split(':')[1].strip())
+ if line.startswith("Bundle-Version:"):
+ provideInfo.setVersion(line.split(':')[1].strip())
+
+ provideInfo.printProvide()
+
def get_osgi_provide (self, path):
if not os.path.islink(path):
+ if path.endswith("META-INF/MANIFEST.MF"):
+ manifest = open(path)
+ self.handle_manifest(manifest)
if zipfile.is_zipfile(path):
jarfile = ZipFile(path)
manifest = jarfile.open("META-INF/MANIFEST.MF")
- provideInfo = OsgiProvideInfo()
- for line in manifest.readlines():
- if line.startswith("Bundle-SymbolicName:"):
- provideInfo.setSymbolicName(line.split(':')[1].strip())
- if line.startswith("Bundle-Version:"):
- provideInfo.setVersion(line.split(':')[1].strip())
- provideInfo.printProvide()
+ self.handle_manifest(manifest)
if __name__ == "__main__":
diff --git a/depgenerators/osgi.req b/depgenerators/osgi.req
new file mode 100755
index 0000000..0ad2a75
--- /dev/null
+++ b/depgenerators/osgi.req
@@ -0,0 +1,88 @@
+#!/usr/bin/python
+
+# Copyright (c) 2011, Red Hat, Inc
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+# * Neither the name of the <ORGANIZATION> nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Authors: Alexander Kurtakov <akurtako(a)redhat.com>
+
+import sys
+import os.path
+import zipfile
+from zipfile import ZipFile
+
+class TagBuilder:
+
+ def __init__ (self, filelist=None):
+ if filelist == None:
+ filelist = sys.stdin
+ paths = map (lambda x: x.rstrip (), filelist.readlines ())
+ for path in paths:
+ self.get_osgi_require (path)
+
+ def parse_manifest (self, manifest):
+ headers = {}
+ DELIM = ": "
+ name = None
+ for line in manifest.readlines():
+ split = line.split(DELIM)
+ if not name:
+ name = split[0].strip()
+ headers[name]= split[1].strip()
+ else:
+ if len(split) < 2:
+ headers[name] = headers[name]+line.strip()
+ else:
+ name = split[0].strip()
+ headers[name]= split[1].strip()
+ return headers
+
+ def split_bundle_name (self, bundles):
+ bundlenames = []
+ for bundle in bundles.split(','):
+ if ")" in bundle or "]" in bundle >0:
+ continue
+ if ";" in bundle:
+ bundlenames.append(bundle.split(";")[0].strip())
+ else:
+ bundlenames.append(bundle)
+
+ return bundlenames
+
+
+
+ def get_osgi_require (self, path):
+ if not os.path.islink(path):
+ if zipfile.is_zipfile(path):
+ jarfile = ZipFile(path)
+ manifest = jarfile.open("META-INF/MANIFEST.MF")
+ headers = self.parse_manifest(manifest)
+ if headers.get("Require-Bundle"):
+ for bundle in self.split_bundle_name(headers.get("Require-Bundle")):
+ print "osgi(%s)" %(bundle)
+
+if __name__ == "__main__":
+ builder = TagBuilder ()