~ubuntu-branches/ubuntu/maverick/rxtx/maverick

« back to all changes in this revision

Viewing changes to contrib/MAcOSX/RXTXInstaller/Sources/gnu/io/installer/RXTXInstaller.java

  • Committer: Bazaar Package Importer
  • Author(s): Scott Howard
  • Date: 2010-06-03 23:19:16 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100603231916-8bapendemannfwau
Tags: 2.2pre2-1
* New upstream release:
  - Fixes JVM crash and UnsatisfiedLinkError/NoClassDefFoundError
    (Closes: #523139) (Closes: #489701)
  - Fixes amd64 support (Closes: #574395)
* Added debian/watch file
* Switched to source format 3.0 (quilt)
  - moved debian changes into patch in debian/patches
* Changed rules to use dh
* Fixed multiple lintian errors and multiple warnings
  - Policy version 3.8.4
* Section moved to java from libs
* Moved to team maintenance: Maintainer: Debian Java maintainers
  - Mario and I moved to uploaders
* DM Uploads Allowed: yes
* Build depends on javahelper
  - Binary depends on ${java:Depends}, use jh_installlibs for versioned
    install
  - Versioned naming of RXTXcomm.jar (Debian java policy)
* Added VCS tags to debian/control
* Libs now install in /usr/lib/jni instead of /usr/lib
* Added doc-base file

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package gnu.io.installer;
 
2
 
 
3
import java.io.File;
 
4
import java.util.Enumeration;
 
5
import java.util.prefs.*;
 
6
 
 
7
import gnu.io.installer.util.*;
 
8
 
 
9
 
 
10
public abstract class RXTXInstaller {
 
11
    
 
12
    static Preferences sysPref = Preferences.systemRoot();
 
13
    Preferences checkPref = null;
 
14
    protected File jarFolder,libFolder;
 
15
    InstallInstruction inst = new InstallInstruction();
 
16
    
 
17
    public abstract void runPreProcess(); 
 
18
    public abstract void runPostProcess(); 
 
19
    
 
20
    
 
21
    public void install(){
 
22
        initInstallation(RXTXInstaller.class);
 
23
        runPreProcess();
 
24
                if(inst != null){
 
25
                for(Enumeration e = inst.getKeys();e.hasMoreElements();){
 
26
                    File f = (File)e.nextElement();
 
27
                    InstallUtil.installPart(sysPref,checkPref,inst.getPath(f),f);
 
28
                }
 
29
        }
 
30
        runPostProcess();
 
31
        finishInstallation();
 
32
    }
 
33
    
 
34
    protected void finishInstallation(){
 
35
        if(checkPref == null) return;
 
36
                try{
 
37
                    checkPref.removeNode();
 
38
                }catch(Throwable t){}
 
39
    }
 
40
    
 
41
    public InstallInstruction getInstallInstruction(){
 
42
        return inst;
 
43
    }
 
44
    
 
45
    public static RXTXInstaller getInstance() {
 
46
        String osName = System.getProperty("os.name").toLowerCase();
 
47
        if(osName.startsWith("mac")){
 
48
            return new gnu.io.installer.macosx.MACOSXRXTXInstaller();
 
49
        }
 
50
        return null;
 
51
    }
 
52
 
 
53
    protected void initInstallation(Class rootClass){
 
54
        checkPref = null;
 
55
        if(rootClass == null) return;
 
56
        try{
 
57
            Preferences.importPreferences(rootClass.getResourceAsStream("installer.pref"));
 
58
            String checkPrefName = "/check";
 
59
            checkPref = (sysPref.nodeExists(checkPrefName))?sysPref.node(checkPrefName):null;
 
60
        }catch(Throwable t){
 
61
            checkPref = null;
 
62
            System.out.println("Throwable "+t);
 
63
        }
 
64
    }
 
65
 
 
66
    public void addLibResource(String path,String resource){
 
67
        if(libFolder == null || path == null || resource == null) return;
 
68
        File libFile = new File(libFolder,path);
 
69
        addResource(libFile,resource);
 
70
    }
 
71
    
 
72
    public void addJarResource(String path,String resource){
 
73
        if(jarFolder == null || path == null || resource == null) return;
 
74
        File jarFile = new File(jarFolder,path);
 
75
        addResource(jarFile,resource);
 
76
    }
 
77
 
 
78
    public void addResource(File path,String resource){
 
79
        if(inst == null) inst = new InstallInstruction();
 
80
        inst.addResource(path,resource);
 
81
    }
 
82
    
 
83
    public static void main(String args[]) {
 
84
        RXTXInstaller installer = RXTXInstaller.getInstance();
 
85
        if(installer != null) installer.install();
 
86
    }
 
87
    
 
88
}
 
89