Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit04f26d9

Browse files
committed
Add translates for messages
Additional checks:Check that service is runnningCheck that SELECT 1 is workingadd StrContains function to prooject
1 parent5f35b7f commit04f26d9

File tree

3 files changed

+157
-7
lines changed

3 files changed

+157
-7
lines changed

‎nsis/StrContains.nsh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; StrContains
2+
; This function does a case sensitive searches for an occurrence of a substring in a string.
3+
; It returns the substring if it is found.
4+
; Otherwise it returns null("").
5+
; Written by kenglish_hi
6+
; Adapted from StrReplace written by dandaman32
7+
8+
9+
Var STR_HAYSTACK
10+
Var STR_NEEDLE
11+
Var STR_CONTAINS_VAR_1
12+
Var STR_CONTAINS_VAR_2
13+
Var STR_CONTAINS_VAR_3
14+
Var STR_CONTAINS_VAR_4
15+
Var STR_RETURN_VAR
16+
17+
Function StrContains
18+
Exch$STR_NEEDLE
19+
Exch1
20+
Exch$STR_HAYSTACK
21+
; Uncomment to debug
22+
;MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK '
23+
StrCpy$STR_RETURN_VAR""
24+
StrCpy$STR_CONTAINS_VAR_1 -1
25+
StrLen$STR_CONTAINS_VAR_2$STR_NEEDLE
26+
StrLen$STR_CONTAINS_VAR_4$STR_HAYSTACK
27+
loop:
28+
IntOp$STR_CONTAINS_VAR_1$STR_CONTAINS_VAR_1 +1
29+
StrCpy$STR_CONTAINS_VAR_3$STR_HAYSTACK$STR_CONTAINS_VAR_2$STR_CONTAINS_VAR_1
30+
StrCmp$STR_CONTAINS_VAR_3$STR_NEEDLE found
31+
StrCmp$STR_CONTAINS_VAR_1$STR_CONTAINS_VAR_4 done
32+
Goto loop
33+
found:
34+
StrCpy$STR_RETURN_VAR$STR_NEEDLE
35+
Goto done
36+
done:
37+
Pop$STR_NEEDLE;Prevent "invalid opcode" errors and keep the
38+
Exch$STR_RETURN_VAR
39+
FunctionEnd
40+
41+
!macro _StrContainsConstructor OUT NEEDLE HAYSTACK
42+
Push`${HAYSTACK}`
43+
Push`${NEEDLE}`
44+
Call StrContains
45+
Pop`${OUT}`
46+
!macroend
47+
48+
!define StrContains'!insertmacro "_StrContainsConstructor"'

‎nsis/postgresql.nsi

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
!include"WinVer.nsh"
2525
!include"Ports.nsh"
2626
!include"x64.nsh"
27+
!include"StrContains.nsh"
2728
!insertmacro VersionCompare
28-
2929
;--------------------------------
3030
;General
3131
Name"${PRODUCT_NAME} ${PRODUCT_VERSION}"
@@ -199,12 +199,9 @@ SectionEnd
199199

200200
SectionGroup/e $(PostgreSQLString) serverGroup
201201

202-
Function writeUnIsn
203-
FunctionEnd
204-
205202

206203

207-
Section"Client components" secClient
204+
Section$(componentClient) secClient
208205

