[Title] Modify check routine of java version and java execution on cmd command.
authoryongsung1.kim <yongsung1.kim@samsung.com>
Fri, 23 Aug 2013 04:52:22 +0000 (13:52 +0900)
committeryongsung1.kim <yongsung1.kim@samsung.com>
Fri, 23 Aug 2013 04:52:22 +0000 (13:52 +0900)
[Desc.] InstallManager was kwown fault as virus or marware soft. So, modify java check routine. Removed javacheck.exe file, and nsis stub does not make new file, just compare with standard out.
[Issue] Redmine #10197

os_stubs/windows/InstallManager-64.nsi
os_stubs/windows/InstallManager.nsi
os_stubs/windows/javacheck-32.exe [deleted file]
os_stubs/windows/javacheck-64.exe [deleted file]
package/build.windows

index b11f930..6fe35f8 100644 (file)
@@ -8,9 +8,75 @@ Icon "SDK_icon.ico"
 \r
 !include FileFunc.nsh\r
 !include LogicLib.nsh\r
+!include x64.nsh\r
 !insertmacro GetParameters\r
 !insertmacro GetOptions\r
 \r
+### StrStr\r
+!define StrStr "!insertmacro StrStr"\r
\r
+!macro StrStr ResultVar String SubString\r
+       Push `${String}`\r
+       Push `${SubString}`\r
+       Call StrStr\r
+       Pop `${ResultVar}`\r
+!macroend\r
\r
+Function StrStr\r
+/*After this point:\r
+  ------------------------------------------\r
+       $R0 = SubString (input)\r
+       $R1 = String (input)\r
+       $R2 = SubStringLen (temp)\r
+       $R3 = StrLen (temp)\r
+       $R4 = StartCharPos (temp)\r
+       $R5 = TempStr (temp)*/\r
+\r
+       ;Get input from user\r
+       Exch $R0\r
+       Exch\r
+       Exch $R1\r
+       Push $R2\r
+       Push $R3\r
+       Push $R4\r
+       Push $R5\r
+\r
+       ;Get "String" and "SubString" length\r
+       StrLen $R2 $R0\r
+       StrLen $R3 $R1\r
+       ;Start "StartCharPos" counter\r
+       StrCpy $R4 0\r
+\r
+       ;Loop until "SubString" is found or "String" reaches its end\r
+       ${Do}\r
+               ;Remove everything before and after the searched part ("TempStr")\r
+               StrCpy $R5 $R1 $R2 $R4\r
+\r
+               ;Compare "TempStr" with "SubString"\r
+               ${IfThen} $R5 == $R0 ${|} ${ExitDo} ${|}\r
+               ;If not "SubString", this could be "String"'s end\r
+               ${IfThen} $R4 >= $R3 ${|} ${ExitDo} ${|}\r
+               ;If not, continue the loop\r
+               IntOp $R4 $R4 + 1\r
+       ${Loop}\r
\r
+/*After this point:\r
+  ------------------------------------------\r
+       $R0 = ResultVar (output)*/\r
+\r
+       ;Remove part before "SubString" on "String" (if there has one)\r
+       StrCpy $R0 $R1 `` $R4\r
+\r
+       ;Return output to user\r
+       Pop $R5\r
+       Pop $R4\r
+       Pop $R3\r
+       Pop $R2\r
+       Pop $R1\r
+       Exch $R0\r
+FunctionEnd\r
+############\r
+\r
 ### TimeStamp\r
 !ifndef TimeStamp\r
     !define TimeStamp "!insertmacro _TimeStamp" \r
@@ -99,10 +165,46 @@ done:
        File /r "img\*.conf"\r
        File /r "img\*.jar"\r
        DetailPrint "install manager will be executed"\r
-       ExecDos::exec '"$INSTDIR\javacheck.exe"' "" ""\r
+\r
+       ## Check java version and java execution.\r
+       ExpandEnvStrings $3 %COMSPEC%\r
+\r
+       ${DisableX64FSRedirection} ; execute cmd command for windows7 64bit\r
+       nsExec::ExecToStack '"$3" /C ""java.exe" "-version""'\r
+       Pop $0\r
+       Pop $6\r
+       ${EnableX64FSRedirection} ; execute cmd command for windows7 64bit\r
+\r
+       ## check java 1.6\r
+       Push $6\r
+       Push "1.6"\r
+       Call StrStr\r
        Pop $1\r
