Mercurial > trustbridge
view packaging/trustbridge.nsi @ 1307:2bacaec6e101
(perf) Use cached values to deterimine elevation.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 13 Oct 2014 12:32:13 +0200 |
parents | 9f5893faa60b |
children | 303de3160a83 |
line wrap: on
line source
; Copyright (C) 2014 by Bundesamt f�r Sicherheit in der Informationstechnik ; Software engineering by Intevation GmbH ; ; This file is Free Software under the GNU GPL (v>=2) ; and comes with ABSOLUTELY NO WARRANTY! ; See LICENSE.txt for details. ; This script creates the installer for renameme it needs the ; following definitions to be set when calling makensis: ; ; productname: Name of the Software as it will show up under installed ; Software ; company: The publisher of this software. (Windows needs this) ; version_number: The version of the software ; setupname: The name for the result created by this ; productname_short: Used for the default folder name and such ; files_dir: the path to the files ;-------------------------------- ; Includes !define MULTIUSER_EXECUTIONLEVEL Highest !define MULTIUSER_MUI !define MULTIUSER_INSTALLMODE_COMMANDLINE !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "Software\${productname_short}" !define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "" !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "Software\${productname_short}" !define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "" !define MULTIUSER_INSTALLMODE_INSTDIR "${productname_short}" !addplugindir "${plugin_dir}" !addincludedir "${plugin_dir}" !include "MultiUser.nsh" !include "MUI2.nsh" !include "FileFunc.nsh" !include "WinVer.nsh" ;-------------------------------- ;Version Information (for installer file properties) ;VIProductVersion "${version_number}" ;needs integer format: x.x.x.x VIProductVersion 1.0.0.0 VIAddVersionKey "ProductName" "${productname_short}" VIAddVersionKey "Comments" "${productname_short} ist Freie Software" VIAddVersionKey "CompanyName" "${company}" VIAddVersionKey "LegalTrademarks" "" VIAddVersionKey "LegalCopyright" "${copyright}" VIAddVersionKey "FileDescription" "${description}" VIAddVersionKey "FileVersion" "${version_number}" Var StartMenuFolder Var douninstcertificates Var uninstCertificates ;-------------------------------- ; General ; Define Name, File and Installdir of Installer Name "${productname}" OutFile "${setupname}" InstallDir "$PROGRAMFILES\${productname_short}" BrandingText "${company} - ${productname}" ;-------------------------------- ; Interface Settings ; MUI Images / Icons !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_BITMAP "resources\header-install.bmp" !define MUI_HEADERIMAGE_UNBITMAP "resources\header-uninstall.bmp" !define MUI_WELCOMEFINISHPAGE_BITMAP "resources\wizard-install.bmp" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "resources\wizard-uninstall.bmp" !define MUI_ICON "resources\install.ico" !define MUI_UNICON "resources\uninstall.ico" ; MUI welcome page text !define MUI_WELCOMEPAGE_TITLE "Willkommen zur Installation von TrustBridge ${version_number}" ;!define MUI_WELCOMEPAGE_TITLE_3LINES !define MUI_WELCOMEPAGE_TEXT "${productname} ist eine Anwendung \ um Wurzelzertifikate auf ihrem System zu installieren und aktuell zu halten. \ $\r$\n$\r$\n$\r$\n$\r$\n \ Achtung: Dies ist eine Testversion!" !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_UNFINISHPAGE_NOAUTOCLOSE !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${productname_short}" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" ;-------------------------------- ; Pages !define MUI_FINISHPAGE_TITLE "Die Installation war erfolgreich" !define MUI_FINISHPAGE_TEXT "${productname} wurde auf Ihrem \ Computer installliert. $\r$\n$\r$\n\ Klicken Sie auf 'Fertig stellen', um den Installations-Assistenten\ zu schlie�en." !define MUI_FINISHPAGE_RUN $INSTDIR\trustbridge.exe !define MUI_FINISHPAGE_RUN_TEXT "Anwendung starten" !define MUI_FINISHPAGE_RUN_FUNCTION RunAsUser !define MUI_FINISHPAGE_LINK "Mehr unter ${info_url}" !define MUI_FINISHPAGE_LINK_LOCATION "${info_url}" !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !ifdef WRITE_UNINSTALLER !define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome !define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES Function un.ModifyUnWelcome ${NSD_CreateCheckbox} 120u -18u 50% 12u "Verwaltete Zertifikate entfernen." Pop $uninstCertificates SetCtlColors $uninstCertificates "" ${MUI_BGCOLOR} ${NSD_Check} $uninstCertificates ; Check it by default FunctionEnd Function un.LeaveUnWelcome ${NSD_GetState} $uninstCertificates $0 StrCpy $douninstcertificates "FALSE" ${If} $0 <> 0 StrCpy $douninstcertificates "TRUE" ${EndIf} FunctionEnd !endif !insertmacro MUI_LANGUAGE "German" ;-------------------------------- ; Install Functions Function ".onInit" !ifdef WRITE_UNINSTALLER SetOutPath "c:\tmp-uninstaller" WriteUninstaller "c:\tmp-uninstaller\Uninstall.exe" Quit !endif ${IfNot} ${AtLeastWinVista} MessageBox MB_ICONSTOP "Windows XP und �ltere Windows Versionen werden von dieser Anwendung nicht unterst�tzt." Quit ${Endif} UserInfo::GetAccountType pop $0 ${If} $0 != "admin" MessageBox MB_ICONINFORMATION|MB_YESNO "\ Sie sind im Begriff ${productname} ohne Administratorrechte zu installieren. $\r$\n\ $\r$\n\ Ohne Administratorrechte werden Sie von Windows zur Best�tigung jeder Zertifikats�nderung einzeln aufgefordert. $\r$\n$\r$\n\ Wenn Sie die M�glichkeit besitzen Administratorrechte auf diesem System zu erlangen, starten Sie diesen Installer \ erneut mit der Funktion 'Als Administrator ausf�hren'. $\r$\n$\r$\n\ M�chten Sie die Installation ohne Administratorrechte fortsetzen?" /SD IDYES IDYES goOn IDNO stopNow stopNow: Quit goOn: ${EndIf} Var /GLOBAL is_update Var /GLOBAL changed_dir ${GetParameters} $R0 ClearErrors ${GetOptions} $R0 /UPDATE= $is_update ; Check if the install directory was modified on the command line StrCmp "$INSTDIR" "$PROGRAMFILES\${productname_short}" unmodified 0 ; It is modified. Save that value. StrCpy $changed_dir "$INSTDIR" ; MULITUSER_INIT overwrites directory setting from command line !insertmacro MULTIUSER_INIT StrCpy $INSTDIR "$changed_dir" goto initDone unmodified: !insertmacro MULTIUSER_INIT initDone: FunctionEnd ; If we run elevated we do not want to run ; the UI elevated as this could be a security ; problem. Function RunAsUser DesktopShellRun::Exec "$INSTDIR\trustbridge.exe" FunctionEnd ;-------------------------------- ; UnInstall Functions Function "un.onInit" !insertmacro MULTIUSER_UNINIT FunctionEnd Section "" StrCmp $is_update '1' wait_a_bit continue wait_a_bit: ; The trustbridge.exe might need some time to close ; lets give it a chance to avoid failing to overwrite it Sleep 1000 continue: ; The actual installation SetOutPath "$INSTDIR" !include "filelist_in.nsh" SetOutPath "$INSTDIR" ;Create uninstaller !ifndef WRITE_UNINSTALLER File "${files_dir}${path_sep}Uninstall.exe" !endif ; Code below is not run on updates StrCmp $is_update '1' done WriteRegStr SHCTX "Software\${productname_short}" "" $INSTDIR ; Set up autostart WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "TrustBridge" "$INSTDIR\trustbridge.exe --tray" ; Register logging WriteRegStr SHCTX "System\CurrentControlSet\services\eventlog\Application\${productname_short}" "CategoryMessageFile" "$INSTDIR\trustbridge.exe" WriteRegStr SHCTX "System\CurrentControlSet\services\eventlog\Application\${productname_short}" "EventMessageFile" "$INSTDIR\trustbridge.exe" WriteRegStr SHCTX "System\CurrentControlSet\services\eventlog\Application\${productname_short}" "ParameterMessageFile" "$INSTDIR\trustbridge.exe" WriteRegDword SHCTX "System\CurrentControlSet\services\eventlog\Application\${productname_short}" "TypesSupported" 5 WriteRegDword SHCTX "System\CurrentControlSet\services\eventlog\Application\${productname_short}" "CategoryCount" 3 ; Register Uninstaller WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" \ "DisplayName" "${productname}" WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" \ "DisplayIcon" "$\"$INSTDIR\trustbridge.exe$\"" WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" \ "DisplayVersion" "${version_number}" WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" \ "Publisher" "${company}" WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" \ "URLInfoAbout" "${info_url}" WriteRegDword SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" \ "EstimatedSize" "${size}" WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" \ "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" \ "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" ; Below this is HKCU only! SetShellVarContext current !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts CreateDirectory "$SMPROGRAMS\$StartMenuFolder" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\${productname}.lnk" "$INSTDIR\trustbridge.exe" !insertmacro MUI_STARTMENU_WRITE_END done: StrCmp $is_update '1' run_silent dont_run run_silent: DesktopShellRun::Exec "$INSTDIR\trustbridge.exe" "--tray" dont_run: SectionEnd !ifdef WRITE_UNINSTALLER !include "StrFunc.nsh" Section "Uninstall" StrCmp "$douninstcertificates" "TRUE" 0 skip_certs ExpandEnvStrings $0 %LOCALAPPDATA% nsExec::ExecToLog '"$INSTDIR\trustbridge-certificate-installer.exe" "list=$0\BSI\TrustBridge\list-installed.txt" "choices=uninstall"' Delete "$0\BSI\TrustBridge\list*.txt" Delete "$0\BSI\TrustBridge\SW*.exe" RmDir "$0\BSI\TrustBridge" RmDir "$0\BSI" ExpandEnvStrings $0 %APPDATA% Delete "$0\BSI\TrustBridge.ini" RmDir "$0\BSI" var /GLOBAL user_count StrCpy $user_count 0 UserInfo::GetAccountType pop $0 ${If} $0 == "admin" ${Do} ; Loop over profile keys EnumRegKey $R1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" $R0 ${If} $R1 != "" ${UnStrStr} $R2 $R1 "S-1-5-21-" ;Search for S-1-5-21- ${If} $R2 != "" IntOp $user_count $user_count + 1 ${EndIf} IntOp $R0 $R0 + 1 ${EndIf} ${LoopUntil} $R1 == "" ${if} $user_count > 1 MessageBox MB_ICONINFORMATION|MB_YESNO "\ Zertifikate, die f�r andere Nutzer im Zertifikatsspeicher von Firefox und Thunderbird installiert wurden, k�nnen erst beim der n�chsten \ Anmeldung dieser Nutzer deinstalliert werden. \ $\r$\n$\r$\n\ Die Deinstallation der Zertifikate wird von der folgenden Anwendung durchgef�hrt: $\r$\n '$INSTDIR\trustbridge-nss-installer.exe' $\r$\n$\r$\n\ Wenn Zertifikate auch aus den Thunderbird- und Firefox-Speichern anderer Nutzer deinstalliert werden sollen, w�hlen \ Sie bitte 'Nein' und l�schen Sie 'trustbridge-nss-installer.exe' manuell nachdem die anderen Nutzer sich einmal angemeldet hatten.$\r$\n \ $\r$\n\ Soll '$INSTDIR\trustbridge-nss-installer.exe' jetzt entfernt werden?" /SD IDYES IDYES deleteNSSInstaller IDNO dontDeleteNSS ${Else} goto deleteNSSInstaller ${Endif} ${Else} Delete "$INSTDIR\trustbridge-nss-installer.exe" ${EndIf} skip_certs: deleteNSSInstaller: Delete "$INSTDIR\trustbridge-nss-installer.exe" dontDeleteNSS: !include "filelist_un.nsh" Delete "$INSTDIR\Uninstall.exe" RMDir "$INSTDIR" !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder DeleteRegValue SHCTX "Software\${productname_short}" "Start Menu Folder" DeleteRegKey /ifempty SHCTX "Software\${productname_short}" ; Unregister autostart DeleteRegValue SHCTX "Software\Microsoft\Windows\CurrentVersion\Run" "TrustBridge" ; Unregister logging DeleteRegKey SHCTX "System\CurrentControlSet\services\eventlog\Application\${productname_short}" ; Remove uninstaller DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}" ; Below this is HKCU only! SetShellVarContext current Delete "$SMPROGRAMS\$StartMenuFolder\${productname}.lnk" RMDir "$SMPROGRAMS\$StartMenuFolder" SectionEnd !endif