From f2fe5c04dd8722297ec97b2737ec8812ffd5ad73 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 16 Mar 2007 09:44:16 +0000
Subject: [PATCH] Fix for issue 1252 (restrict installed bin files to relevant platform).

---
 opends/resource/bin/statuspanel.bat                                                   |    6 +-
 opends/build.xml                                                                      |    9 ++-
 opends/resource/bin/stop-ds.bat                                                       |    8 +-
 opends/resource/bin/_server-script.bat                                                |    6 +-
 opends/resource/uninstall.bat                                                         |    6 +-
 opends/src/quicksetup/org/opends/quicksetup/util/Utils.java                           |   59 ++++++++++++++++---
 opends/resource/bin/README_WINDOWS.txt                                                |   30 ++++++++++
 opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java |   11 ++-
 opends/resource/bin/_client-script.bat                                                |    6 +-
 opends/resource/bin/start-ds.bat                                                      |    6 +-
 opends/resource/setup.bat                                                             |    6 +-
 11 files changed, 115 insertions(+), 38 deletions(-)

diff --git a/opends/build.xml b/opends/build.xml
index b5be56f..2533079 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -605,7 +605,8 @@
 
     <mkdir dir="${pdir}"                 />
     <mkdir dir="${pdir}/bak"             />
-    <mkdir dir="${pdir}/bin"             />
+    <mkdir dir="${pdir}/bat"             />
+  	<mkdir dir="${pdir}/bin"             />
     <mkdir dir="${pdir}/classes"         />
     <mkdir dir="${pdir}/config"          />
     <mkdir dir="${pdir}/config/upgrade"  />
@@ -639,9 +640,11 @@
 
     <fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/bin" excludes="*.bat"
          eol="lf" />
-    <fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/bin" includes="*.bat"
+    <fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/bin" includes="*.bat,README_WINDOWS.txt"
          eol="crlf" />
-
+    <fixcrlf srcDir="${scripts.dir}" destDir="${pdir}/bat" includes="*.bat"
+         eol="crlf" />
+  	
     <copy todir="${pdir}/config">
       <fileset file="${config.dir}/*" />
     </copy>
diff --git a/opends/resource/bin/README_WINDOWS.txt b/opends/resource/bin/README_WINDOWS.txt
new file mode 100644
index 0000000..c429ea3
--- /dev/null
+++ b/opends/resource/bin/README_WINDOWS.txt
@@ -0,0 +1,30 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+Note that all the batch files under the 'bin' directory have been moved to the
+'bat' directory.  For the moment a copy of the batch files is still included
+under 'bin' directory.  However these files will be removed in next builds and
+so only a copy of the batch files will be provided under the 'bat' directory.
diff --git a/opends/resource/bin/_client-script.bat b/opends/resource/bin/_client-script.bat
index 5f79e87..6d284f7 100644
--- a/opends/resource/bin/_client-script.bat
+++ b/opends/resource/bin/_client-script.bat
@@ -51,8 +51,8 @@
 goto setClassPath
 
 :noJavaHome
-if not exist "%DIR_HOME%\bin\set-java-home.bat" goto noSetJavaHome
-call "%DIR_HOME%\bin\set-java-home.bat"
+if not exist "%DIR_HOME%\bat\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\bat\set-java-home.bat"
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
 goto setClassPath
 
@@ -63,7 +63,7 @@
 
 
 :setClassPath
-FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bin\setcp.bat" %%x
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
 
 set PATH=%SystemRoot%
 
diff --git a/opends/resource/bin/_server-script.bat b/opends/resource/bin/_server-script.bat
index 8cfc11c..2c39881 100644
--- a/opends/resource/bin/_server-script.bat
+++ b/opends/resource/bin/_server-script.bat
@@ -51,8 +51,8 @@
 goto setClassPath
 
 :noJavaHome
-if not exist "%DIR_HOME%\bin\set-java-home.bat" goto noSetJavaHome
-call "%DIR_HOME%\bin\set-java-home.bat"
+if not exist "%DIR_HOME%\bat\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\bat\set-java-home.bat"
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
 goto setClassPath
 
@@ -62,7 +62,7 @@
 goto end
 
 :setClassPath
-FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bin\setcp.bat" %%x
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
 
 set PATH=%SystemRoot%
 