-       ${If} $1 != 0\r
-               goto NoEnv\r
+       ${If} $1 == "" ; if not java version 1.6, it will check java version 1.7.\r
+               Push $6\r
+               Push "1.7"\r
+               Call StrStr\r
+               Pop $1\r
+               ${If} $1 == "" ; if not java version 1.7, it will check java version using java home.\r
+                       ## Execute java.exe in java home\r
+                       nsExec::ExecToStack '"$3" /C ""$5\bin\java.exe" "-version""'\r
+                       Pop $0\r
+                       Pop $6\r
+\r
+                       Push $6\r
+                       Push "1.6"\r
+                       Call StrStr\r
+                       Pop $1\r
+                       ${If} $1 == "" ; if not java version 1.6, it will check java version 1.7.\r
+                               Push $6\r
+                               Push "1.7"\r
+                               Call StrStr\r
+                               Pop $1\r
+                               ${If} $1 == "" ; if not java version 1.7, system does not support java.\r
+                                       goto NoEnv\r
+                               ${EndIf}\r
+                       ${EndIf}\r
+               ${EndIf}\r
        ${EndIf}\r
 \r
        ${If} $R0 == ""\r
@@ -126,4 +228,4 @@ NoJava:
 SetAutoClose true\r
 return\r
 \r
-sectionEnd
\ No newline at end of file
+sectionEnd\r
index 09a0e71..8353efa 100644 (file)
@@ -11,6 +11,72 @@ Icon "SDK_icon.ico"
 !insertmacro GetParameters\r
 !insertmacro GetOptions\r
 \r
+### StrStr\r
+!define StrStr "!insertmacro StrStr"\r
\r
+!macro StrStr ResultVar String SubString\r
+       Push `${String}`\r
+       Push `${SubString}`\r
+       Call StrStr\r
+       Pop `${ResultVar}`\r
+!macroend\r
\r
+Function StrStr\r
+/*After this point:\r
+  ------------------------------------------\r
+       $R0 = SubString (input)\r
+       $R1 = String (input)\r
+       $R2 = SubStringLen (temp)\r
+       $R3 = StrLen (temp)\r
+       $R4 = StartCharPos (temp)\r
+       $R5 = TempStr (temp)*/\r
+\r
+       ;Get input from user\r
+       Exch $R0\r
+       Exch\r
+       Exch $R1\r
+       Push $R2\r
+       Push $R3\r
+       Push $R4\r
+       Push $R5\r
+\r
+       ;Get "String" and "SubString" length\r
+       StrLen $R2 $R0\r
+       StrLen $R3 $R1\r
+       ;Start "StartCharPos" counter\r
+       StrCpy $R4 0\r
+\r
+       ;Loop until "SubString" is found or "String" reaches its end\r
+       ${Do}\r
+               ;Remove everything before and after the searched part ("TempStr")\r
+               StrCpy $R5 $R1 $R2 $R4\r
+\r
+               ;Compare "TempStr" with "SubString"\r
+               ${IfThen} $R5 == $R0 ${|} ${ExitDo} ${|}\r
+               ;If not "SubString", this could be "String"'s end\r
+               ${IfThen} $R4 >= $R3 ${|} ${ExitDo} ${|}\r
+               ;If not, continue the loop\r
+               IntOp $R4 $R4 + 1\r
+       ${Loop}\r
\r
+/*After this point:\r
+  ------------------------------------------\r
+       $R0 = ResultVar (output)*/\r
+\r
+       ;Remove part before "SubString" on "String" (if there has one)\r
+       StrCpy $R0 $R1 `` $R4\r
+\r
+       ;Return output to user\r
+       Pop $R5\r
+       Pop $R4\r
+       Pop $R3\r
+       Pop $R2\r
+       Pop $R1\r
+       Exch $R0\r
+FunctionEnd\r
+############\r
+\r
+\r
 ### TimeStamp\r
 !ifndef TimeStamp\r
     !define TimeStamp "!insertmacro _TimeStamp" \r