209206
/*${If} ${FileExists} "$INSTDIR\*.*"
210207
${orif} ${FileExists} "$INSTDIR"
@@ -280,7 +277,7 @@ Section "Client components" secClient
280277

281278
SectionEnd
282279

283-
Section $(PostgreSQLString) sec1
280+
Section $(componentServer) sec1
284281

285282
${if}$PG_OLD_DIR!=""; exist PG install
286283
MessageBoxMB_YESNO|MB_ICONQUESTION"$(MESS_STOP_SERVER)"IDYES doitStopIDNO noyetStop
@@ -624,6 +621,10 @@ Section $(PostgreSQLString) sec1
624621
FileWrite$0"#online_analyze.local_tracking = 'on'$\r$\n"
625622
FileWrite$0"#plantuner.fix_empty_table = 'on'$\r$\n"
626623
FileWrite$0"#online_analyze.enable = off$\r$\n"
624+
625+
;debug for unstarted server:
626+
;FileWrite $0 "effective_io_concurrency = 2$\r$\n"
627+
627628
FileClose$0
628629

629630
ErrFileCfg1:
@@ -730,6 +731,63 @@ Section $(PostgreSQLString) sec1
730731
FileWrite$LogFile"Start service OK$\r$\n"
731732

732733
${endif}
734+
735+
;check that service is running
736+
;sc query "postgrespro-X64-10" | find "RUNNING"
737+
738+
DetailPrint"Check service is running ..."
739+
call checkServiceIsRunning
740+
pop$0
741+
${if}$0==""
742+
Sleep5000
743+
call checkServiceIsRunning
744+
pop$0
745+
${if}$0==""
746+
DetailPrint"Error: service is not running!"
747+
MessageBoxMB_OK|MB_ICONSTOP"$(MESS_ERROR_SERVER)"
748+
FileWrite$LogFile"Error: service $ServiceID_text is not running!$\r$\n"
749+
FileClose$LogFile
750+
Abort
751+
${endif}
752+
${endif}
753+
754+
755+
;check connection to the server
756+
DetailPrint"Check connection ..."
757+
;Sleep 1000
758+
759+
FileWrite$LogFile"Check connection ...$\r$\n"
760+
FileWrite$LogFile'"$INSTDIR\bin\psql.exe" -p $TextPort_text -U "$UserName_text" -c "SELECT 1;" postgres$\r$\n'
761+
762+
;send password to Environment Variable PGPASSWORD
763+
${if}"$Pass1_text"!=""
764+
StrCpy$R0$Pass1_text
765+
System::Call'Kernel32::SetEnvironmentVariableA(t, t) i("PGPASSWORD", R0).r0'
766+
${endif}
767+
768+
nsExec::ExecToStack /TIMEOUT=10000'"$INSTDIR\bin\psql.exe" -p $TextPort_text -U "$UserName_text" -c "SELECT 1;" postgres'
769+
770+
pop$0
771+
pop$1# printed text, up to ${NSIS_MAX_STRLEN}
772+
${if}$0!=0
773+
DetailPrint"Checking connection has return $0"
774+
DetailPrint"Output: $1"
775+
FileWrite$LogFile"Checking connection has return $0$\r$\n"
776+
FileWrite$LogFile"Output: $1$\r$\n"
777+
778+
;MessageBox MB_OK "Create adminpack error: $1"
779+
MessageBoxMB_OK|MB_ICONSTOP"$(MESS_ERROR_SERVER)"
780+
FileClose$LogFile
781+
return
782+
${else}
783+
DetailPrint"Checking connection is OK"
784+
FileWrite$LogFile"Checking connection is OK$\r$\n"
785+
${endif}
786+
${if}"$Pass1_text"!=""
787+
StrCpy$R0""
788+
System::Call'Kernel32::SetEnvironmentVariableA(t, t) i("PGPASSWORD", R0).r0'
789+
${endif}
790+
;end check connection to the server
733791

734792
${if}$isDataDirExist==0
735793
;send password to Environment Variable PGPASSWORD
@@ -774,6 +832,9 @@ Section $(PostgreSQLString) sec1
774832

775833
SectionEnd
776834

835+
Section $(componentDeveloper) secDev
836+
!include devel_list.nsi
837+
SectionEnd
777838

778839
SectionGroupEnd
779840

@@ -858,6 +919,11 @@ SectionEnd
858919
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
859920
!insertmacro MUI_DESCRIPTION_TEXT${SecMS} $(DESC_SecMS)
860921
!insertmacro MUI_DESCRIPTION_TEXT${Sec1} $(DESC_Sec1)
922+
!insertmacro MUI_DESCRIPTION_TEXT${secClient} $(DESC_componentClient)
923+
!insertmacro MUI_DESCRIPTION_TEXT${secDev} $(DESC_componentDeveloper)
924+
925+
926+
861927
;!insertmacro MUI_DESCRIPTION_TEXT ${SecService} $(DESC_SecService)
862928
!insertmacro MUI_FUNCTION_DESCRIPTION_END
863929

@@ -1952,7 +2018,7 @@ ${EndIf}
19522018
IntOp$3${SF_SELECTED} |${SF_RO}
19532019
SectionSetFlags${secClient}$3
19542020
;SectionSetFlags ${secClient} ${SF_RO}
1955-
2021+
!define MUI_LANGDLL_ALLLANGUAGES
19562022
!insertmacro MUI_LANGDLL_DISPLAY;select language
19572023
StrCpy$PG_OLD_DIR""
19582024
StrCpy$DATA_DIR"$INSTDIR\data"
@@ -2131,3 +2197,22 @@ Function .onSelChange
21312197

21322198
${endif}
21332199
FunctionEnd
2200+
2201+
Function checkServiceIsRunning
2202+
nsExec::ExecToStack /TIMEOUT=10000'sc query "$ServiceID_text"'
2203+
pop$0
2204+
pop$1# printed text, up to ${NSIS_MAX_STRLEN}
2205+
${if}$0!='0'
2206+
push""
2207+
return
2208+
${endif}
2209+
2210+
${StrContains}$2"RUNNING""$1"
2211+
${if}$2==""
2212+
push""
2213+
return
2214+
${endif}
2215+
push"1"
2216+
2217+
FunctionEnd
2218+

‎nsis/translates.nsi

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,20 @@ The parameters are written to the file $DATA_DIR\postgresql.conf"
116116

117117
LangString MESS_ERROR_INITDB${LANG_ENGLISH}"An error occurred while initializing the database!"
118118
LangString MESS_ERROR_INITDB${LANG_RUSSIAN}"Ïðè èíèöèàëèçàöèè áàçû äàííûõ ïðîèçîøëà îøèáêà!"
119+
120+
121+
LangString componentServer${LANG_ENGLISH}"Server components"
122+
LangString componentServer${LANG_RUSSIAN}"Êîìïîíåíòû ñåðâåðà"
123+
124+
125+
LangString componentClient${LANG_ENGLISH}"Client components"
126+
LangString componentClient${LANG_RUSSIAN}"Êîìïîíåíòû êëèåíòà"
127+
128+
LangString componentDeveloper${LANG_ENGLISH}"Developer components"
129+
LangString componentDeveloper${LANG_RUSSIAN}"Êîìïîíåíòû ðàçðàáîò÷èêà"
130+
131+
LangString DESC_componentClient${LANG_ENGLISH}"Install PostgreSQL clients components and documetation"
132+
LangString DESC_componentClient${LANG_RUSSIAN}"Óñòàíîâêà ôàéëîâ êëèåíòà PostgreSQL è äîêóìåíòàöèè"
133+
134+
LangString DESC_componentDeveloper${LANG_ENGLISH}"Install PostgreSQL developer components"
135+
LangString DESC_componentDeveloper${LANG_RUSSIAN}"Óñòàíîâêà ôàéëîâ PostgreSQL äëÿ ðàçðàáîò÷èêà"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp