From: yongsung1.kim Date: Fri, 23 Aug 2013 04:52:22 +0000 (+0900) Subject: [Title] Modify check routine of java version and java execution on cmd command. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cd4c8d70dbb7bb04d61c6c38e88612bda04f0438;p=sdk%2Finstaller%2Finstall-manager.git [Title] Modify check routine of java version and java execution on cmd command. [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 --- diff --git a/os_stubs/windows/InstallManager-64.nsi b/os_stubs/windows/InstallManager-64.nsi index b11f930..6fe35f8 100644 --- a/os_stubs/windows/InstallManager-64.nsi +++ b/os_stubs/windows/InstallManager-64.nsi @@ -8,9 +8,75 @@ Icon "SDK_icon.ico" !include FileFunc.nsh !include LogicLib.nsh +!include x64.nsh !insertmacro GetParameters !insertmacro GetOptions +### StrStr +!define StrStr "!insertmacro StrStr" + +!macro StrStr ResultVar String SubString + Push `${String}` + Push `${SubString}` + Call StrStr + Pop `${ResultVar}` +!macroend + +Function StrStr +/*After this point: + ------------------------------------------ + $R0 = SubString (input) + $R1 = String (input) + $R2 = SubStringLen (temp) + $R3 = StrLen (temp) + $R4 = StartCharPos (temp) + $R5 = TempStr (temp)*/ + + ;Get input from user + Exch $R0 + Exch + Exch $R1 + Push $R2 + Push $R3 + Push $R4 + Push $R5 + + ;Get "String" and "SubString" length + StrLen $R2 $R0 + StrLen $R3 $R1 + ;Start "StartCharPos" counter + StrCpy $R4 0 + + ;Loop until "SubString" is found or "String" reaches its end + ${Do} + ;Remove everything before and after the searched part ("TempStr") + StrCpy $R5 $R1 $R2 $R4 + + ;Compare "TempStr" with "SubString" + ${IfThen} $R5 == $R0 ${|} ${ExitDo} ${|} + ;If not "SubString", this could be "String"'s end + ${IfThen} $R4 >= $R3 ${|} ${ExitDo} ${|} + ;If not, continue the loop + IntOp $R4 $R4 + 1 + ${Loop} + +/*After this point: + ------------------------------------------ + $R0 = ResultVar (output)*/ + + ;Remove part before "SubString" on "String" (if there has one) + StrCpy $R0 $R1 `` $R4 + + ;Return output to user + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Pop $R1 + Exch $R0 +FunctionEnd +############ + ### TimeStamp !ifndef TimeStamp !define TimeStamp "!insertmacro _TimeStamp" @@ -99,10 +165,46 @@ done: File /r "img\*.conf" File /r "img\*.jar" DetailPrint "install manager will be executed" - ExecDos::exec '"$INSTDIR\javacheck.exe"' "" "" + + ## Check java version and java execution. + ExpandEnvStrings $3 %COMSPEC% + + ${DisableX64FSRedirection} ; execute cmd command for windows7 64bit + nsExec::ExecToStack '"$3" /C ""java.exe" "-version""' + Pop $0 + Pop $6 + ${EnableX64FSRedirection} ; execute cmd command for windows7 64bit + + ## check java 1.6 + Push $6 + Push "1.6" + Call StrStr Pop $1 - ${If} $1 != 0 - goto NoEnv + ${If} $1 == "" ; if not java version 1.6, it will check java version 1.7. + Push $6 + Push "1.7" + Call StrStr + Pop $1 + ${If} $1 == "" ; if not java version 1.7, it will check java version using java home. + ## Execute java.exe in java home + nsExec::ExecToStack '"$3" /C ""$5\bin\java.exe" "-version""' + Pop $0 + Pop $6 + + Push $6 + Push "1.6" + Call StrStr + Pop $1 + ${If} $1 == "" ; if not java version 1.6, it will check java version 1.7. + Push $6 + Push "1.7" + Call StrStr + Pop $1 + ${If} $1 == "" ; if not java version 1.7, system does not support java. + goto NoEnv + ${EndIf} + ${EndIf} + ${EndIf} ${EndIf} ${If} $R0 == "" @@ -126,4 +228,4 @@ NoJava: SetAutoClose true return -sectionEnd \ No newline at end of file +sectionEnd diff --git a/os_stubs/windows/InstallManager.nsi b/os_stubs/windows/InstallManager.nsi index 09a0e71..8353efa 100644 --- a/os_stubs/windows/InstallManager.nsi +++ b/os_stubs/windows/InstallManager.nsi @@ -11,6 +11,72 @@ Icon "SDK_icon.ico" !insertmacro GetParameters !insertmacro GetOptions +### StrStr +!define StrStr "!insertmacro StrStr" + +!macro StrStr ResultVar String SubString + Push `${String}` + Push `${SubString}` + Call StrStr + Pop `${ResultVar}` +!macroend + +Function StrStr +/*After this point: + ------------------------------------------ + $R0 = SubString (input) + $R1 = String (input) + $R2 = SubStringLen (temp) + $R3 = StrLen (temp) + $R4 = StartCharPos (temp) + $R5 = TempStr (temp)*/ + + ;Get input from user + Exch $R0 + Exch + Exch $R1 + Push $R2 + Push $R3 + Push $R4 + Push $R5 + + ;Get "String" and "SubString" length + StrLen $R2 $R0 + StrLen $R3 $R1 + ;Start "StartCharPos" counter + StrCpy $R4 0 + + ;Loop until "SubString" is found or "String" reaches its end + ${Do} + ;Remove everything before and after the searched part ("TempStr") + StrCpy $R5 $R1 $R2 $R4 + + ;Compare "TempStr" with "SubString" + ${IfThen} $R5 == $R0 ${|} ${ExitDo} ${|} + ;If not "SubString", this could be "String"'s end + ${IfThen} $R4 >= $R3 ${|} ${ExitDo} ${|} + ;If not, continue the loop + IntOp $R4 $R4 + 1 + ${Loop} + +/*After this point: + ------------------------------------------ + $R0 = ResultVar (output)*/ + + ;Remove part before "SubString" on "String" (if there has one) + StrCpy $R0 $R1 `` $R4 + + ;Return output to user + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Pop $R1 + Exch $R0 +FunctionEnd +############ + + ### TimeStamp !ifndef TimeStamp !define TimeStamp "!insertmacro _TimeStamp" @@ -98,10 +164,46 @@ done: File /r "img\*.conf" File /r "img\*.jar" DetailPrint "install manager will be executed" - ExecDos::exec '"$INSTDIR\javacheck.exe"' "" "" + + MessageBox MB_ICONEXCLAMATION "java home path : $5" + + ## Check java version and java execution. + ExpandEnvStrings $3 %COMSPEC% + + nsExec::ExecToStack '"$3" /C ""java.exe" "-version""' + Pop $0 + Pop $6 + ## check java 1.6 + Push $6 + Push "1.6" + Call StrStr Pop $1 - ${If} $1 != 0 - goto NoEnv + ${If} $1 == "" ; if not java version 1.6, it will check java version 1.7. + Push $6 + Push "1.7" + Call StrStr + Pop $1 + ${If} $1 == "" ; if not java version 1.7, it will check java version using java home. + ## Execute java.exe in java home + nsExec::ExecToStack '"$5" /C ""$4\bin\java.exe" "-version""' + Pop $0 + Pop $6 + + ## check java 1.6 + Push $6 + Push "1.6" + Call StrStr + Pop $1 + ${If} $1 == "" ; if not java version 1.6, it will check java version 1.7. + Push $6 + Push "1.7" + Call StrStr + Pop $1 + ${If} $1 == "" ; if not java version 1.7, system does not support java. + goto NoEnv + ${EndIf} + ${EndIf} + ${EndIf} ${EndIf} ${If} $R0 == "" diff --git a/os_stubs/windows/javacheck-32.exe b/os_stubs/windows/javacheck-32.exe deleted file mode 100644 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 index b08ca86..0000000 Binary files a/os_stubs/windows/javacheck-64.exe and /dev/null differ diff --git a/package/build.windows b/package/build.windows index 5f5b541..574af2a 100755 --- a/package/build.windows +++ b/package/build.windows @@ -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!"