[izpack-changes] r1972 - in izpack-src/trunk: . src/lib/com/izforge/izpack/rules src/lib/com/izforge/izpack/util

noreply at berlios.de noreply at berlios.de
Fri Dec 28 14:11:02 CET 2007


Author: jponge
Date: 2007-12-28 14:10:49 +0100 (Fri, 28 Dec 2007)
New Revision: 1972

Modified:
   izpack-src/trunk/IzPack-head.ipr
   izpack-src/trunk/Versions.txt
   izpack-src/trunk/src/lib/com/izforge/izpack/rules/RulesEngine.java
   izpack-src/trunk/src/lib/com/izforge/izpack/util/OsVersion.java
   izpack-src/trunk/src/lib/com/izforge/izpack/util/OsVersionConstants.java
Log:
- OsVersion class: detect X86, PPC and SPARC architectures (Julien Ponge)
- RulesEngines: new built-in rules: izpack.solarisinstall.x86 and izpack.solarisinstall.sparc (Julien Ponge)

Modified: izpack-src/trunk/IzPack-head.ipr
===================================================================
--- izpack-src/trunk/IzPack-head.ipr	2007-12-21 18:35:56 UTC (rev 1971)
+++ izpack-src/trunk/IzPack-head.ipr	2007-12-28 13:10:49 UTC (rev 1972)
@@ -246,7 +246,7 @@
       <module fileurl="file://$PROJECT_DIR$/IzPack-head.iml" filepath="$PROJECT_DIR$/IzPack-head.iml" />
     </modules>
   </component>
-  <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="false" project-jdk-name="1.6" project-jdk-type="JavaSDK" />
+  <component name="ProjectRootManager" version="2" assert-keyword="true" jdk-15="false" project-jdk-name="1.5" project-jdk-type="JavaSDK" />
   <component name="ResourceManagerContainer">
     <option name="myResourceBundles">
       <value>

Modified: izpack-src/trunk/Versions.txt
===================================================================
--- izpack-src/trunk/Versions.txt	2007-12-21 18:35:56 UTC (rev 1971)
+++ izpack-src/trunk/Versions.txt	2007-12-28 13:10:49 UTC (rev 1972)
@@ -74,6 +74,8 @@
 - Support of XInclude-like constructs (Matthew Fudge, Volantis Systems Ltd.
   via Julien Ponge)
 - Spanish langpack update (Sergio Banos Calvo via Julien Ponge)
+- OsVersion class: detect X86, PPC and SPARC architectures (Julien Ponge)
+- RulesEngines: new built-in rules: izpack.solarisinstall.x86 and izpack.solarisinstall.sparc (Julien Ponge)
   
   > 3.10.2 (build 2007.05.11)
 

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/rules/RulesEngine.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/rules/RulesEngine.java	2007-12-21 18:35:56 UTC (rev 1971)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/rules/RulesEngine.java	2007-12-28 13:10:49 UTC (rev 1972)
@@ -64,6 +64,8 @@
         createBuiltinOsCondition("IS_LINUX", "izpack.linuxinstall");
         createBuiltinOsCondition("IS_SUNOS", "izpack.solarisinstall");
         createBuiltinOsCondition("IS_MAC", "izpack.macinstall");
