Author: jm
Date: 2011-05-31 12:31:15 -0700 (Tue, 31 May 2011)
New Revision: 25602

Added:
   csplugins/trunk/toronto/jm/repacker/deploy.sh
   csplugins/trunk/toronto/jm/repacker/genheaders.py
   csplugins/trunk/toronto/jm/repacker/repack.sh
   csplugins/trunk/toronto/jm/repacker/wrap.sh
Log:
Added scripts for repacking JAR files with native code into OSGi bundles


Added: csplugins/trunk/toronto/jm/repacker/deploy.sh
===================================================================
--- csplugins/trunk/toronto/jm/repacker/deploy.sh                               
(rev 0)
+++ csplugins/trunk/toronto/jm/repacker/deploy.sh       2011-05-31 19:31:15 UTC 
(rev 25602)
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+GROUP_ID=$1
+VERSION=$2
+
+for FILE in bundles/*.jar
+do
+    ARTIFACT_ID=`basename ${FILE} .jar`
+    mvn install:install-file -Dfile=${FILE} -DgroupId=${GROUP_ID} 
-DartifactId=${ARTIFACT_ID} -Dversion=${VERSION} -Dpackaging=jar
+done


Property changes on: csplugins/trunk/toronto/jm/repacker/deploy.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: csplugins/trunk/toronto/jm/repacker/genheaders.py
===================================================================
--- csplugins/trunk/toronto/jm/repacker/genheaders.py                           
(rev 0)
+++ csplugins/trunk/toronto/jm/repacker/genheaders.py   2011-05-31 19:31:15 UTC 
(rev 25602)
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+import re
+import sys
+from zipfile import ZipFile
+
+patterns = [
+    [re.compile('lib(.+)[.](dylib|jnilib)'), 'mac os x'],
+    [re.compile('lib(.+)[.]so'), 'linux'],
+    [re.compile('lib(.+)[.]dll'), 'win32'],
+]
+
+def generate_headers(name, fragment_host):
+    zip = ZipFile(name, 'r')
+    processors = ['x86-64', 'x86']
+    platforms = {}
+    for entry in zip.namelist():
+        for pattern, platform in patterns:
+            matcher = pattern.match(entry)
+            if matcher:
+                if platform not in platforms:
+                    entries = []
+                    platforms[platform] = entries
+                else:
+                    entries = platforms[platform]
+                entries.append(entry)
+                break
+    if len(platforms) == 0:
+        return
+    
+    platform_entries = []
+    for processor in processors:
+        for platform, entries in platforms.items():
+            platform_entries.append('%s;osname=%s;processor=%s' % 
(';'.join(entries), platform, processor))
+    
+    properties = open('%s.properties' % name, 'w')
+    print >> properties, 'Bundle-NativeCode=%s' % ','.join(platform_entries + 
['*'])
+    print >> properties, 'Fragment-Host=%s' % fragment_host
+    properties.close()
+    
+if __name__ == '__main__':
+    if len(sys.argv) > 2:
+        name = sys.argv[1]
+        fragment_host = sys.argv[2]    
+        generate_headers(name, fragment_host)


Property changes on: csplugins/trunk/toronto/jm/repacker/genheaders.py
___________________________________________________________________
Added: svn:executable
   + *

Added: csplugins/trunk/toronto/jm/repacker/repack.sh
===================================================================
--- csplugins/trunk/toronto/jm/repacker/repack.sh                               
(rev 0)
+++ csplugins/trunk/toronto/jm/repacker/repack.sh       2011-05-31 19:31:15 UTC 
(rev 25602)
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+BUNDLE_NAME=$1
+shift
+
+rm -rf temp-all temp-natives
+mkdir -p temp-all
+mkdir -p temp-natives
+
+pushd temp-all
+for JAR in "$@"
+do
+    unzip -o "../${JAR}"
+done
+mv lib*.* ../temp-natives
+
+jar cvf ../${BUNDLE_NAME}.jar *
+popd
+
+
+pushd temp-natives
+jar cvf ../${BUNDLE_NAME}-natives.jar *
+popd
+
+rm -rf bundles
+mkdir -p bundles
+./wrap.sh
\ No newline at end of file


Property changes on: csplugins/trunk/toronto/jm/repacker/repack.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: csplugins/trunk/toronto/jm/repacker/wrap.sh
===================================================================
--- csplugins/trunk/toronto/jm/repacker/wrap.sh                         (rev 0)
+++ csplugins/trunk/toronto/jm/repacker/wrap.sh 2011-05-31 19:31:15 UTC (rev 
25602)
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+BND_CMD=bnd
+
+for FILE in *.jar
+do
+    FRAGMENT_HOST=$(basename ${FILE} -natives.jar)
+    echo ${FRAGMENT_HOST}
+    ./genheaders.py ${FILE} ${FRAGMENT_HOST}
+    if [ -f "${FILE}.properties" ]
+    then
+        ${BND_CMD} wrap -properties "${FILE}.properties" "${FILE}"
+    else
+        ${BND_CMD} wrap "${FILE}"
+    fi
+done
+
+mkdir -p bundles
+for FILE in *.bar
+do
+    mv "${FILE}" "bundles/$(basename ${FILE} .bar).jar"
+done


Property changes on: csplugins/trunk/toronto/jm/repacker/wrap.sh
___________________________________________________________________
Added: svn:executable
   + *

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to