1 ; w32installer.nsi -*- coding: latin-1; -*-
3 ; Copyright (C) 2005 Free Software Foundation, Inc.
5 ; This file is free software; as a special exception the author gives
6 ; unlimited permission to copy and/or distribute it, with or without
7 ; modifications, as long as this notice is preserved.
9 ; This program is distributed in the hope that it will be useful, but
10 ; WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
11 ; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 ;----------------------------------------------------------------------
14 ; This is an installer script used to create a W32 installer "exe" file
15 ; using NSIS. It is usually used by the mk-w32-dist script.
16 ;----------------------------------------------------------------------
18 ; We use the modern UI.
20 !include "StrFunc.nsh"
21 !include "Sections.nsh"
26 Name "GNU Privacy Guard"
29 OutFile "gnupg-w32-${VERSION}.exe"
31 OutFile "gnupg-w32cli-${VERSION}.exe"
34 InstallDir "$PROGRAMFILES\GNU\GnuPG"
36 InstallDirRegKey HKLM "Software\GNU\GnuPG" "Install Directory"
40 VIProductVersion "${PROD_VERSION}"
41 VIAddVersionKey "ProductName" "GNU Privacy Guard (${VERSION})"
42 VIAddVersionKey "Comments" \
43 "GnuPG is Free Software; you can redistribute it and/or modify \
44 it under the terms of the GNU General Public License. You should \
45 have received a copy of the GNU General Public License along with \
46 this software; if not, write to the Free Software Foundation, Inc., \
47 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA"
48 VIAddVersionKey "CompanyName" "Free Software Foundation"
49 VIAddVersionKey "LegalTrademarks" ""
50 VIAddVersionKey "LegalCopyright" \
51 "Copyright (C) 2005 Free Software Foundation, Inc."
52 VIAddVersionKey "FileDescription" \
53 "GnuPG: Encryption and digital signature tool"
54 VIAddVersionKey "FileVersion" "${PROD_VERSION}"
56 ; ----------------------
57 ; Variable declarations
58 ; ----------------------
67 ;;;!define MUI_ABORTWARNING
68 !define MUI_FINISHPAGE_NOAUTOCLOSE
69 !define MUI_UNFINISHPAGE_NOAUTOCLOSE
71 ; Remember the installer language
72 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
73 !define MUI_LANGDLL_REGISTRY_KEY "Software\GNU\GnuPG"
74 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
80 !define MUI_WELCOMEPAGE_TEXT "$(T_About)"
82 !insertmacro MUI_PAGE_WELCOME
85 !define MUI_PAGE_HEADER_SUBTEXT "$(T_GPLHeader)"
87 !define MUI_LICENSEPAGE_TEXT_BOTTOM "$(T_GPLShort)"
89 !define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)"
91 !insertmacro MUI_PAGE_LICENSE "COPYING.txt"
93 !define MUI_PAGE_CUSTOMFUNCTION_SHOW PrintNonAdminWarning
94 !insertmacro MUI_PAGE_COMPONENTS
96 Page custom CustomPageOptions
98 !insertmacro MUI_PAGE_DIRECTORY
100 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
101 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\GNU\GnuPG"
102 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
104 !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
106 !insertmacro MUI_PAGE_INSTFILES
108 !define MUI_FINISHPAGE_SHOWREADME "README-W32.txt"
109 !define MUI_FINISHPAGE_SHOWREADME_TEXT "$(T_ShowReadme)"
110 !define MUI_FINISHPAGE_LINK "$(T_FiniLink)"
111 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.gnupg.org/"
112 !insertmacro MUI_PAGE_FINISH
115 !insertmacro MUI_UNPAGE_CONFIRM
116 !insertmacro MUI_UNPAGE_INSTFILES
123 !insertmacro MUI_LANGUAGE "English"
124 !insertmacro MUI_LANGUAGE "German"
130 !insertmacro MUI_RESERVEFILE_LANGDLL
131 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
132 ReserveFile "opt.ini"
133 ReserveFile "COPYING.txt"
134 ReserveFile "README-W32.txt"
135 #ReserveFile "${NSISDIR}/Plugins/System.dll"
136 ReserveFile "${NSISDIR}/Plugins/UserInfo.dll"
139 ${StrStr} # Supportable for Install Sections and Functions
140 ${StrTok} # Supportable for Install Sections and Functions
148 ;----------------------
149 Section "Base" SecBase
153 SetOutPath "$INSTDIR"
156 File "gpgkeys_finger.exe"
157 File "gpgkeys_hkp.exe"
158 File "gpgkeys_curl.exe"
159 File "gpgkeys_ldap.exe"
161 SetOutPath "$INSTDIR\Doc"
164 File "README-W32.txt"
169 WriteRegStr HKLM "Software\GNU\GnuPG" "Install Directory" $INSTDIR
171 SectionEnd ; Section Base
173 ;----------------------
177 SetOutPath "$INSTDIR\gnupg.nls"
181 SectionEnd ; Section NLS
183 ;------------------------
184 Section "Tools" SecTools
187 SetOutPath "$INSTDIR"
191 SectionEnd ; Section Tools
195 Section "WinPT" SecWinPT
198 SetOutPath "$INSTDIR"
202 File "keyserver.conf"
204 SetOutPath "$INSTDIR\Doc"
206 File "README.winpt.txt"
208 WriteRegStr HKCU "Software\GNU\GnuPG" "gpgProgram" "$INSTDIR\gpg.exe"
210 SectionEnd ; Section WinPT
214 ;----------------------
215 Section "Documentation" SecDoc
218 SetOutPath "$INSTDIR\Doc"
227 File "NEWS.winpt.txt"
231 SetOutPath "$INSTDIR\Src"
235 SectionEnd ; Section Documentation
240 Section /o "Source" SecSource
242 SetOutPath "$INSTDIR\Src"
244 ; Note that we include the uncompressed tarballs because this allows
245 ; far better compression results for the distribution. We might
246 ; want to compress it again after installation.
248 File "gnupg-${VERSION}.tar"
250 File "libiconv-${LIBICONV_VERSION}.tar"
253 File "winpt-${WINPT_VERSION}.tar"
256 SectionEnd ; Section Source
260 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
262 ;; The last section is a hidden one; used to finish up things.
264 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
267 ;;--------------------------
268 ;; Create the uninstaller
269 ;;--------------------------
270 WriteUninstaller "$INSTDIR\uninst-gnupg.exe"
272 StrCpy $MYTMP "Software\Microsoft\Windows\CurrentVersion\Uninstall\GnuPG"
273 WriteRegExpandStr HKLM $MYTMP "UninstallString" '"$INSTDIR\uninst-gnupg.exe"'
274 WriteRegExpandStr HKLM $MYTMP "InstallLocation" "$INSTDIR"
275 WriteRegStr HKLM $MYTMP "DisplayName" "GNU Privacy Guard"
276 WriteRegStr HKLM $MYTMP "DisplayIcon" "$INSTDIR\gpg.exe,0"
277 WriteRegStr HKLM $MYTMP "DisplayVersion" "${VERSION}"
278 WriteRegStr HKLM $MYTMP "Publisher" "Free Software Foundation"
279 WriteRegStr HKLM $MYTMP "URLInfoAbout" "http://www.gnupg.org/"
280 WriteRegDWORD HKLM $MYTMP "NoModify" "1"
281 WriteRegDWORD HKLM $MYTMP "NoRepair" "1"
284 ;;---------------------
285 ;; Create Menu entries
286 ;;---------------------
287 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
289 CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
291 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GnuPG README.lnk" \
292 "$INSTDIR\Doc\README.txt"
293 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GnuPG README.Windows.lnk" \
294 "$INSTDIR\Doc\README-W32.txt"
295 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GnuPG NEWS.lnk" \
296 "$INSTDIR\Doc\NEWS.txt"
298 SectionGetFlags ${SecDoc} $R0
299 IntOp $R0 $R0 & ${SF_SELECTED}
300 IntCmp $R0 ${SF_SELECTED} 0 +2
301 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\GnuPG Manual Page.lnk" \
302 "$INSTDIR\Doc\gpg.man"
306 SectionGetFlags ${SecWinPT} $R0
307 IntOp $R0 $R0 & ${SF_SELECTED}
308 IntCmp $R0 ${SF_SELECTED} 0 no_winpt_menu
309 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\winpt.lnk" \
311 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\WinPT README.lnk" \
312 "$INSTDIR\Doc\README.winpt.txt"
314 SectionGetFlags ${SecDoc} $R0
315 IntOp $R0 $R0 & ${SF_SELECTED}
316 IntCmp $R0 ${SF_SELECTED} 0 +2
317 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\WinPT NEWS.lnk" \
318 "$INSTDIR\Doc\NEWS.winpt.txt"
323 CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\uninst-gnupg.lnk" \
324 "$INSTDIR\uninst-gnupg.exe"
327 !insertmacro MUI_STARTMENU_WRITE_END
333 SectionGetFlags ${SecNLS} $R0
334 IntOp $R0 $R0 & ${SF_SELECTED}
335 IntCmp $R0 ${SF_SELECTED} 0 lang_none
337 !insertmacro MUI_INSTALLOPTIONS_READ $R0 "opt.ini" "Field 1" "ListItems"
338 DetailPrint "Available languages: $R0"
339 !insertmacro MUI_INSTALLOPTIONS_READ $R1 "opt.ini" "Field 1" "State"
340 DetailPrint "Selected language: $R1"
342 StrCmp $R1 "" lang_none +1
343 ${StrStr} $R2 $R0 $R1
344 StrCmp $R2 "" lang_none +1
345 ${StrTok} $R3 $R2 " " "0" "1"
348 DetailPrint "No language selected - using default"
351 DetailPrint "Setting language to: $R3"
352 WriteRegStr HKCU "Software\GNU\GnuPG" "Lang" $R3
356 SectionEnd ; "-Finish"
360 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
362 ;; Create the section for the uninstaller
364 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
367 ;;------------------------
369 ;;------------------------
370 Delete "$INSTDIR\gpg.exe"
371 Delete "$INSTDIR\gpgkeys_finger.exe"
372 Delete "$INSTDIR\gpgkeys_hkp.exe"
373 Delete "$INSTDIR\gpgkeys_curl.exe"
374 Delete "$INSTDIR\gpgkeys_ldap.exe"
376 Delete "$INSTDIR\Doc\README.txt"
377 Delete "$INSTDIR\Doc\README-W32.txt"
378 Delete "$INSTDIR\Doc\COPYING.txt"
379 Delete "$INSTDIR\Doc\COPYING.LIB.txt"
380 Delete "$INSTDIR\Doc\README.iconv.txt"
382 Delete "$INSTDIR\iconv.dll"
384 Delete "$INSTDIR\gnupg.nls\*.mo"
386 Delete "$INSTDIR\gpgsplit.exe"
387 Delete "$INSTDIR\gpgv.exe"
390 Delete "$INSTDIR\WinPT.exe"
391 Delete "$INSTDIR\PTD.dll"
392 Delete "$INSTDIR\Doc\README.winpt.txt"
393 Delete "$INSTDIR\Doc\NEWS.winpt.txt"
394 Delete "$INSTDIR\Doc\keyserver.conf"
397 Delete "$INSTDIR\Doc\gnupg.man"
398 Delete "$INSTDIR\Doc\gpg.man"
399 Delete "$INSTDIR\Doc\gpgv.man"
400 Delete "$INSTDIR\Doc\NEWS.txt"
401 Delete "$INSTDIR\Doc\FAQ.txt"
403 Delete "$INSTDIR\Src\gnupg-${VERSION}.tar"
404 Delete "$INSTDIR\Src\libiconv-${LIBICONV_VERSION}.tar"
405 Delete "$INSTDIR\Src\winpt-${WINPT_VERSION}.tar"
406 Delete "$INSTDIR\Src\*.diff"
408 Delete "$INSTDIR\uninst-gnupg.exe"
410 ;;------------------------
411 ;; Delete directories
412 ;;------------------------
415 RMDir "$INSTDIR\gnupg.nls"
419 ;;---------------------------------------------------
420 ;; Delete the menu entries and any empty parent menus
421 ;;---------------------------------------------------
422 !insertmacro MUI_STARTMENU_GETFOLDER Application $MYTMP
423 Delete "$SMPROGRAMS\$MYTMP\*.lnk"
424 StrCpy $MYTMP "$SMPROGRAMS\$MYTMP"
428 GetFullPathName $MYTMP "$MYTMP\.."
429 IfErrors startMenuDeleteLoopDone
430 StrCmp $MYTMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
431 startMenuDeleteLoopDone:
434 ;;-----------------------
435 ;; Cleanup the registry
436 ;;-----------------------
437 DeleteRegValue HKCU "Software\GNU\GnuPG" "Start Menu Folder"
438 DeleteRegValue HKLM "Software\GNU\GnuPG" "Install Directory"
439 DeleteRegKey /ifempty HKLM "Software\GNU\GnuPG"
440 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GnuPG"
442 SectionEnd ; Uninstall
450 # We can't use System.dll anymore becuase it has bee removed from
451 # Debian due to an inability to build using FS. We should use the
452 # use our own DLL as we do with gpg4win.
453 #System::Call 'kernel32::CreateMutexA(i 0, i 0, t "GnuPGInst") i .r1 ?e'
456 # MessageBox MB_OK "An instance of the installer is already running."
459 ;;!define MUI_LANGDLL_ALWAYSSHOW
460 !insertmacro MUI_LANGDLL_DISPLAY
462 !insertmacro MUI_INSTALLOPTIONS_EXTRACT "opt.ini"
469 !insertmacro MUI_UNGETLANGUAGE
474 ;; Check whether the current user is in the Administrator group or
475 ;; an OS version without the need for an Administrator is in use.
476 ;; Print a warning if this is not the case.
477 Function PrintNonAdminWarning
482 UserInfo::GetAccountType
484 StrCmp $1 "Admin" leave +1
485 MessageBox MB_OK "$(T_AdminNeeded)"
491 Function CustomPageOptions
492 SectionGetFlags ${SecNLS} $R0
493 IntOp $R0 $R0 & ${SF_SELECTED}
494 IntCmp $R0 ${SF_SELECTED} show
499 !insertmacro MUI_HEADER_TEXT "$(T_InstallOptions)" "$(T_SelectLanguage)"
500 !insertmacro MUI_INSTALLOPTIONS_READ $R0 "opt.ini" "Field 1" "ListItems"
501 ReadRegStr $R1 HKCU "Software\GNU\GnuPG" "Lang"
502 StrCmp $R1 "" use_default +1
503 ${StrStr} $R2 $R0 "$R1 - "
504 StrCmp $R2 "" +1 set_lang
506 StrCpy $R2 "$(T_langid) - $(T_langname)"
508 ${StrTok} $R3 $R2 "|" "0" "1"
509 !insertmacro MUI_INSTALLOPTIONS_WRITE "opt.ini" "Field 1" "State" $R3
511 !insertmacro MUI_INSTALLOPTIONS_DISPLAY "opt.ini"
516 ; Install iconv.dll if it has not been installed on the system.
517 Function InstallIconv
519 ; First delete a iconv DLL already installed in the target directory.
520 ; This is required to detect a meanwhile globally installed dll.
521 Delete "$INSTDIR\iconv.dll"
523 GetDllVersion "iconv.dll" $R0 $R1
525 DetailPrint "iconv.dll is not installed."
528 IntOp $R2 $R0 / 0x00010000
529 IntOp $R3 $R0 & 0x0000FFFF
530 IntOp $R4 $R1 / 0x00010000
531 IntOp $R5 $R1 & 0x0000FFFF
532 StrCpy $0 "$R2.$R3.$R4.$R5"
534 DetailPrint "iconv.dll version is $0"
536 IntCmp $R2 1 0 IconvTooOld
537 IntCmp $R3 9 0 IconvTooOld
541 DetailPrint "The installed iconv.dll is too old."
544 SetOutPath "$INSTDIR"
547 SetOutPath "$INSTDIR\doc"
548 File "COPYING.LIB.txt"
549 File "README.iconv.txt"
558 ; The list of language IDs and corresponding Latin-1 names. Note that
559 ; this mapping needs to match the one in the mk-w32-dist script, so
560 ; that they are usable to get a default value for then ListItems of
562 LangString T_langid ${LANG_ENGLISH} "en"
563 LangString T_langname ${LANG_ENGLISH} "English"
564 LangString T_langid ${LANG_GERMAN} "de"
565 LangString T_langname ${LANG_GERMAN} "Deutsch"
567 ; The About string as displayed on the first page.
568 LangString T_About ${LANG_ENGLISH} \
569 "GnuPG is GNU's tool for secure communication and data storage. \
570 It can be used to encrypt data and to create digital signatures. \
571 It includes an advanced key management facility and is compliant \
572 with the proposed OpenPGP Internet standard as described in RFC2440. \
574 \r\n\r\n\r\n\r\n\r\nThis is GnuPG version ${VERSION}\r\n\
575 built on $%BUILDINFO%\r\n\
576 file version ${PROD_VERSION}"
577 LangString T_About ${LANG_GERMAN} \
578 "GnuPG is das Werkzeug aus dem GNU Projekt zur sicheren Kommunikation \
579 sowie zum sicheren Speichern von Daten. \
581 \r\n\r\n\r\n\r\n\r\nDies ist GnuPG Version ${VERSION}\r\n\
582 erstellt am $%BUILDINFO%\r\n\
583 Dateiversion ${PROD_VERSION}"
586 LangString T_GPLHeader ${LANG_ENGLISH} \
587 "This software is licensed under the terms of the GNU General Public \
588 License (GPL) which guarantees your freedom to share and change Free \
590 LangString T_GPLHeader ${LANG_GERMAN}} \
591 "Diese Software ist unter der GNU General Public License \
592 (GPL) lizensiert; dies gibt Ihnen die Freiheit, sie \
593 zu ändern und weiterzugeben."
595 LangString T_GPLShort ${LANG_ENGLISH} \
596 "In short: You are allowed to run this software for any purpose. \
597 You may distribute it as long as you give the recipients the same \
598 rights you have received."
599 LangString T_GPLShort ${LANG_GERMAN} \
600 "In aller Kürze: Sie haben das Recht, die Software zu jedem Zweck \
601 einzusetzen. Sie können die Software weitergeben, sofern Sie dem \
602 Empfänger dieselben Rechte einräumen, die auch Sie erhalten haben."
606 LangString T_FiniLink ${LANG_ENGLISH} \
607 "Visit the GnuPG website for latest news and support"
608 LangString T_FiniLink ${LANG_GERMAN}} \
609 "Zur GnuPG Website mit Neuigkeiten und Hilfsangeboten"
611 ; From Function PrintNonAdminWarning
612 LangString T_AdminNeeded ${LANG_ENGLISH} \
613 "Warning: Administrator permissions required for a successful installation"
614 LangString T_AdminNeeded ${LANG_GERMAN} \
615 "Warnung: Administrator Reche werden für eine erfolgreiche \
616 Installation benötigt."
619 ; Installation options like language used for GnuPG
620 LangString T_InstallOptions ${LANG_ENGLISH} "Install Options"
621 LangString T_InstallOptions ${LANG_GERMAN} "Installationsoptionen"
623 LangString T_SelectLanguage ${LANG_ENGLISH} "GnuPG Language Selection"
624 LangString T_SelectLanguage ${LANG_German} "Auswahl der Sprache für GnuPG"
626 ; This text is used on the finish page.
627 LangString T_ShowReadme ${LANG_ENGLISH} "Show the README file"
628 LangString T_ShowReadme ${LANG_GERMAN} "Die README Datei anzeigen"
631 LangString DESC_SecBase ${LANG_ENGLISH} \
632 "The basic files used for the standard OpenPGP protocol"
633 LangString DESC_SecBase ${LANG_GERMAN} \
634 "Die Basis Dateien zur Benutzung des OpenPGP Protokolls"
636 Langstring DESC_SecNLS ${LANG_ENGLISH} \
637 "Support for languages other than English"
638 LangString DESC_SecNLS ${LANG_GERMAN} \
639 "Unterstützung für weitere Sprachen neben Englisch"
641 LangString DESC_SecTools ${LANG_ENGLISH} \
642 "Extra tools like gpgv and gpgsplit"
643 LangString DESC_SecTools ${LANG_GERMAN} \
644 "Weitere Tools wie gpgv und gpgsplit"
647 LangString DESC_SecWinPT ${LANG_ENGLISH} \
648 "The Windows Privacy Tray (WinPT)"
649 LangString DESC_SecWinPT ${LANG_GERMAN} \
650 "Der Windows Privacy Tray (WinPT)"
653 LangString DESC_SecDoc ${LANG_ENGLISH} \
654 "Manual pages and a FAQ"
655 LangString DESC_SecDoc ${LANG_GERMAN} \
656 "Handbuchseiten und eine FAQ"
658 LangString DESC_SecSource ${LANG_ENGLISH} \
660 LangString DESC_SecSource ${LANG_GERMAN} \
665 ;-------------------------------------
666 ; Associate section names with strings
667 ;--------------------------------------
668 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
669 !insertmacro MUI_DESCRIPTION_TEXT ${SecBase} $(DESC_SecBase)
670 !insertmacro MUI_DESCRIPTION_TEXT ${SecNLS} $(DESC_SecNLS)
671 !insertmacro MUI_DESCRIPTION_TEXT ${SecTools} $(DESC_SecTools)
673 !insertmacro MUI_DESCRIPTION_TEXT ${SecWinPT} $(DESC_SecWinPT)
675 !insertmacro MUI_DESCRIPTION_TEXT ${SecDoc} $(DESC_SecDoc)
676 !insertmacro MUI_FUNCTION_DESCRIPTION_END