diff --git a/opends/resource/bin/start-ds.bat b/opends/resource/bin/start-ds.bat
index 7cd4fcd..8ea23b5 100644
--- a/opends/resource/bin/start-ds.bat
+++ b/opends/resource/bin/start-ds.bat
@@ -41,8 +41,8 @@
 goto setClassPath
 
 :noJavaHome
-if not exist "%DIR_HOME%\bin\set-java-home.bat" goto noSetJavaHome
-call "%DIR_HOME%\bin\set-java-home.bat"
+if not exist "%DIR_HOME%\bat\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\bat\set-java-home.bat"
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
 goto setClassPath
 
@@ -52,7 +52,7 @@
 goto end
 
 :setClassPath
-FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bin\setcp.bat" %%x
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
 
 set PATH=%SystemRoot%
 
diff --git a/opends/resource/bin/statuspanel.bat b/opends/resource/bin/statuspanel.bat
index 5c3284c..d8c9f35 100644
--- a/opends/resource/bin/statuspanel.bat
+++ b/opends/resource/bin/statuspanel.bat
@@ -41,8 +41,8 @@
 goto setClassPath
 
 :noJavaHome
-if not exist "%DIR_HOME%\bin\set-java-home.bat" goto noSetJavaHome
-call "%DIR_HOME%\bin\set-java-home.bat"
+if not exist "%DIR_HOME%\bat\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\bat\set-java-home.bat"
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
 goto setClassPath
 
@@ -52,7 +52,7 @@
 goto end
 
 :setClassPath
-FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bin\setcp.bat" %%x
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
 
 set PATH=%SystemRoot%
 
diff --git a/opends/resource/bin/stop-ds.bat b/opends/resource/bin/stop-ds.bat
index 9145664..5aad779 100644
--- a/opends/resource/bin/stop-ds.bat
+++ b/opends/resource/bin/stop-ds.bat
@@ -44,8 +44,8 @@
 goto setClassPath
 
 :noJavaHome
-if not exist "%DIR_HOME%\bin\set-java-home.bat" goto noSetJavaHome
-call "%DIR_HOME%\bin\set-java-home.bat"
+if not exist "%DIR_HOME%\bat\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\bat\set-java-home.bat"
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
 goto setClassPath
 
@@ -55,7 +55,7 @@
 goto end
 
 :setClassPath
-FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bin\setcp.bat" %%x
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
 
 "%JAVA_BIN%" -Xms8M -Xmx8M %SCRIPT_NAME_ARG%  org.opends.server.tools.StopDS --checkStoppability %*
 
@@ -74,7 +74,7 @@
 goto end
 
 :startUsingSystemCall
-"%DIR_HOME%\bin\start-ds.bat"
+"%DIR_HOME%\bat\start-ds.bat"
 goto end
 
 :stopUsingSystemCall
diff --git a/opends/resource/setup.bat b/opends/resource/setup.bat
index b3f46cf..e049d94 100644
--- a/opends/resource/setup.bat
+++ b/opends/resource/setup.bat
@@ -41,8 +41,8 @@
 goto setClassPath
 
 :noJavaHome
-if not exist "%DIR_HOME%\bin\set-java-home.bat" goto noSetJavaHome
-call "%DIR_HOME%\bin\set-java-home.bat"
+if not exist "%DIR_HOME%\bat\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\bat\set-java-home.bat"
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
 goto setClassPath
 
@@ -53,7 +53,7 @@
 
 
 :setClassPath
-FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bin\setcp.bat" %%x
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
 
 set PATH=%SystemRoot%
 
diff --git a/opends/resource/uninstall.bat b/opends/resource/uninstall.bat
index 219872f..931054e 100644
--- a/opends/resource/uninstall.bat
+++ b/opends/resource/uninstall.bat
@@ -41,8 +41,8 @@
 goto setClassPath
 
 :noJavaHome
-if not exist "%DIR_HOME%\bin\set-java-home.bat" goto noSetJavaHome
-call "%DIR_HOME%\bin\set-java-home.bat"
+if not exist "%DIR_HOME%\bat\set-java-home.bat" goto noSetJavaHome
+call "%DIR_HOME%\bat\set-java-home.bat"
 set JAVA_BIN=%JAVA_HOME%\bin\java.exe
 goto setClassPath
 
