add NSIS installer files Samuli Seppänen

'make installer' will now spit out an openvpn-gui-installer.exe. The
location of the required makensis tool can be specified by appending
MAKENSIS=/path/to/makensis to the configure command line. Otherwise
it's searched for in your $PATH. The installer target is only available
when makensis is available.
pull/1/head
Heiko Hund 11 years ago
parent 02b924f48a
commit 10c32f06c2

@ -66,7 +66,11 @@ openvpn_gui_RESOURCES = \
res/reconnecting.ico \ res/reconnecting.ico \
res/openvpn-gui.manifest res/openvpn-gui.manifest
EXTRA_DIST = $(openvpn_gui_RESOURCES) openvpn_gui_NSIS = \
nsis/openvpn-gui.nsi \
nsis/english.nsh
EXTRA_DIST = $(openvpn_gui_RESOURCES) $(openvpn_gui_NSIS)
openvpn_gui_SOURCES = \ openvpn_gui_SOURCES = \
main.c main.h \ main.c main.h \
@ -98,3 +102,15 @@ openvpn_gui_LDADD = \
openvpn-gui-res.o: $(openvpn_gui_RESOURCES) $(srcdir)/openvpn-gui-res.h openvpn-gui-res.o: $(openvpn_gui_RESOURCES) $(srcdir)/openvpn-gui-res.h
$(RCCOMPILE) -i $< -o $@ $(RCCOMPILE) -i $< -o $@
if HAVE_NSIS
CLEANFILES = openvpn-gui-installer.exe
openvpn-gui-installer.exe: $(openvpn_gui_NSIS) $(bin_PROGRAMS)
$(STRIP) -s $(bin_PROGRAMS)
$(MAKENSIS) -DARCH=$(ARCH) -DVERSION=$(VERSION) $<
installer: openvpn-gui-installer.exe
.PHONY: installer
endif

