Changeset 1780

Show
Ignore:
Timestamp:
12/20/07 13:41:38 (1 year ago)
Author:
dsugar
Message:

fix problems with load libselinuxjava.so file
make it work like setools stuff is done.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libselinux.linux.x86/META-INF/MANIFEST.MF

    r1779 r1780  
    99Eclipse-PlatformFilter: (& (osgi.os=linux) (osgi.arch=x86)) 
    1010Require-Bundle: org.eclipse.core.runtime.compatibility 
    11 Bundle-ClassPath: libselinuxjava.jar 
    1211Export-Package: com.tresys.framework.compiler.linkage.libselinuxjava 
  • trunk/libselinux.linux.x86/build.properties

    r1779 r1780  
    1 source.libselinuxjava.jar = src/ 
    2 output.libselinuxjava.jar = bin/ 
     1source.. = src/ 
     2output.. = bin/ 
    33bin.includes = META-INF/,\ 
    4                libselinuxjava.jar,\ 
     4               .,\ 
    55               libselinuxjava/libselinuxjava.so 
    6 source.libselinuxjava.jar = src/ 
  • trunk/libselinux.linux.x86_64/META-INF/MANIFEST.MF

    r1779 r1780  
    1010Require-Bundle: org.eclipse.core.runtime.compatibility 
    1111Export-Package: com.tresys.framework.compiler.linkage.libselinuxjava 
    12 Bundle-ClassPath: libselinuxjava.jar 
  • trunk/libselinux.linux.x86_64/build.properties

    r1779 r1780  
    1 source.libselinuxjava.jar = src/ 
    2 output.libselinuxjava.jar = bin/ 
     1source.. = src/ 
     2output.. = bin/ 
    33bin.includes = META-INF/,\ 
    4                libselinuxjava.jar,\ 
     4               .,\ 
    55               libselinuxjava/libselinuxjava.so 
    6 source.libselinuxjava.jar = src/ 
  • trunk/libselinuxjava-plugin/META-INF/MANIFEST.MF

    r1779 r1780  
    1313 org.eclipse.core.runtime 
    1414Bundle-Activator: com.tresys.framework.compiler.linkage.libselinuxjava_plugin 
    15 Bundle-ClassPath: library.jar 
     15Bundle-ClassPath: libselinux.jar 
  • trunk/libselinuxjava-plugin/build.properties

    r1779 r1780  
    1 source.library.jar = src/ 
    2 output.library.jar = bin/ 
     1output.libselinux.jar = bin/ 
    32bin.includes = META-INF/,\ 
    4                library.jar,\ 
     3               libselinux.jar,\ 
    54               plugin.properties 
    65src.includes = .classpath,\ 
     
    98               build.properties,\ 
    109               src/ 
    11 jars.compile.order = library.jar 
    12 source.library.jar = src/ 
     10jars.compile.order = libselinux.jar 
     11source.libselinux.jar = src/ 
     12source.libselinux.jar = src/ 
    1313 
  • trunk/libselinuxjava-plugin/src/com/tresys/framework/compiler/linkage/libselinuxjava_plugin.java

    r1630 r1780  
    1111package com.tresys.framework.compiler.linkage; 
    1212 
     13import java.io.IOException; 
     14import java.net.URL; 
     15 
     16import org.eclipse.core.runtime.Platform; 
    1317import org.eclipse.core.runtime.Plugin; 
     18import org.eclipse.core.runtime.Status; 
     19import org.eclipse.jface.dialogs.MessageDialog; 
     20import org.eclipse.swt.widgets.Display; 
     21import org.eclipse.ui.PlatformUI; 
     22import org.osgi.framework.Bundle; 
    1423import org.osgi.framework.BundleContext; 
    1524 
     
    1726        extends Plugin 
    1827{ 
     28        // The plug-in ID 
     29        private static final String PLUGIN_ID = "com.tresys.libselinux"; 
    1930 
    2031        static private libselinuxjava_plugin m_default; 
     32        private boolean m_bIsLoaded = false; 
    2133         
    2234        public libselinuxjava_plugin () 
     
    3547        { 
    3648                super.start (context); 
     49                 
     50                loadLibs (context); 
    3751        } 
    3852         
     
    4458        } 
    4559 
     60        public boolean isLoaded () 
     61        { 
     62                return m_bIsLoaded; 
     63        } 
     64         
     65        /** 
     66         * Convenience method which returns the unique identifier of this plugin. 
     67         */ 
     68        public static String getUniqueIdentifier() 
     69        { 
     70                if (getDefault() == null) 
     71                { 
     72                        // If the default instance is not yet initialized, 
     73                        // return a static identifier. This identifier must 
     74                        // match the plugin id defined in plugin.xml 
     75                        return PLUGIN_ID; 
     76                } 
     77                return getDefault().getBundle().getSymbolicName(); 
     78        } 
     79 
     80        /** 
     81         * Check if a specific debugging option is turned on 
     82         * see http://wiki.eclipse.org/index.php/FAQ_How_do_I_use_the_platform_debug_tracing_facility%3F 
     83         * for more information and .options file in project for what is debugable 
     84         * settable in the launch configuration 'tracing' tab 
     85         * @param i_sDebugOption 
     86         * @return 
     87         */ 
     88        public boolean isDebugging (String i_sDebugOption) 
     89        { 
     90                if (!isDebugging ()) 
     91                        return false; 
     92                 
     93                String sOption = Platform.getDebugOption (getUniqueIdentifier () + i_sDebugOption); 
     94                return ("true".equals (sOption)); //$NON-NLS-1$ 
     95        } 
     96 
     97        private void loadLibs (BundleContext context) 
     98        { 
     99                        // list of libs to load.  On most systems will only need to load the last 4. 
     100                        // but, there are cases when the others are needed.  If they are there, load them 
     101                        // if not, don't worry about it. 
     102                String [] aLibs = {  
     103                                "selinuxjava"                   //$NON_NLS-1$ 
     104                        }; 
     105 
     106                for (int i = 0; i < aLibs.length; i++) 
     107                { 
     108                        try 
     109                        { 
     110                                String sLibName = "libselinuxjava/" + System.mapLibraryName (aLibs[i]); 
     111                                Bundle i_bundle = context.getBundle (); 
     112                                URL selinuxResource = i_bundle.getResource(sLibName);   //$NON-NLS-1$ 
     113                                String sPath = null; 
     114                                if (selinuxResource != null) 
     115                                        sPath = Platform.asLocalURL(selinuxResource).getPath(); 
     116                                 
     117                                if (sPath != null) 
     118                                { 
     119                                        System.load (sPath); 
     120                                        m_bIsLoaded = true; 
     121                                } 
     122                        } 
     123                        catch (UnsatisfiedLinkError ule) 
     124                        { 
     125                                Status status = new Status (Status.ERROR, getUniqueIdentifier (), "Unable to load lib: " + aLibs[i], ule); 
     126                                getLog ().log (status); 
     127                        } 
     128                        catch (IOException ioe) 
     129                        { 
     130                                Status status = new Status (Status.ERROR, getUniqueIdentifier (), "Unable to load lib: " + aLibs[i], ioe); 
     131                                getLog ().log (status); 
     132                        } 
     133                } 
     134                 
     135                if (!isLoaded ()) 
     136                { 
     137                        Display.getDefault().syncExec(  
     138                                new Runnable()  
     139                                {  
     140                                        public void run()  
     141                                        { 
     142                                                MessageDialog waitBox = new MessageDialog( 
     143                                                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), 
     144                                                                "Missing libselinuxjava", null, 
     145                                                                "Missing libselinuxjava, correct this problem before creating projects", 
     146                                                                MessageDialog.ERROR, new String[] { "OK"}, 1);                                                   
     147                 
     148                                                waitBox.open(); 
     149                                        } 
     150                                }); 
     151                         
     152                } 
     153        } 
     154         
     155 
    46156}