[Greater-commits] r3823 - trunk/packaging
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Nov 22 15:59:13 CET 2011
Author: aheinecke
Date: 2011-11-22 15:59:13 +0100 (Tue, 22 Nov 2011)
New Revision: 3823
Modified:
trunk/packaging/greater-installer.nsi
trunk/packaging/makeinstaller.py
Log:
Make password settable from the installer
Modified: trunk/packaging/greater-installer.nsi
===================================================================
--- trunk/packaging/greater-installer.nsi 2011-11-21 16:18:16 UTC (rev 3822)
+++ trunk/packaging/greater-installer.nsi 2011-11-22 14:59:13 UTC (rev 3823)
@@ -22,12 +22,17 @@
; Modern UI
!include "MUI.nsh"
+ !include "includes\trim.nsh"
+ !include "LogicLib.nsh"
; Add (custom) plugin dir
!addplugindir plugins
;--------------------------------
; Variable declarations
Var POSTGRESQL_INSTALLED
+ Var SHOULD_AUTOLOGIN
+ Var DB_PASSWORD
+ Var SERVERNAME
;--------------------------------
;Version Information (for installer file properties)
@@ -48,9 +53,7 @@
Name "${productname}"
OutFile "${setupname}"
InstallDir "$PROGRAMFILES\${productname_short}"
- InstType "Single User"
- InstType "Client Only"
- InstType "Server Only"
+ InstType "Standard"
;--------------------------------
;Interface Settings
@@ -75,6 +78,7 @@
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
Page custom CustomPageOptions
+ Page custom PasswordPage PasswordPageLeave
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
@@ -96,7 +100,28 @@
!insertmacro MUI_RESERVEFILE_LANGDLL
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
ReserveFile "installer-options.ini"
+ ReserveFile "password-options.ini"
+;-------------------------------
+; Macros for user management
+!macro GetServerName SERVER_NAME_OUT
+ System::Call 'kernel32.dll::GetComputerNameExW(i 4,w .r0,*i ${NSIS_MAX_STRLEN} r1)i.r2'
+ ${If} $2 = 1
+ StrCpy ${SERVER_NAME_OUT} "\\$0"
+ ${Else}
+ System::Call "kernel32.dll::GetComputerNameW(t .r0,*i ${NSIS_MAX_STRLEN} r1)i.r2"
+ ${If} $2 = 1
+ StrCpy ${SERVER_NAME_OUT} "\\$0"
+ ${Else}
+ StrCpy ${SERVER_NAME_OUT} ""
+ ${EndIf}
+ ${EndIf}
+!macroend
+
+!macro DeleteUser SERVER_NAME USERNAME
+ # Delete a user
+ System::Call 'netapi32::NetUserDel(w "${SERVER_NAME}",w "${USERNAME}")i.r0'
+!macroend
;--------------------------------
;Installer Sections
@@ -131,12 +156,15 @@
;PostgreSQL Installation
Section "PostgreSQL 9.0.4" SecPostgreSQL
Banner::show /NOUNLOAD /set 76 "Installing..." "PostgreSQL 9.0.4" ""
+ !insertmacro GetServerName $SERVERNAME
+ !insertmacro DeleteUser $SERVERNAME "greater-db"
+
SetOutPath "$TEMP"
File "postgresql-9.0.4-1-windows.exe" ; Should be more generalized
DetailPrint "Installing PostgreSQL..."
ExecWait '"$TEMP\postgresql-9.0.4-1-windows.exe" --mode unattended --prefix "$INSTDIR\postgres9" \
- --superpassword greater --superaccount greater \
- --serviceaccount greater-db --servicepassword greater \
+ --superpassword $DB_PASSWORD --superaccount greater \
+ --serviceaccount greater-db --servicepassword $DB_PASSWORD \
--datadir "$INSTDIR\GREAT-ER-DB\database" --create_shortcuts 0 \
--servicename greater_postgres_server --unattendedmodeui minimal \
--debugtrace "$INSTDIR\postgres_installation.txt" --debuglevel 2 \
@@ -146,7 +174,7 @@
IntCmp $0 0 pgInstallOK
MessageBox MB_OK|MB_ICONEXCLAMATION "Your PostgreSQL database installation failed! $\r$\n \
Please report this issue to http://wald.intevation.org/tracker/?group_id=55 $\r$\n \
- with the attached installation log that you can find at:$\r$\n %TMP%\install-postgresql.log"
+ with the attached installation log that you can find at:$\r$\n $TEMP\install-postgresql.log"
pgInstallOK:
@@ -154,7 +182,7 @@
;--------------------------------
; Install default database
; Set the temporary PGPASSWORD variable for this process and it's children
- System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PGPASSWORD", "greater").r0'
+ System::Call 'Kernel32::SetEnvironmentVariableA(t, t) i("PGPASSWORD", "$DB_PASSWORD").r0'
SetOutPath "$TEMP"
File "defaultdata\defaultdb.backup"
@@ -291,10 +319,17 @@
IntCmp $R0 0 no_start_menu
# Create new Start menu entries
CreateDirectory "$SMPROGRAMS\${productname}"
+ IntCmp $SHOULD_AUTOLOGIN 0 no_autologin
CreateShortCut "$SMPROGRAMS\${productname}\${productname_short} Sediment.lnk" \
"$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-Sediment\${executable}" \
- "greater/greater at greater-sediment"' \
+ "greater/$DB_PASSWORD at greater-sediment"' \
"$INSTDIR\GREAT-ER-Sediment\Resources\greater2.ico"
+ goto no_start_menu
+ no_autologin:
+ CreateShortCut "$SMPROGRAMS\${productname}\${productname_short} Sediment.lnk" \
+ "$INSTDIR\python\pythonw.exe" "$INSTDIR\GREAT-ER-Sediment\${executable}" \
+ "$INSTDIR\GREAT-ER-Sediment\Resources\greater2.ico"
+
no_start_menu:
# ** Desktop Icon **
@@ -305,10 +340,16 @@
"Field 3" "State"
IntCmp $R0 0 no_desktop
# Create new Desktop link
+ IntCmp $SHOULD_AUTOLOGIN 0 desktop_no_autologin
CreateShortCut "$DESKTOP\${productname_short} Sediment.lnk" \
"$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-Sediment\${executable}" \
- "greater/greater at greater-sediment"' \
+ "greater/$DB_PASSWORD at greater-sediment"' \
"$INSTDIR\GREAT-ER-Sediment\Resources\greater2.ico"
+ goto no_desktop
+ desktop_no_autologin:
+ CreateShortCut "$DESKTOP\${productname_short} Sediment.lnk" \
+ "$INSTDIR\python\pythonw.exe" "$INSTDIR\GREAT-ER-Sediment\${executable}" \
+ "$INSTDIR\GREAT-ER-Sediment\Resources\greater2.ico"
no_desktop:
Return
@@ -342,10 +383,16 @@
IntCmp $R0 0 no_start_menu
# Create new Start menu entries
CreateDirectory "$SMPROGRAMS\${productname}"
+ IntCmp $SHOULD_AUTOLOGIN 0 no_autologin_2
CreateShortCut "$SMPROGRAMS\${productname}\${productname_short}.lnk" \
- "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-CEFIC\${executable}" greater/greater at greater' \
+ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-CEFIC\${executable}" greater/$DB_PASSWORD at greater' \
"$INSTDIR\GREAT-ER-CEFIC\Resources\greater2.ico"
-
+ goto manuals
+ no_autologin_2:
+ CreateShortCut "$SMPROGRAMS\${productname}\${productname_short}.lnk" \
+ "$INSTDIR\python\pythonw.exe" "$INSTDIR\GREAT-ER-CEFIC\${executable}" \
+ "$INSTDIR\GREAT-ER-CEFIC\Resources\greater2.ico"
+ manuals:
CreateDirectory "$SMPROGRAMS\${productname}\Documentation"
CreateShortCut "$SMPROGRAMS\${productname}\Documentation\GREAT-ER Manual.lnk" '"$INSTDIR\GREAT-ER-CEFIC\doc\greater-manual.pdf"'
CreateShortCut "$SMPROGRAMS\${productname}\Documentation\GREAT-ER Installation.lnk" '"$INSTDIR\GREAT-ER-CEFIC\doc\greater-installation.pdf"'
@@ -359,12 +406,18 @@
# Check if the desktop entries where requested.
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "installer-options.ini" \
"Field 3" "State"
- IntCmp $R0 0 no_desktop
+ IntCmp $R0 0 no_desktop2
# Create new Desktop link
+ IntCmp $SHOULD_AUTOLOGIN 0 no_autologin3
CreateShortCut "$DESKTOP\${productname_short}.lnk" \
- "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-CEFIC\${executable}" greater/greater at greater' \
+ "$INSTDIR\python\pythonw.exe" '"$INSTDIR\GREAT-ER-CEFIC\${executable}" greater/$DB_PASSWORD at greater' \
"$INSTDIR\GREAT-ER-CEFIC\Resources\greater2.ico"
- no_desktop:
+ goto no_desktop2
+ no_autologin3:
+ CreateShortCut "$DESKTOP\${productname_short}.lnk" \
+ "$INSTDIR\python\pythonw.exe" "$INSTDIR\GREAT-ER-CEFIC\${executable}" \
+ "$INSTDIR\GREAT-ER-CEFIC\Resources\greater2.ico"
+ no_desktop2:
Return
@@ -376,23 +429,22 @@
Function ".onInit"
newadvsplash::show /NOUNLOAD 2000 1000 500 -2 /BANNER "banner.png"
- InstTypeSetText 0 "Full (recommended)"
- InstTypeSetText 1 "Client only (no Database)"
- InstTypeSetText 2 "Server only"
- SectionSetInstTypes ${sediment_section_id} 1
- SectionSetInstTypes ${client_section_id} 3
- SectionSetInstTypes ${common_section_id} 3
- SectionSetInstTypes ${SecPostgreSQL} 5
- SectionSetInstTypes ${admin_section_id} 5
+ InstTypeSetText 0 "Standard"
+ SectionSetInstTypes ${sediment_section_id} 0
+ SectionSetInstTypes ${client_section_id} 1
+ SectionSetInstTypes ${common_section_id} 1
+ SectionSetInstTypes ${SecPostgreSQL} 1
+ SectionSetInstTypes ${admin_section_id} 1
SectionSetInstTypes ${gpp_section_id} 1
SectionSetFlags ${client_section_id} 1
SectionSetFlags ${SecPostgreSQL} 1
SectionSetFlags ${admin_section_id} 1
- SectionSetFlags ${sediment_section_id} 1
+ SectionSetFlags ${sediment_section_id} 0
SectionSetFlags ${gpp_section_id} 1
SectionSetFlags ${common_section_id} 17
SectionSetSize ${SecPostgreSQL} "207330"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "installer-options.ini"
+ !insertmacro MUI_INSTALLOPTIONS_EXTRACT "password-options.ini"
call CheckExistingVersion
CALL DetectPostgreSQL
FunctionEnd
@@ -439,11 +491,11 @@
; Custom Page for add Desktop, Startmenu and Quick Launch links
Function CustomPageOptions
- !insertmacro MUI_HEADER_TEXT "$(T_InstallOptions)" "$(T_InstallOptLinks)"
+ !insertmacro MUI_HEADER_TEXT "Configuration" "$(T_InstallOptLinks)"
# Note that the default selection is done in the ini file.
!insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
- "Field 1" "Text" "Please select where ${productname_short} should place shortcuts:"
+ "Field 1" "Text" "Please select where ${productname_short} shortcuts should be placed:"
!insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
"Field 2" "Text" "Start Menu"
!insertmacro MUI_INSTALLOPTIONS_WRITE "installer-options.ini" \
@@ -453,25 +505,44 @@
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "installer-options.ini"
FunctionEnd
-; AbortDisplayLogOption - give the user the option to display an error log
-; and abort the installation.
-; R8 - Error message
-; R9 - Log filename;
-Function AbortDisplayLogOption
+Function PasswordPageLeave
- ; Display a message box with the error
- MessageBox MB_YESNO|MB_ICONSTOP "$R8$\r$\n$\r$\nDo you wont to open '$R9'?" IDYES adlo_show_error_log
+ !insertmacro MUI_INSTALLOPTIONS_READ $0 "password-options.ini" "Field 3" "State"
+ !insertmacro MUI_INSTALLOPTIONS_READ $1 "password-options.ini" "Field 5" "State"
- ; If the user selects NO, simply abort the installation
- Abort "$R8"
+ StrCmp $0 $1 0 no_match
+ StrLen $2 $0
+ IntCmp $2 0 empty
+ Push $0
+ Call CheckForSpaces
+ Pop $2
+ IntCmp $2 0 continue spaces spaces
+
+ empty:
+ MessageBox MB_OK|MB_ICONSTOP "An empty password is not allowed"
+ Abort
+ no_match:
+ MessageBox MB_OK|MB_ICONSTOP "The passwords do not match"
+ Abort
+ spaces:
+ MessageBox MB_OK|MB_ICONSTOP "The password may not contain spaces"
+ Abort
+ continue:
+ StrCpy $DB_PASSWORD $0
+ !insertmacro MUI_INSTALLOPTIONS_READ $SHOULD_AUTOLOGIN "password-options.ini" \
+ "Field 6" "State"
Return
+FunctionEnd
- adlo_show_error_log:
- ;Otherwise show the error log first
- ExecShell "open" "$R9"
- Abort "$R8"
- Return
+; Custom Page for Password input
+Function PasswordPage
+ ${IfNot} ${SectionIsSelected} ${SecPostgreSQL}
+ Abort
+ ${EndIf}
+ !insertmacro MUI_HEADER_TEXT "Configuration" "Database Password"
+ !insertmacro MUI_INSTALLOPTIONS_DISPLAY "password-options.ini"
FunctionEnd
+
;---------------------
; Disable the next button on the components page as long as there
; are no sections selected
@@ -633,6 +704,7 @@
# From Function CustomPageOptions
# English
LangString T_InstallOptions ${LANG_ENGLISH} "Install Options"
+LangString T_PasswordOptions ${LANG_ENGLISH} "Password"
LangString T_InstallOptLinks ${LANG_ENGLISH} "Shortcut Options"
LangString T_InstOptLabelA ${LANG_ENGLISH} "Please select where ${productname_short} shall install links:"
LangString T_InstOptFieldA ${LANG_ENGLISH} "Start Menu"
Modified: trunk/packaging/makeinstaller.py
===================================================================
--- trunk/packaging/makeinstaller.py 2011-11-21 16:18:16 UTC (rev 3822)
+++ trunk/packaging/makeinstaller.py 2011-11-22 14:59:13 UTC (rev 3823)
@@ -41,7 +41,7 @@
"productname_short" : "GREAT-ER",
"description" : ("Geo-referenced Regional Exposure "
"Assessment Tool for European Rivers"),
- "version_number" : "3.0.0.1",
+ "version_number" : "3.0.0.2",
"version_date" : time.strftime("%Y-%m-%d-%H-%M")}
More information about the Greater-commits
mailing list