[Title] Windows stub(nsis) can get current time.
authoryongsung1.kim <yongsung1.kim@samsung.com>
Wed, 10 Jul 2013 07:21:48 +0000 (16:21 +0900)
committeryongsung1.kim <yongsung1.kim@samsung.com>
Wed, 10 Jul 2013 07:21:48 +0000 (16:21 +0900)
[Detail] InstallManager makes a temporary directory as 'tizensdk_<currenttime>' for installation.
         However current time is compile time until now. so, we fixed nsis script for getting real current time.
[Issue] redmine #9920

os_stubs/windows/InstallManager-64.nsi
os_stubs/windows/InstallManager.nsi

index a275d0c..b8d9cf3 100644 (file)
@@ -10,11 +10,67 @@ Icon "SDK_icon.ico"
 !include LogicLib.nsh\r
 !insertmacro GetParameters\r
 !insertmacro GetOptions\r
-!define /date MYTIMESTAMP "%Y%m%d%H%M%S"\r
+\r
+### TimeStamp\r
+!ifndef TimeStamp\r
+    !define TimeStamp "!insertmacro _TimeStamp" \r
+    !macro _TimeStamp FormatedString\r
+        !ifdef __UNINSTALL__\r
+            Call un.__TimeStamp\r
+        !else\r
+            Call __TimeStamp\r
+        !endif\r
+        Pop ${FormatedString}\r
+    !macroend\r
+\r
+!macro __TimeStamp UN\r
+Function ${UN}__TimeStamp\r
+    ClearErrors\r
+    ## Store the needed Registers on the stack\r
+        Push $0 ; Stack $0\r
+        Push $1 ; Stack $1 $0\r
+        Push $2 ; Stack $2 $1 $0\r
+        Push $3 ; Stack $3 $2 $1 $0\r
+        Push $4 ; Stack $4 $3 $2 $1 $0\r
+        Push $5 ; Stack $5 $4 $3 $2 $1 $0\r
+        Push $6 ; Stack $6 $5 $4 $3 $2 $1 $0\r
+\r
+    ## Call System API to get the current system Time\r
+        System::Alloc 16\r
+        Pop $0\r
+        System::Call 'kernel32::GetLocalTime(i) i(r0)'\r
+        System::Call '*$0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)i (.r1, .r2, n, .r3, .r4, .r5, .r6)'\r
+        System::Free $0\r
+\r
+        IntFmt $2 "%02i" $2\r
+        IntFmt $3 "%02i" $3\r
+        IntFmt $4 "%02i" $4\r
+        IntFmt $5 "%02i" $5\r
+        IntFmt $6 "%02i" $6\r
+\r
+    ## Generate Timestamp\r
+        StrCpy $0 "$1$2$3$4$5$6" \r
+\r
+    ## Restore the Registers and add Timestamp to the Stack\r
+        Pop $6  ; Stack $5 $4 $3 $2 $1 $0\r
+        Pop $5  ; Stack $4 $3 $2 $1 $0\r
+        Pop $4  ; Stack $3 $2 $1 $0\r
+        Pop $3  ; Stack $2 $1 $0\r
+        Pop $2  ; Stack $1 $0\r
+        Pop $1  ; Stack $0\r
+        Exch $0 ; Stack ${TimeStamp}\r
+\r
+FunctionEnd\r
+!macroend\r
+!insertmacro __TimeStamp "" \r
+!insertmacro __TimeStamp "un." \r
+!endif\r
+###########\r
 \r
 section\r
   ${GetParameters} $R0\r
   ${GetExePath} $R1\r
+  ${TimeStamp} $0\r
   SetRegView 64\r
 \r
   StrCpy $1 "SOFTWARE\JavaSoft\Java Runtime Environment"\r
@@ -33,7 +89,7 @@ section
 \r
   done:\r
   StrCpy $2 '-path "$R1"'\r
-  StrCpy $INSTDIR "$TEMP\tizensdk_${MYTIMESTAMP}"\r
+  StrCpy $INSTDIR "$TEMP\tizensdk_$0}"\r
   RMDir /r $INSTDIR\r
   SetOutPath $INSTDIR\r
   SetOverwrite on\r
index d0f1419..f7de70c 100644 (file)
@@ -10,11 +10,67 @@ Icon "SDK_icon.ico"
 !include LogicLib.nsh\r
 !insertmacro GetParameters\r
 !insertmacro GetOptions\r
-!define /date MYTIMESTAMP "%Y%m%d%H%M%S"\r
+\r
+### TimeStamp\r
+!ifndef TimeStamp\r
+    !define TimeStamp "!insertmacro _TimeStamp" \r
+    !macro _TimeStamp FormatedString\r
+        !ifdef __UNINSTALL__\r
+            Call un.__TimeStamp\r
+        !else\r
+            Call __TimeStamp\r
+        !endif\r
+        Pop ${FormatedString}\r
+    !macroend\r
+\r
+!macro __TimeStamp UN\r
+Function ${UN}__TimeStamp\r
+    ClearErrors\r
+    ## Store the needed Registers on the stack\r
+        Push $0 ; Stack $0\r
+        Push $1 ; Stack $1 $0\r
+        Push $2 ; Stack $2 $1 $0\r
+        Push $3 ; Stack $3 $2 $1 $0\r
+        Push $4 ; Stack $4 $3 $2 $1 $0\r
+        Push $5 ; Stack $5 $4 $3 $2 $1 $0\r
+        Push $6 ; Stack $6 $5 $4 $3 $2 $1 $0\r
+\r
+    ## Call System API to get the current system Time\r
+        System::Alloc 16\r
+        Pop $0\r
+        System::Call 'kernel32::GetLocalTime(i) i(r0)'\r
+        System::Call '*$0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)i (.r1, .r2, n, .r3, .r4, .r5, .r6)'\r
+        System::Free $0\r
+\r
+        IntFmt $2 "%02i" $2\r
+        IntFmt $3 "%02i" $3\r
+        IntFmt $4 "%02i" $4\r
+        IntFmt $5 "%02i" $5\r
+        IntFmt $6 "%02i" $6\r
+\r
+    ## Generate Timestamp\r
+        StrCpy $0 "$1$2$3$4$5$6" \r
+\r
+    ## Restore the Registers and add Timestamp to the Stack\r
+        Pop $6  ; Stack $5 $4 $3 $2 $1 $0\r
+        Pop $5  ; Stack $4 $3 $2 $1 $0\r
+        Pop $4  ; Stack $3 $2 $1 $0\r
+        Pop $3  ; Stack $2 $1 $0\r
+        Pop $2  ; Stack $1 $0\r
+        Pop $1  ; Stack $0\r
+        Exch $0 ; Stack ${TimeStamp}\r
+\r
+FunctionEnd\r
+!macroend\r
+!insertmacro __TimeStamp "" \r
+!insertmacro __TimeStamp "un." \r
+!endif\r
+###########\r
 \r
 section\r
   ${GetParameters} $R0\r
   ${GetExePath} $R1\r
+  ${TimeStamp} $0\r
 \r
   StrCpy $1 "SOFTWARE\JavaSoft\Java Runtime Environment"\r
   StrCpy $2 0\r
@@ -32,7 +88,7 @@ section
 \r
   done:\r
   StrCpy $2 '-path "$R1"'\r
-  StrCpy $INSTDIR "$TEMP\tizensdk_${MYTIMESTAMP}"\r
+  StrCpy $INSTDIR "$TEMP\tizensdk_$0"\r
   RMDir /r $INSTDIR\r
   SetOutPath $INSTDIR\r
   SetOverwrite on\r