2 # license GPL version 3
3 # author Uwe Stöhr and others
5 ; To compile this script NSIS 2.23 and newer are required
6 ; http://nsis.sourceforge.net/
9 ; Do a Cyclic Redundancy Check to make sure the installer
10 ; was not corrupted by the download.
13 ; Make the installer as small as possible.
18 ; you only need to change this section for new releases
19 VIProductVersion "2.2.0.0" ; file version for the installer in the scheme "x.x.x.x"
20 #!define VERSION "2.2" #Already set by command line parameter
21 Name "JabRef ${VERSION}"
22 !define REGKEY "SOFTWARE\JabRef"
23 !define COMPANY "JabRef Team"
24 !define URL "http://jabref.sourceforge.net"
25 !define PRODUCT_EXE "JabRef.exe"
26 !define PRODUCT_NAME "JabRef"
27 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
28 !define PRODUCT_LICENSE_FILE "dist\gpl3.txt"
41 #from nullsoft distribution
43 #taken from http://nsis.sourceforge.net/FileAssoc
44 !include "fileassoc.nsh"
45 #from nullsoft distribution
46 !include "LogicLib.nsh"
50 !macro IsUserAdmin Result UName
57 UserInfo::GetAccountType
60 StrCpy ${Result} "yes"
67 StrCpy ${Result} "yes"
74 ; Remember the installer language
75 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
76 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
77 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
79 ; let warning appear when installation is canceled
80 !define MUI_ABORTWARNING
82 ; Icons for the installer program
83 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-full.ico"
84 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
87 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
88 !insertmacro MUI_PAGE_WELCOME
91 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
93 ; Specify the installation directory.
94 !insertmacro MUI_PAGE_DIRECTORY
96 ; choose the components to install.
97 !insertmacro MUI_PAGE_COMPONENTS
99 ; Specify where to install program shortcuts.
100 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
101 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
102 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
103 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "${PRODUCT_NAME}"
104 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
106 ; Watch the components being installed.
107 !insertmacro MUI_PAGE_INSTFILES
110 !define MUI_FINISHPAGE_RUN "$INSTDIR\${PRODUCT_EXE}"
111 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
112 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
113 !insertmacro MUI_PAGE_FINISH
116 !insertmacro MUI_UNPAGE_CONFIRM
117 !insertmacro MUI_UNPAGE_INSTFILES
120 # Installer languages
121 !insertmacro MUI_LANGUAGE "English" # first language is the default language
122 !insertmacro MUI_LANGUAGE "French"
123 !insertmacro MUI_LANGUAGE "German"
124 !insertmacro MUI_LANGUAGE "Italian"
125 !insertmacro MUI_LANGUAGE "Russian"
126 !insertmacro MUI_LANGUAGE "Spanish"
128 !include "installer_languages\english.nsh"
129 !include "installer_languages\french.nsh"
130 !include "installer_languages\german.nsh"
131 !include "installer_languages\italian.nsh"
132 !include "installer_languages\russian.nsh"
133 !include "installer_languages\spanish.nsh"
136 # Installer attributes
137 OutFile JabRefSetup.exe
138 InstallDir "$PROGRAMFILES\JabRef"
139 BrandingText "$(^Name) installer" ; appear at the bottom of the installer windows
140 XPStyle on ; use XP style for installer windows
141 LicenseData "$(JabRefLicenseData)"
143 ; creates file informations for the JabRefSetup.exe
144 VIAddVersionKey ProductName "JabRef"
145 VIAddVersionKey ProductVersion "${VERSION}"
146 VIAddVersionKey CompanyName "${COMPANY}"
147 VIAddVersionKey CompanyWebsite "${URL}"
148 VIAddVersionKey FileDescription "JabRef installation program"
149 VIAddVersionKey LegalCopyright "under the GPL version 3"
150 VIAddVersionKey FileVersion ""
154 Section "!JabRef" SecCore
158 Section "$(SecAssociateBibTitle)" SecAssociateBib
159 !insertmacro APP_ASSOCIATE "bib" "JabRef.BibTeX" "$(FileTypeTitle)" "$INSTDIR\${PRODUCT_EXE},0" "$(OpenIn)" "$INSTDIR\${PRODUCT_EXE} $\"%1$\""
162 Section "$(SecDesktopTitle)" SecDesktop
163 StrCpy $CreateDesktopIcon "true"
166 ; section descriptions
167 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
168 !insertmacro MUI_DESCRIPTION_TEXT ${SecAssociateBib} "$(SecAssociateBibDescription)"
169 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
170 !insertmacro MUI_FUNCTION_DESCRIPTION_END
172 Section "-Installation actions" SecInstallation
175 SetOutPath "$INSTDIR"
178 WriteRegStr SHCTX "${REGKEY}\Components" Main 1
180 WriteRegStr SHCTX "${REGKEY}" Path $INSTDIR
181 WriteUninstaller $INSTDIR\uninstall.exe
182 ; create shortcuts to startmenu
183 SetOutPath "$INSTDIR"
184 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
185 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\$(^Name).lnk" "$INSTDIR\${PRODUCT_EXE}" "" "$INSTDIR\JabRef.exe"
186 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall $(^Name).lnk" "$INSTDIR\uninstall.exe"
187 ; create desktop icon
188 ${if} $CreateDesktopIcon == "true"
189 SetOutPath "$INSTDIR"
190 CreateShortCut "$DESKTOP\$(^Name).lnk" "$INSTDIR\${PRODUCT_EXE}" "" "$INSTDIR\${PRODUCT_EXE}" ;$(^Name).lnk
192 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
193 ${if} $Answer == "yes" ; if user is admin
194 ; register information that appear in Windows' software listing
195 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
196 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${VERSION}"
197 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${COMPANY}"
198 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${URL}"
199 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXE}"
200 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
201 WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
202 WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
208 # Uninstaller sections
209 Section "un.JabRef" un.SecUnProgramFiles
213 Delete $INSTDIR\${PRODUCT_EXE}
214 Delete $INSTDIR\uninstall.exe
215 ; delete dir only if empty
217 ; delete start menu entry
218 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
220 ; delete desktop icon
221 Delete "$DESKTOP\$(^Name).lnk"
222 ; delete registry entries
223 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
224 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
225 DeleteRegKey HKCR "Applications\${PRODUCT_EXE}"
226 DeleteRegValue HKCR ".bib" "JabRef.BibTeX_backup"
227 DeleteRegValue HKCU "Software\Classes\.bib" "JabRef.BibTeX_backup"
228 DeleteRegValue SHCTX "Software\Classes\.bib" "JabRef.BibTeX_backup"
229 DeleteRegKey HKCU "${REGKEY}"
230 DeleteRegKey SHCTX "${REGKEY}"
231 ; remove file association with .bib-files
232 !insertmacro APP_UNASSOCIATE "bib" "JabRef.BibTeX"
233 ; close uninstaller automatically
239 # Installer functions
243 ; If the user does *not* have administrator privileges, abort
246 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
247 ${if} $Answer == "yes"
248 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
250 SetShellVarContext current
251 StrCpy $INSTDIR "$APPDATA\$(^Name)"
257 # Uninstaller functions
260 ; If the user does *not* have administrator privileges, abort
262 !insertmacro IsUserAdmin $Answer $UserName
263 ${if} $Answer == "yes"
264 SetShellVarContext all
266 SetShellVarContext current
269 ; ask if it should really be removed
270 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2
275 Function un.onUninstSuccess
278 MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"