@@ -52,7 +52,7 @@
 goto end
 
 :setClassPath
-FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bin\setcp.bat" %%x
+FOR %%x in ("%DIR_HOME%\lib\*.jar") DO call "%DIR_HOME%\bat\setcp.bat" %%x
 
 set PATH=%SystemRoot%
 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java b/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
index 4424e1c..e926c2e 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
@@ -626,16 +626,21 @@
     String perm;
 
     File file = new File(path);
-    if (file.getParent().endsWith(File.separator + "bin"))
+    if (file.getParent().endsWith(
+        File.separator + Utils.getWindowsBinariesRelativePath()) ||
+        file.getParent().endsWith(
+        File.separator + Utils.getUNIXBinariesRelativePath()))
     {
       if (path.endsWith(".bat"))
       {
         perm = "644";
-      } else
+      }
+      else
       {
         perm = "755";
       }
-    } else if (path.endsWith(".sh"))
+    }
+    else if (path.endsWith(".sh"))
     {
       perm = "755";
     } else if (path.endsWith(Utils.getUnixSetupFileName()) ||
diff --git a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index b442baa..b0f4d75 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -73,10 +73,16 @@
   private static final String[] OPEN_DS_JAR_RELATIVE_PATHS =
     { "lib/quicksetup.jar", "lib/OpenDS.jar", "lib/je.jar" };
 
+
   /**
-   * The relative path where all the binaries (scripts) are.
+   * The relative path where all the Windows binaries (batch files) are.
    */
-  private static final String BINARIES_PATH_RELATIVE = "bin";
+  private static final String WINDOWS_BINARIES_PATH_RELATIVE = "bat";
+
+  /**
+   * The relative path where all the UNIX binaries (scripts) are.
+   */
+  private static final String UNIX_BINARIES_PATH_RELATIVE = "bin";
 
   /**
    * The relative path where all the libraries (jar files) are.
@@ -964,7 +970,7 @@
       }
     }
     File f = new File(path).getAbsoluteFile();
-    File binariesDir = f.getParentFile();
+    File librariesDir = f.getParentFile();
 
     /*
      * Do a best effort to avoid having a relative representation (for
@@ -972,12 +978,12 @@
      */
     try
     {
-      installPath = binariesDir.getParentFile().getCanonicalPath();
+      installPath = librariesDir.getParentFile().getCanonicalPath();
     }
     catch (IOException ioe)
     {
       // Best effort
-      installPath = binariesDir.getParent();
+      installPath = librariesDir.getParent();
     }
     return installPath;
   }
@@ -1005,14 +1011,47 @@
 
 
   /**
-   * Returns the relative path of the directory containing the binaries of the
-   * Open DS installation.  The path is relative to the installation path.
-   * @return the relative path of the directory containing the binaries of the
-   * Open DS installation.
+   * Returns the relative path of the directory containing the Windows binaries
+   * of the Open DS installation.  The path is relative to the installation
+   * path.
+   * @return the relative path of the directory containing the Windows binaries
+   * of the Open DS installation.
+   */
+  public static String getWindowsBinariesRelativePath()
+  {
+    return WINDOWS_BINARIES_PATH_RELATIVE;
+  }
+
+  /**
+   * Returns the relative path of the directory containing the binaries/scripts
+   * of the Open DS installation.  The path is relative to the installation
+   * path.
+   * @return the relative path of the directory containing the binaries/scripts
+   * of the Open DS installation.
    */
   public static String getBinariesRelativePath()
   {
-    return BINARIES_PATH_RELATIVE;
+    String binPath;
+    if (isWindows())
+    {
+      binPath = getWindowsBinariesRelativePath();
+    }
+    else
+    {
+      binPath = getUNIXBinariesRelativePath();
+    }
+    return binPath;
+  }
+
+  /**
+   * Returns the relative path of the directory containing the UNIX binaries of
+   * the Open DS installation.  The path is relative to the installation path.
+   * @return the relative path of the directory containing the UNIX binaries of
+   * the Open DS installation.
+   */
+  public static String getUNIXBinariesRelativePath()
+  {
+    return UNIX_BINARIES_PATH_RELATIVE;
   }
 
   /**

--
Gitblit v1.10.0