@@ -98,10 +164,46 @@ done:
        File /r "img\*.conf"\r
        File /r "img\*.jar"\r
        DetailPrint "install manager will be executed"\r
-       ExecDos::exec '"$INSTDIR\javacheck.exe"' "" ""\r
+\r
+       MessageBox MB_ICONEXCLAMATION "java home path : $5"\r
+\r
+       ## Check java version and java execution.\r
+       ExpandEnvStrings $3 %COMSPEC%\r
+       \r
+       nsExec::ExecToStack '"$3" /C ""java.exe" "-version""'\r
+       Pop $0\r
+       Pop $6\r
+       ## check java 1.6\r
+       Push $6\r
+       Push "1.6"\r
+       Call StrStr\r
        Pop $1\r
-       ${If} $1 != 0\r
-               goto NoEnv\r
+       ${If} $1 == "" ; if not java version 1.6, it will check java version 1.7.\r
+               Push $6\r
+               Push "1.7"\r
+               Call StrStr\r
+               Pop $1\r
+               ${If} $1 == "" ; if not java version 1.7, it will check java version using java home.\r
+                       ## Execute java.exe in java home\r
+                       nsExec::ExecToStack '"$5" /C ""$4\bin\java.exe" "-version""'\r
+                       Pop $0\r
+                       Pop $6\r
+\r
+                       ## check java 1.6\r
+                       Push $6\r
+                       Push "1.6"\r
+                       Call StrStr\r
+                       Pop $1\r
+                       ${If} $1 == "" ; if not java version 1.6, it will check java version 1.7.\r
+                               Push $6\r
+                               Push "1.7"\r
+                               Call StrStr\r
+                               Pop $1\r
+                               ${If} $1 == "" ; if not java version 1.7, system does not support java.\r
+                                       goto NoEnv\r
+                               ${EndIf}\r
+                       ${EndIf}\r
+               ${EndIf}\r
        ${EndIf}\r
 \r
        ${If} $R0 == ""\r
diff --git a/os_stubs/windows/javacheck-32.exe b/os_stubs/windows/javacheck-32.exe
deleted file mode 100644 (file)
index 4276b1f..0000000
Binary files a/os_stubs/windows/javacheck-32.exe and /dev/null differ
diff --git a/os_stubs/windows/javacheck-64.exe b/os_stubs/windows/javacheck-64.exe
deleted file mode 100644 (file)
index b08ca86..0000000
Binary files a/os_stubs/windows/javacheck-64.exe and /dev/null differ
index 5f5b541..574af2a 100755 (executable)
@@ -42,14 +42,12 @@ makeExecutable() {
                        cp -rf $SRCDIR/os_stubs/windows/32/InstManager.exe ${buildDir}/img/
                        cp -rf $SRCDIR/os_stubs/windows/32/InstManagerC.exe ${buildDir}/img/
                        cp -rf $SRCDIR/os_stubs/windows/InstallManager.nsi ${buildDir}/
-                       cp -rf $SRCDIR/os_stubs/windows/javacheck-32.exe ${buildDir}/img/javacheck.exe
                ;;
         windows-64)
                        cp -rf $SRCDIR/InstallManager_java/dist/windows64/InstallManager.jar ${buildDir}/img
                        cp -rf $SRCDIR/os_stubs/windows/64/InstManager.exe ${buildDir}/img/
                        cp -rf $SRCDIR/os_stubs/windows/64/InstManagerC.exe ${buildDir}/img/
                        cp -rf $SRCDIR/os_stubs/windows/InstallManager-64.nsi ${buildDir}/InstallManager.nsi
-                       cp -rf $SRCDIR/os_stubs/windows/javacheck-64.exe ${buildDir}/img/javacheck.exe
         ;;
         *)
                        echo "The OS \"${TARGET_OS}\" is not supported yet!"