From 44937ef87281ca0873709c037e2d8dc91a94cd91 Mon Sep 17 00:00:00 2001 From: "yongsung1.kim" Date: Wed, 10 Jul 2013 16:21:48 +0900 Subject: [PATCH] [Title] Windows stub(nsis) can get current time. [Detail] InstallManager makes a temporary directory as 'tizensdk_' 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 | 60 ++++++++++++++++++++++++++++++++-- os_stubs/windows/InstallManager.nsi | 60 ++++++++++++++++++++++++++++++++-- 2 files changed, 116 insertions(+), 4 deletions(-) diff --git a/os_stubs/windows/InstallManager-64.nsi b/os_stubs/windows/InstallManager-64.nsi index a275d0c..b8d9cf3 100644 --- a/os_stubs/windows/InstallManager-64.nsi +++ b/os_stubs/windows/InstallManager-64.nsi @@ -10,11 +10,67 @@ Icon "SDK_icon.ico" !include LogicLib.nsh !insertmacro GetParameters !insertmacro GetOptions -!define /date MYTIMESTAMP "%Y%m%d%H%M%S" + +### TimeStamp +!ifndef TimeStamp + !define TimeStamp "!insertmacro _TimeStamp" + !macro _TimeStamp FormatedString + !ifdef __UNINSTALL__ + Call un.__TimeStamp + !else + Call __TimeStamp + !endif + Pop ${FormatedString} + !macroend + +!macro __TimeStamp UN +Function ${UN}__TimeStamp + ClearErrors + ## Store the needed Registers on the stack + Push $0 ; Stack $0 + Push $1 ; Stack $1 $0 + Push $2 ; Stack $2 $1 $0 + Push $3 ; Stack $3 $2 $1 $0 + Push $4 ; Stack $4 $3 $2 $1 $0 + Push $5 ; Stack $5 $4 $3 $2 $1 $0 + Push $6 ; Stack $6 $5 $4 $3 $2 $1 $0 + + ## Call System API to get the current system Time + System::Alloc 16 + Pop $0 + System::Call 'kernel32::GetLocalTime(i) i(r0)' + System::Call '*$0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)i (.r1, .r2, n, .r3, .r4, .r5, .r6)' + System::Free $0 + + IntFmt $2 "%02i" $2 + IntFmt $3 "%02i" $3 + IntFmt $4 "%02i" $4 + IntFmt $5 "%02i" $5 + IntFmt $6 "%02i" $6 + + ## Generate Timestamp + StrCpy $0 "$1$2$3$4$5$6" + + ## Restore the Registers and add Timestamp to the Stack + Pop $6 ; Stack $5 $4 $3 $2 $1 $0 + Pop $5 ; Stack $4 $3 $2 $1 $0 + Pop $4 ; Stack $3 $2 $1 $0 + Pop $3 ; Stack $2 $1 $0 + Pop $2 ; Stack $1 $0 + Pop $1 ; Stack $0 + Exch $0 ; Stack ${TimeStamp} + +FunctionEnd +!macroend +!insertmacro __TimeStamp "" +!insertmacro __TimeStamp "un." +!endif +########### section ${GetParameters} $R0 ${GetExePath} $R1 + ${TimeStamp} $0 SetRegView 64 StrCpy $1 "SOFTWARE\JavaSoft\Java Runtime Environment" @@ -33,7 +89,7 @@ section done: StrCpy $2 '-path "$R1"' - StrCpy $INSTDIR "$TEMP\tizensdk_${MYTIMESTAMP}" + StrCpy $INSTDIR "$TEMP\tizensdk_$0}" RMDir /r $INSTDIR SetOutPath $INSTDIR SetOverwrite on diff --git a/os_stubs/windows/InstallManager.nsi b/os_stubs/windows/InstallManager.nsi index d0f1419..f7de70c 100644 --- a/os_stubs/windows/InstallManager.nsi +++ b/os_stubs/windows/InstallManager.nsi @@ -10,11 +10,67 @@ Icon "SDK_icon.ico" !include LogicLib.nsh !insertmacro GetParameters !insertmacro GetOptions -!define /date MYTIMESTAMP "%Y%m%d%H%M%S" + +### TimeStamp +!ifndef TimeStamp + !define TimeStamp "!insertmacro _TimeStamp" + !macro _TimeStamp FormatedString + !ifdef __UNINSTALL__ + Call un.__TimeStamp + !else + Call __TimeStamp + !endif + Pop ${FormatedString} + !macroend + +!macro __TimeStamp UN +Function ${UN}__TimeStamp + ClearErrors + ## Store the needed Registers on the stack + Push $0 ; Stack $0 + Push $1 ; Stack $1 $0 + Push $2 ; Stack $2 $1 $0 + Push $3 ; Stack $3 $2 $1 $0 + Push $4 ; Stack $4 $3 $2 $1 $0 + Push $5 ; Stack $5 $4 $3 $2 $1 $0 + Push $6 ; Stack $6 $5 $4 $3 $2 $1 $0 + + ## Call System API to get the current system Time + System::Alloc 16 + Pop $0 + System::Call 'kernel32::GetLocalTime(i) i(r0)' + System::Call '*$0(&i2, &i2, &i2, &i2, &i2, &i2, &i2, &i2)i (.r1, .r2, n, .r3, .r4, .r5, .r6)' + System::Free $0 + + IntFmt $2 "%02i" $2 + IntFmt $3 "%02i" $3 + IntFmt $4 "%02i" $4 + IntFmt $5 "%02i" $5 + IntFmt $6 "%02i" $6 + + ## Generate Timestamp + StrCpy $0 "$1$2$3$4$5$6" + + ## Restore the Registers and add Timestamp to the Stack + Pop $6 ; Stack $5 $4 $3 $2 $1 $0 + Pop $5 ; Stack $4 $3 $2 $1 $0 + Pop $4 ; Stack $3 $2 $1 $0 + Pop $3 ; Stack $2 $1 $0 + Pop $2 ; Stack $1 $0 + Pop $1 ; Stack $0 + Exch $0 ; Stack ${TimeStamp} + +FunctionEnd +!macroend +!insertmacro __TimeStamp "" +!insertmacro __TimeStamp "un." +!endif +########### section ${GetParameters} $R0 ${GetExePath} $R1 + ${TimeStamp} $0 StrCpy $1 "SOFTWARE\JavaSoft\Java Runtime Environment" StrCpy $2 0 @@ -32,7 +88,7 @@ section done: StrCpy $2 '-path "$R1"' - StrCpy $INSTDIR "$TEMP\tizensdk_${MYTIMESTAMP}" + StrCpy $INSTDIR "$TEMP\tizensdk_$0" RMDir /r $INSTDIR SetOutPath $INSTDIR SetOverwrite on -- 2.7.4