[jpackage-utils] Add OSGi provides generator.

Alexander Kurtakov akurtakov at fedoraproject.org
Tue May 31 12:38:52 UTC 2011


commit 6634c12d01a0057bf74b7416668cac6132e7bbec
Author: Alexander Kurtakov <akurtako at redhat.com>
Date:   Tue May 31 15:38:22 2011 +0300

    Add OSGi provides generator.

 jpackage-utils.spec |   13 ++++++++--
 osgi.attr           |    3 ++
 osgi.prov           |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 78 insertions(+), 3 deletions(-)
---
diff --git a/jpackage-utils.spec b/jpackage-utils.spec
index 08b0910..d115434 100644
--- a/jpackage-utils.spec
+++ b/jpackage-utils.spec
@@ -34,7 +34,7 @@
 
 Name:           jpackage-utils
 Version:        1.7.5
-Release:        4.12%{?dist}
+Release:        4.13%{?dist}
 Epoch:          0
 Summary:        JPackage utilities
 License:        BSD
@@ -45,6 +45,8 @@ Source2:        abs2rel.sh
 Source3:        abs2rel.lua
 Source4:        maven.prov
 Source5:        maven.attr
+Source6:        osgi.prov
+Source7:        osgi.attr
 Patch1:         %{name}-own-mavendirs.patch
 Patch2:         %{name}-prefer-jre.patch
 Patch3:         %{name}-set-classpath.patch
@@ -167,8 +169,10 @@ install -pm 644 xml/* ${RPM_BUILD_ROOT}${_javadir}-utils/xml
 
 # Add the provides script
 install -m0755 -D %{SOURCE4} $RPM_BUILD_ROOT%{_rpmconfigdir}/maven.prov
+install -m0755 -D %{SOURCE6} $RPM_BUILD_ROOT%{_rpmconfigdir}/osgi.prov
 # Add the maven poms file attribute entry (rpm >= 4.9.0)
 install -m0644 -D %{SOURCE5} $RPM_BUILD_ROOT%{_rpmconfigdir}/fileattrs/maven.attr
+install -m0644 -D %{SOURCE5} $RPM_BUILD_ROOT%{_rpmconfigdir}/fileattrs/osgi.attr
 
 cat <<EOF > %{name}-%{version}.files
 %{_bindir}/*
@@ -196,8 +200,8 @@ cat <<EOF > %{name}-%{version}.files
 %dir ${_mavendepmapdir}
 %dir ${_mavendepmapfragdir}
 ${_javadir}-utils/*
-%{_rpmconfigdir}/maven.prov
-%{_rpmconfigdir}/fileattrs/maven.attr
+%{_rpmconfigdir}/*.prov
+%{_rpmconfigdir}/fileattrs/*.attr
 %config %{_sysconfdir}/java/jpackage-release
 %config(noreplace) %{_sysconfdir}/java/java.conf
 %config(noreplace) %{_sysconfdir}/java/font.properties
@@ -211,6 +215,9 @@ EOF
 
 
 %changelog
+* Tue May 31 2011 Alexander Kurtakov <akurtako at redhat.com> 0:1.7.5-4.13
+- Add OSGi provides generator.
+
 * Fri Apr 15 2011 Alexander Kurtakov <akurtako at redhat.com> 0:1.7.5-4.12
 - Update to current guidelines.
 - Drop patch enabling gcj_support macro by default.
diff --git a/osgi.attr b/osgi.attr
new file mode 100644
index 0000000..bcfcb82
--- /dev/null
+++ b/osgi.attr
@@ -0,0 +1,3 @@
+%__maven_provides	%{_rpmconfigdir}/osgi.prov
+%__maven_path	^.*\.jar
+
diff --git a/osgi.prov b/osgi.prov
new file mode 100644
index 0000000..ca778de
--- /dev/null
+++ b/osgi.prov
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+
+## Copyright (C) 2011 Red Hat, Inc.
+## Author: Aleksandar Kurtakov <akurtako at redhat.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+import sys
+import os.path
+import zipfile
+from zipfile import ZipFile
+
+class OsgiProvideInfo:
+    
+    symbolicName = None
+    version = None
+    
+    def setSymbolicName(self, content):
+        self.symbolicName = content.split(";")[0].strip()
+        
+    def setVersion(self, content):
+        versions = content.split('.')[0:3]
+        self.version = ".".join(versions)
+        
+    def printProvide(self):
+        if self.version and self.symbolicName:
+            print "osgi(%s) = %s" %(self.symbolicName, self.version)
+
+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_provide (path)
+	  
+    def get_osgi_provide (self, path):
+        if not os.path.islink(path):
+            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()
+                    
+
+if __name__ == "__main__":
+    builder = TagBuilder ()


More information about the scm-commits mailing list