@ -45,6 +45,9 @@ if test -z "$MAX_CONFIGS"; then
fi fi
AC_DEFINE_UNQUOTED([MAX_CONFIGS], [$MAX_CONFIGS], [Maximum number of config files supported.]) AC_DEFINE_UNQUOTED([MAX_CONFIGS], [$MAX_CONFIGS], [Maximum number of config files supported.])
AC_ARG_VAR([ARCH], [override the CPU architecture for the NSIS installer])
test "x$ARCH" = "x" && ARCH=${host%%-*}
case "$host" in case "$host" in
*-mingw*) *-mingw*)
CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN" CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
@ -61,6 +64,12 @@ AC_PROG_INSTALL
AC_PROG_LN_S AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_ARG_VAR([MAKENSIS], [define the path to the makensis tool])
if test "x$MAKENSIS" = "x"; then
AC_PATH_PROG([MAKENSIS], [makensis])
fi
AM_CONDITIONAL([HAVE_NSIS], [test "x$MAKENSIS" != "x"])
PKG_CHECK_MODULES( PKG_CHECK_MODULES(
[OPENSSL_CRYPTO], [OPENSSL_CRYPTO],
[libcrypto >= 0.9.6], [libcrypto >= 0.9.6],

@ -0,0 +1,14 @@
LangString NAME_SecOverwriteConfiguration ${LANG_ENGLISH} "Overwrite configuration"
LangString DESC_SecOverwriteConfiguration ${LANG_ENGLISH} "Overwrite previous user-defined ${PACKAGE_NAME} configuration with default values"
LangString NAME_AddRegistryKeys ${LANG_ENGLISH} "Add registry keys"
LangString DESC_AddRegistryKeys ${LANG_ENGLISH} "Add OpenVPN-GUI-specific registry keys"
LangString NAME_SecInstallExecutable ${LANG_ENGLISH} "Install ${PACKAGE_NAME}"
LangString DESC_SecInstallExecutable ${LANG_ENGLISH} "Install ${PACKAGE_NAME} executable"
LangString NAME_SecInstallDocumentation ${LANG_ENGLISH} "Install documentation"
LangString DESC_SecInstallDocumentation ${LANG_ENGLISH} "Install documentation"
LangString NAME_SecInstallDesktopIcon ${LANG_ENGLISH} "Install desktop icon"
LangString DESC_SecInstallDesktopIcon ${LANG_ENGLISH} "Install ${PACKAGE_NAME} desktop icon"
LangString NAME_SecAddStartMenuEntries ${LANG_ENGLISH} "Add start menu entries"
LangString DESC_SecAddStartMenuEntries ${LANG_ENGLISH} "Add start menu entries for installed components"
LangString NAME_DeleteAllRegistryKeys ${LANG_ENGLISH} "Delete all registry keys"
LangString DESC_DeleteAllRegistryKeys ${LANG_ENGLISH} "Delete all registry keys related to OpenVPN-GUI"

@ -0,0 +1,235 @@
; ****************************************************************************
; * Copyright (C) 2013 OpenVPN Technologies, Inc. *
; * This program is free software; you can redistribute it and/or modify *
; * it under the terms of the GNU General Public License version 2 *
; * as published by the Free Software Foundation. *
; ****************************************************************************
SetCompressor lzma
; Includes
!include "LogicLib.nsh"
!include "MultiUser.nsh"
!include "MUI2.nsh"
; Defines
!define MULTIUSER_EXECUTIONLEVEL Admin
!define PACKAGE_NAME "OpenVPN-GUI"
!define REG_KEY "HKLM Software\OpenVPN-GUI"
; Basic configuration
Name "OpenVPN-GUI ${VERSION}"
OutFile "..\openvpn-gui-installer.exe"
RequestExecutionLevel admin
ShowInstDetails show
; Default installation directory. Needed for silent installations. Will get
; overwritten in the function .onInit
InstallDir "$PROGRAMFILES\${PACKAGE_NAME}"
; Installer pages
!insertmacro MUI_PAGE_LICENSE "..\COPYRIGHT.GPL"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
; Uninstaller pages
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
Function .onInit
SetShellVarContext all
; Check if we're running on 64-bit Windows
${If} "${ARCH}" == "x86_64"
SetRegView 64
; Change the installation directory to C:\Program Files, but only if the
; user has not provided a custom install location.
${If} "$INSTDIR" == "$PROGRAMFILES\${PACKAGE_NAME}"
StrCpy $INSTDIR "$PROGRAMFILES64\${PACKAGE_NAME}"
${EndIf}
${EndIf}
FunctionEnd
Function un.onInit
ClearErrors
!insertmacro MULTIUSER_UNINIT
SetShellVarContext all
${If} "${ARCH}" == "x86_64"
SetRegView 64
${EndIf}
FunctionEnd
; This empty section allows selecting whether to reset OpenVPN-GUI registry key
; values to the default. OpenVPN-specific part of the configuration gets
; auto-detected and overwritten regardless of this setting.
Section /o "$(NAME_SecOverwriteConfiguration)" SecOverwriteConfiguration
SectionEnd
Section "-Add registry keys" SecAddRegistryKeys
AddSize 0
Var /GLOBAL OPENVPN_INSTALL_DIR
; This code checks if OpenVPN is installed and bails out if it's not.
goto read_32bit_registry
read_32bit_registry:
ClearErrors
ReadRegStr $OPENVPN_INSTALL_DIR HKLM "Software\OpenVPN" ""
IfErrors read_64bit_registry openvpn_found
read_64bit_registry:
ClearErrors
SetRegView 64
ReadRegStr $OPENVPN_INSTALL_DIR HKLM "Software\OpenVPN" ""
IfErrors openvpn_not_found openvpn_found
openvpn_not_found:
Abort "OpenVPN not installed, bailing out..."
openvpn_found:
DetailPrint "OpenVPN installed to $OPENVPN_INSTALL_DIR"
; If we're told to overwrite existing configuration, we do it.
${If} ${SectionIsSelected} ${SecOverwriteConfiguration}
goto overwrite_gui_configuration
${EndIf}
; If registry values are missing, we need to add them regardless of what
; we've been told.
ClearErrors
ReadRegStr $0 HKLM "Software\OpenVPN-GUI" "allow_edit"
IfErrors overwrite_gui_configuration update_openvpn_settings
overwrite_gui_configuration:
; OpenVPN-GUI-specific registry keys. We may or may not update
; these.
WriteRegStr ${REG_KEY} "allow_edit" "1"
WriteRegStr ${REG_KEY} "allow_password" "1"
WriteRegStr ${REG_KEY} "allow_proxy" "1"
WriteRegStr ${REG_KEY} "allow_service" "0"
WriteRegStr ${REG_KEY} "connectscript_timeout" "15"
WriteRegStr ${REG_KEY} "disconnect_on_suspend" "1"
WriteRegStr ${REG_KEY} "disconnectscript_timeout" "10"
WriteRegStr ${REG_KEY} "preconnectscript_timeout" "10"
WriteRegStr ${REG_KEY} "editor" "C:\Windows\notepad.exe"
WriteRegStr ${REG_KEY} "log_append" "0"
WriteRegStr ${REG_KEY} "log_viewer" "C:\Windows\notepad.exe"
WriteRegStr ${REG_KEY} "passphrase_attempts" "3"
WriteRegStr ${REG_KEY} "priority" "NORMAL_PRIORITY_CLASS"
WriteRegStr ${REG_KEY} "show_balloon" "1"
WriteRegStr ${REG_KEY} "show_script_window" "1"
WriteRegStr ${REG_KEY} "silent_connection" "0"
update_openvpn_settings:
; Registry keys related to OpenVPN. We always update these during
; install.
DeleteRegValue ${REG_KEY} "config_dir"
DeleteRegValue ${REG_KEY} "config_ext"
DeleteRegValue ${REG_KEY} "exe_path"
DeleteRegValue ${REG_KEY} "log_dir"
WriteRegStr ${REG_KEY} "config_dir" "$OPENVPN_INSTALL_DIR\config"
WriteRegStr ${REG_KEY} "config_ext" "ovpn"
WriteRegStr ${REG_KEY} "exe_path" "$OPENVPN_INSTALL_DIR\bin\openvpn.exe"
WriteRegStr ${REG_KEY} "log_dir" "$OPENVPN_INSTALL_DIR\log"
SectionEnd
Section "$(NAME_SecInstallExecutable)" SecInstallExecutable
SetOutPath "$INSTDIR\bin"
AddSize 400
File "..\openvpn-gui.exe"
SectionEnd
Section "$(NAME_SecInstallDesktopIcon)" SecInstallDesktopIcon
AddSize 1
SetOverwrite on
CreateShortcut "$DESKTOP\OpenVPN-GUI.lnk" "$INSTDIR\bin\openvpn-gui.exe"
SectionEnd
Section "$(NAME_SecAddStartMenuEntries)" SecAddStartMenuEntries
AddSize 1
SetOverwrite on
CreateDirectory "$SMPROGRAMS\${PACKAGE_NAME}"
WriteINIStr "$SMPROGRAMS\${PACKAGE_NAME}\${PACKAGE_NAME} Web Site.url" "InternetShortcut" "URL" "http://sourceforge.net/projects/openvpn-gui"
${If} ${SectionIsSelected} ${SecInstallExecutable}
CreateShortcut "$SMPROGRAMS\${PACKAGE_NAME}\${PACKAGE_NAME}.lnk" "$INSTDIR\bin\openvpn-gui.exe"
${EndIf}
SectionEnd
Section "$(NAME_SecInstallDocumentation)" SecInstallDocumentation
AddSize 1
SetOverwrite on
SetOutPath "$INSTDIR\doc"
File /oname=README.txt "..\README"
SectionEnd
Section "-post"
; Create uninstall
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PACKAGE_NAME}" "DisplayName" "${PACKAGE_NAME} ${VERSION}"
WriteRegExpandStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PACKAGE_NAME}" "UninstallString" "$INSTDIR\Uninstall.exe"
;WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PACKAGE_NAME}" "DisplayIcon" "$INSTDIR\icon.ico"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PACKAGE_NAME}" "DisplayVersion" "${VERSION}"
SectionEnd
; This section is here to allow deletion of user-defined OpenVPN-GUI
; configuration. Registry keys related to current OpenVPN install are always
; deleted during uninstall.
Section /o "un.$(NAME_DeleteAllRegistryKeys)" SecDeleteAllRegistryKeys
SectionEnd
Section "-un.Uninstall" SecUninstall
; We'll always delete registry keys related to OpenVPN. These will be
; recreated automatically when OpenVPN-GUI is installed again.
DeleteRegValue ${REG_KEY} "config_dir"
DeleteRegValue ${REG_KEY} "config_ext"
DeleteRegValue ${REG_KEY} "exe_path"
DeleteRegValue ${REG_KEY} "log_dir"
; We wipe OpenVPN-GUI-specific configuration if asked to
${If} ${SectionIsSelected} ${SecDeleteAllRegistryKeys}
DeleteRegKey ${REG_KEY}
${EndIf}
; Remove desktop icon, start menu entries and installed files
Delete "$DESKTOP\${PACKAGE_NAME}.lnk"
RMDir /r "$SMPROGRAMS\${PACKAGE_NAME}"
RMDir /r "$INSTDIR"
;DeleteRegKey HKCR "${PACKAGE_NAME}File"
; Remove OpenVPN-GUI uninstall/change option from Add/Remove programs list
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PACKAGE_NAME}"
SectionEnd
; Language settings
!include "english.nsh"
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecOverwriteConfiguration} $(DESC_SecOverwriteConfiguration)
!insertmacro MUI_DESCRIPTION_TEXT ${SecInstallExecutable} $(DESC_SecInstallExecutable)
!insertmacro MUI_DESCRIPTION_TEXT ${SecInstallDocumentation} $(DESC_SecInstallDocumentation)
!insertmacro MUI_DESCRIPTION_TEXT ${SecInstallDesktopIcon} $(DESC_SecInstallDesktopIcon)
!insertmacro MUI_DESCRIPTION_TEXT ${SecAddStartMenuEntries} $(DESC_SecAddStartMenuEntries)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Loading…
Cancel
Save