+        createBuiltinOsCondition("IS_SUNOS_X86", "izpack.solarisinstall.x86");
+        createBuiltinOsCondition("IS_SUNOS_sparc", "izpack.solarisinstall.sparc");
 
         if ((installdata != null) && (installdata.allPacks != null))
         {

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/util/OsVersion.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/util/OsVersion.java	2007-12-21 18:35:56 UTC (rev 1971)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/util/OsVersion.java	2007-12-28 13:10:49 UTC (rev 1972)
@@ -22,74 +22,139 @@
 
 /**
  * This is a convienient class, which helps you to detect / identify the running OS/Distribution
- * 
+ * <p/>
  * Created at: Date: Nov 9, 2004 Time: 8:53:22 PM
- * 
+ *
  * @author hani, Marc.Eppelmann&#064;reddot.de
  */
-public final class OsVersion implements OsVersionConstants, StringConstants
-{
+public final class OsVersion implements OsVersionConstants, StringConstants {
 
     //~ Static fields/initializers
     // *******************************************************************************************************************************
 
-    /** OS_NAME = System.getProperty( "os.name" ) */
-    public static final String OS_NAME = System.getProperty( OSNAME );
+    /**
+     * OS_NAME = System.getProperty( "os.name" )
+     */
+    public static final String OS_NAME = System.getProperty(OSNAME);
 
-    /** True if this is FreeBSD. */
-    public static final boolean IS_FREEBSD = StringTool.startsWithIgnoreCase(OS_NAME, FREEBSD );
+    /**
+     * OS_ARCH = System.getProperty("os.arch")
+     */
+    public static final String OS_ARCH = System.getProperty(OSARCH);
 
-    /** True if this is Linux. */
-    public static final boolean IS_LINUX = StringTool.startsWithIgnoreCase(OS_NAME, LINUX );
+    /**
+     * True if the processor is in the Intel x86 family.
+     */
+    public static final boolean IS_X86 = StringTool.startsWithIgnoreCase(OS_ARCH, X86) ||
+            StringTool.startsWithIgnoreCase(OS_ARCH, I386);
 
-    /** True if this is HP-UX. */
-    public static final boolean IS_HPUX = StringTool.startsWithIgnoreCase(OS_NAME, HP_UX );
+    /**
+     * True if the processor is in the PowerPC family.
+     */
+    public static final boolean IS_PPC = StringTool.startsWithIgnoreCase(OS_ARCH, PPC);
 
-    /** True if this is AIX. */
-    public static final boolean IS_AIX = StringTool.startsWithIgnoreCase(OS_NAME, AIX );
+    /**
+     * True if the processor is in the SPARC family.
+     */
+    public static final boolean IS_SPARC = StringTool.startsWithIgnoreCase(OS_ARCH, SPARC);
 
-    /** True if this is SunOS. */
-    public static final boolean IS_SUNOS = StringTool.startsWithIgnoreCase(OS_NAME, SUNOS );
+    /**
+     * True if this is FreeBSD.
+     */
+    public static final boolean IS_FREEBSD = StringTool.startsWithIgnoreCase(OS_NAME, FREEBSD);
 
-    /** True if this is OS/2. */
-    public static final boolean IS_OS2 = StringTool.startsWith(OS_NAME, OS_2 );
+    /**
+     * True if this is Linux.
+     */
+    public static final boolean IS_LINUX = StringTool.startsWithIgnoreCase(OS_NAME, LINUX);
 
-    /** True is this is Mac OS */
-    public static final boolean IS_MAC = StringTool.startsWith(OS_NAME, MAC );
-    
-    /** True if this is the Mac OS X. */
+    /**
+     * True if this is HP-UX.
+     */
+    public static final boolean IS_HPUX = StringTool.startsWithIgnoreCase(OS_NAME, HP_UX);
+
+    /**
+     * True if this is AIX.
+     */
+    public static final boolean IS_AIX = StringTool.startsWithIgnoreCase(OS_NAME, AIX);
+
+    /**
+     * True if this is SunOS.
+     */
+    public static final boolean IS_SUNOS = StringTool.startsWithIgnoreCase(OS_NAME, SUNOS) ||
+            StringTool.startsWithIgnoreCase(OS_NAME, SOLARIS);
+
+    /**
+     * True if this is SunOS / x86
+     */
+    public static final boolean IS_SUNOS_X86 = IS_SUNOS && IS_X86;
+
+    /**
+     * True if this is SunOS / sparc
+     */
+    public static final boolean IS_SUNOS_SPARC = IS_SUNOS && IS_SPARC;
+
+    /**
+     * True if this is OS/2.
+     */
+    public static final boolean IS_OS2 = StringTool.startsWith(OS_NAME, OS_2);
+
+    /**
+     * True is this is Mac OS
+     */
+    public static final boolean IS_MAC = StringTool.startsWith(OS_NAME, MAC);
+
+    /**
+     * True if this is the Mac OS X.
+     */
     public static final boolean IS_OSX = StringTool.startsWithIgnoreCase(OS_NAME, MACOSX);
 
-    /** True if this is Windows. */
-    public static final boolean IS_WINDOWS = StringTool.startsWith(OS_NAME, WINDOWS );
+    /**
+     * True if this is Windows.
+     */
+    public static final boolean IS_WINDOWS = StringTool.startsWith(OS_NAME, WINDOWS);
 
-    /** True if this is some variant of Unix (OSX, Linux, Solaris, FreeBSD, etc). */
+    /**
+     * True if this is some variant of Unix (OSX, Linux, Solaris, FreeBSD, etc).
+     */
     public static final boolean IS_UNIX = !IS_OS2 && !IS_WINDOWS;
 
-    /** True if RedHat Linux was detected */
+    /**
+     * True if RedHat Linux was detected
+     */
     public static final boolean IS_REDHAT_LINUX = IS_LINUX
-            && ( ( FileUtil.fileContains(getReleaseFileName(), REDHAT ) || FileUtil.fileContains(getReleaseFileName() ,
-                    RED_HAT ) ) );
+            && ((FileUtil.fileContains(getReleaseFileName(), REDHAT) || FileUtil.fileContains(getReleaseFileName(),
+            RED_HAT)));
 
-    /** True if Fedora Linux was detected */
+    /**
+     * True if Fedora Linux was detected
+     */
     public static final boolean IS_FEDORA_LINUX = IS_LINUX
-            && FileUtil.fileContains(getReleaseFileName(), FEDORA );
+            && FileUtil.fileContains(getReleaseFileName(), FEDORA);
 
-    /** True if Mandriva(Mandrake) Linux was detected */
+    /**
+     * True if Mandriva(Mandrake) Linux was detected
+     */
     public static final boolean IS_MANDRAKE_LINUX = IS_LINUX
-             && FileUtil.fileContains( getReleaseFileName(), MANDRAKE );
-    
-    /** True if Mandrake/Mandriva Linux was detected */
-    public static final boolean IS_MANDRIVA_LINUX = ( IS_LINUX
-            && FileUtil.fileContains( getReleaseFileName(), MANDRIVA ) ) || IS_MANDRAKE_LINUX;
+            && FileUtil.fileContains(getReleaseFileName(), MANDRAKE);
 
-    /** True if SuSE Linux was detected */
+    /**
+     * True if Mandrake/Mandriva Linux was detected
+     */
+    public static final boolean IS_MANDRIVA_LINUX = (IS_LINUX
+            && FileUtil.fileContains(getReleaseFileName(), MANDRIVA)) || IS_MANDRAKE_LINUX;
+
+    /**
+     * True if SuSE Linux was detected
+     */
     public static final boolean IS_SUSE_LINUX = IS_LINUX
-            && FileUtil.fileContains( getReleaseFileName(), SUSE, true );  /*  caseInsensitive , since 'SUSE' 10 */
+            && FileUtil.fileContains(getReleaseFileName(), SUSE, true);  /*  caseInsensitive , since 'SUSE' 10 */
 
-    /** True if Debian Linux or derived was detected */
+    /**
+     * True if Debian Linux or derived was detected
+     */
     public static final boolean IS_DEBIAN_LINUX = (IS_LINUX
-            && FileUtil.fileContains(PROC_VERSION, DEBIAN )) || ( IS_LINUX && new File( "/etc/debian_version" ).exists() );
+            && FileUtil.fileContains(PROC_VERSION, DEBIAN)) || (IS_LINUX && new File("/etc/debian_version").exists());
 
     // TODO detect the newcomer (K)Ubuntu */
     //~ Methods
@@ -97,122 +162,89 @@
 
     /**
      * Gets the etc Release Filename
-     * 
+     *
      * @return name of the file the release info is stored in for Linux distributions
      */
-    private static String getReleaseFileName()
-    {
+    private static String getReleaseFileName() {
         String result = "";
 
         File[] etcList = new File("/etc").listFiles();
-        
-        if( etcList != null )
-        for (int idx = 0; idx < etcList.length; idx++)
-        {
-            File etcEntry = etcList[idx];
 
-            if (etcEntry.isFile())
-            {
-                if (etcEntry.getName().endsWith("-release"))
-                {
-                    //match :-)
-                    return result = etcEntry.toString();
+        if (etcList != null)
+            for (int idx = 0; idx < etcList.length; idx++) {
+                File etcEntry = etcList[idx];
+
+                if (etcEntry.isFile()) {
+                    if (etcEntry.getName().endsWith("-release")) {
+                        //match :-)
+                        return result = etcEntry.toString();
+                    }
                 }
             }
-        }
 
         return result;
     }
 
     /**
      * Gets the Details of a Linux Distribution
-     * 
+     *
      * @return description string of the Linux distribution
      */
-    private static String getLinuxDistribution()
-    {
+    private static String getLinuxDistribution() {
         String result = null;
 
-        if (IS_SUSE_LINUX)
-        {
-            try
-            {
+        if (IS_SUSE_LINUX) {
+            try {
                 result = SUSE + SP + LINUX + NL + StringTool.stringArrayListToString(FileUtil.getFileContent(getReleaseFileName()));
             }
-            catch (IOException e)
-            {
+            catch (IOException e) {
                 // TODO ignore
             }
-        }
-        else if (IS_REDHAT_LINUX)
-        {
-            try
-            {
+        } else if (IS_REDHAT_LINUX) {
+            try {
                 result = REDHAT + SP + LINUX + NL + StringTool.stringArrayListToString(FileUtil.getFileContent(getReleaseFileName()));
             }
-            catch (IOException e)
-            {
+            catch (IOException e) {
                 // TODO ignore
             }
-        }
-
-        else if (IS_FEDORA_LINUX)
-        {
-            try
-            {
+        } else if (IS_FEDORA_LINUX) {
+            try {
                 result = FEDORA + SP + LINUX + NL
                         + StringTool.stringArrayListToString(FileUtil.getFileContent(getReleaseFileName()));
             }
-            catch (IOException e)
-            {
+            catch (IOException e) {
                 // TODO ignore
             }
-        }
-        else if (IS_MANDRAKE_LINUX)
-        {
-            try
-            {
+        } else if (IS_MANDRAKE_LINUX) {
+            try {
                 result = MANDRAKE + SP + LINUX + NL
                         + StringTool.stringArrayListToString(FileUtil.getFileContent(getReleaseFileName()));
             }
-            catch (IOException e)
-            {
+            catch (IOException e) {
                 // TODO ignore
             }
-        }
-        else if (IS_MANDRIVA_LINUX)
-        {
-            try
-            {
-                result = MANDRIVA + SP +  LINUX + NL
+        } else if (IS_MANDRIVA_LINUX) {
+            try {
+                result = MANDRIVA + SP + LINUX + NL
                         + StringTool.stringArrayListToString(FileUtil.getFileContent(getReleaseFileName()));
             }
-            catch (IOException e)
-            {
+            catch (IOException e) {
                 // TODO ignore
             }
-        }
-        else if (IS_DEBIAN_LINUX)
-        {
-            try
-            {
+        } else if (IS_DEBIAN_LINUX) {
+            try {
                 result = DEBIAN + SP + LINUX + NL
                         + StringTool.stringArrayListToString(FileUtil.getFileContent("/etc/debian_version"));
             }
-            catch (IOException e)
-            {
+            catch (IOException e) {
                 // TODO ignore
             }
-        }
-        else
-        {
-            try
-            {
+        } else {
+            try {
                 result = "Unknown Linux Distribution\n"
                         + StringTool.stringArrayListToString(FileUtil.getFileContent(getReleaseFileName()));
             }
-            catch (IOException e)
-            {
+            catch (IOException e) {
                 // TODO ignore
             }
         }
@@ -222,46 +254,38 @@
 
     /**
      * returns a String which contains details of known OSs
+     *
      * @return the details
      */
-    public static String getOsDetails()
-    {
+    public static String getOsDetails() {
         StringBuffer result = new StringBuffer();
         result.append("OS_NAME=").append(OS_NAME).append(NL);
 
-        if( IS_UNIX )
-        {
-            if( IS_LINUX )
-            {
+        if (IS_UNIX) {
+            if (IS_LINUX) {
                 result.append(getLinuxDistribution()).append(NL);
-            }
-            else
-            {
-                try
-                {
+            } else {
+                try {
                     result.append(FileUtil.getFileContent(getReleaseFileName())).append(NL);
                 }
-                catch (IOException e)
-                {
+                catch (IOException e) {
                     Debug.log("Unable to get release file contents in 'getOsDetails'.");
                 }
             }
         }
 
-        if( IS_WINDOWS )
-        {
+        if (IS_WINDOWS) {
             result.append(System.getProperty(OSNAME)).append(SP).append(System.getProperty("sun.os.patch.level", "")).append(NL);
         }
         return result.toString();
     }
-    
+
     /**
      * Testmain
-     * 
+     *
      * @param args Commandline Args
      */
-    public static void main(String[] args)
-    {
-      System.out.println( getOsDetails() );
-    }    
+    public static void main(String[] args) {
+        System.out.println(getOsDetails());
+    }
 }

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/util/OsVersionConstants.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/util/OsVersionConstants.java	2007-12-21 18:35:56 UTC (rev 1971)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/util/OsVersionConstants.java	2007-12-28 13:10:49 UTC (rev 1972)
@@ -25,61 +25,126 @@
  *
  * @author marc.eppelmann&#064;reddot.de
  */
-public interface OsVersionConstants
-{
-  //~ Static fields/initializers *********************************************************
+public interface OsVersionConstants {
+    //~ Static fields/initializers *********************************************************
 
-  /** OSNAME = "os.name" */
-  public final static String OSNAME = "os.name";
+    /**
+     * OSNAME = "os.name"
+     */
+    public final static String OSNAME = "os.name";
 
-  /** FREEBSD = "FreeBSD" */
-  public final static String FREEBSD = "FreeBSD";
+    /**
+     * OSARCH = "os.arch"
+     */
+    public final static String OSARCH = "os.arch";
 
-  /** LINUX = "Linux" */
-  public final static String LINUX = "Linux";
+    /**
+     * X86 = "x86"
+     */
+    public static final String X86 = "x86";
 
-  /** HP_UX = "HP-UX" */
-  public final static String HP_UX = "HP-UX";
+    /**
+     * I386 = "i386"
+     */
+    public static final String I386 = "i386";
 
-  /** AIX = "AIX" */
-  public final static String AIX = "AIX";
+    /**
+     * PPC = "ppc"
+     */
+    public static final String PPC = "ppc";
 
-  /** SUNOS = "SunOS" */
-  public final static String SUNOS = "SunOS";
+    /**
+     * SPARC = "sparc"
+     */
+    public static final String SPARC = "sparc";
 
-  /** OS_2 = "OS/2" */
-  public final static String OS_2 = "OS/2";
+    /**
+     * FREEBSD = "FreeBSD"
+     */
+    public final static String FREEBSD = "FreeBSD";
 
-  /** MAC = "Mac" */
-  public final static String MAC = "Mac";
-  
-  /** Mac OS X */
-  public final static String MACOSX = "mac os x";
+    /**
+     * LINUX = "Linux"
+     */
+    public final static String LINUX = "Linux";
 
-  /** WINDOWS = "Windows" */
-  public final static String WINDOWS = "Windows";
+    /**
+     * HP_UX = "HP-UX"
+     */
+    public final static String HP_UX = "HP-UX";
 
-  /** REDHAT  = "RedHat" */
-  public final static String REDHAT  = "RedHat";
+    /**
+     * AIX = "AIX"
+     */
+    public final static String AIX = "AIX";
 
-  /** RED_HAT = "Red Hat" */
-  public final static String RED_HAT = "Red Hat";
+    /**
+     * SUNOS = "SunOS"
+     */
+    public final static String SUNOS = "SunOS";
 
-  /** FEDORA = "Fedora" */
-  public final static String FEDORA = "Fedora";
+    /**
+     * SOLARIS = "Solaris"
+     */
+    public static final String SOLARIS = "Solaris";
 
-  /** MANDRAKE = "Mandrake" */
-  public final static String MANDRAKE = "Mandrake";
+    /**
+     * OS_2 = "OS/2"
+     */
+    public final static String OS_2 = "OS/2";
 
-  /** MANDRIVA = "Mandriva" */
-  public final static String MANDRIVA = "Mandriva";
+    /**
+     * MAC = "Mac"
+     */
+    public final static String MAC = "Mac";
 
-  /** SUSE = "SuSE" */
-  public final static String SUSE = "SuSE";
+    /**
+     * Mac OS X
+     */
+    public final static String MACOSX = "mac os x";
 
-  /** DEBIAN = "Debian" */
-  public final static String DEBIAN = "Debian";
+    /**
+     * WINDOWS = "Windows"
+     */
+    public final static String WINDOWS = "Windows";
 
-  /** PROC_VERSION = "/proc/version" */
-  public final static String PROC_VERSION = "/proc/version";
+    /**
+     * REDHAT  = "RedHat"
+     */
+    public final static String REDHAT = "RedHat";
+
+    /**
+     * RED_HAT = "Red Hat"
+     */
+    public final static String RED_HAT = "Red Hat";
+
+    /**
+     * FEDORA = "Fedora"
+     */
+    public final static String FEDORA = "Fedora";
+
+    /**
+     * MANDRAKE = "Mandrake"
+     */
+    public final static String MANDRAKE = "Mandrake";
+
+    /**
+     * MANDRIVA = "Mandriva"
+     */
+    public final static String MANDRIVA = "Mandriva";
+
+    /**
+     * SUSE = "SuSE"
+     */
+    public final static String SUSE = "SuSE";
+
+    /**
+     * DEBIAN = "Debian"
+     */
+    public final static String DEBIAN = "Debian";
+
+    /**
+     * PROC_VERSION = "/proc/version"
+     */
+    public final static String PROC_VERSION = "/proc/version";
 }



More information about the izpack-changes mailing list