view packaging/trustbridge.nsi @ 831:747a48996c1f

(Issue13) Precompile uninstaller Create-dist-packge now creates a temporary installer that only writes the uninstaller. Then it excutes this installer (using wine) to create the uninstaller. That uninstaller is then packaged normaly and packaged instead of the written uninstaller.
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 24 Jul 2014 15:59:00 +0200
parents 95e14add5c50
children bd9d07c301fd
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}"

!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
;--------------------------------
; 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"
;!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_WELCOMEPAGE_TEXT "${productname} ist eine Anwendung \
um Wurzelzertifikate auf ihrem System zu installieren und aktuell zu halten."

!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
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
!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_OK "Windows XP und �ltere Windows Versionen werden von dieser Anwendung nicht unterst�tzt."
    Quit
  ${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
  ExecShell "" "$INSTDIR\trustbridge.exe"
FunctionEnd

;--------------------------------
; UnInstall Functions

Function "un.onInit"
  !insertmacro MULTIUSER_UNINIT
FunctionEnd

Section ""
; The actual installation
  SetOutPath "$INSTDIR"
  !include "filelist.nsh"

;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

  WriteRegStr SHCTX "Software\${productname_short}" "" $INSTDIR

; 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"

  !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:

SectionEnd

!ifdef WRITE_UNINSTALLER
Section "Uninstall"
  RMDir /r "$INSTDIR" ; TODO include uninstall files
; !include "filelist-un.nsh"
;  Delete "$INSTDIR\Uninstall.exe"
;  RMDir "$INSTDIR"

  !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder

  Delete "$SMPROGRAMS\$StartMenuFolder\${productname}.lnk"
  RMDir "$SMPROGRAMS\$StartMenuFolder"

  DeleteRegKey /ifempty SHCTX "Software\${productname_short}"

; Unregister logging
  DeleteRegKey SHCTX "System\CurrentControlSet\services\eventlog\Application\${productname_short}" 

; Remove uninstaller
  DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${productname_short}"
SectionEnd
!endif

http://wald.intevation.org/projects/trustbridge/