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_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
27 !define PRODUCT_LICENSE_FILE "dist\gpl3.txt"
39 #from nullsoft distribution
41 #taken from http://nsis.sourceforge.net/FileAssoc
42 !include "fileassoc.nsh"
43 #from nullsoft distribution
44 !include "LogicLib.nsh"
48 !macro IsUserAdmin Result UName
55 UserInfo::GetAccountType
58 StrCpy ${Result} "yes"
65 StrCpy ${Result} "yes"
72 ; Remember the installer language
73 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
74 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
75 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
77 ; let warning appear when installation is canceled
78 !define MUI_ABORTWARNING
80 ; Icons for the installer program
81 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-full.ico"
82 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-full.ico"
85 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
86 !insertmacro MUI_PAGE_WELCOME
89 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
91 ; Specify the installation directory.
92 !insertmacro MUI_PAGE_DIRECTORY
94 ; choose the components to install.
95 !insertmacro MUI_PAGE_COMPONENTS
97 ; Specify where to install program shortcuts.
98 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
99 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
100 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
101 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "$(^Name)"
102 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
104 ; Watch the components being installed.
105 !insertmacro MUI_PAGE_INSTFILES
108 !define MUI_FINISHPAGE_RUN "$INSTDIR\${PRODUCT_EXE}"
109 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
110 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
111 !insertmacro MUI_PAGE_FINISH
114 !insertmacro MUI_UNPAGE_CONFIRM
115 !insertmacro MUI_UNPAGE_INSTFILES
118 # Installer languages
119 !insertmacro MUI_LANGUAGE "English" # first language is the default language
120 !insertmacro MUI_LANGUAGE "French"
121 !insertmacro MUI_LANGUAGE "German"
122 !insertmacro MUI_LANGUAGE "Italian"
123 !insertmacro MUI_LANGUAGE "Russian"
124 !insertmacro MUI_LANGUAGE "Spanish"
126 !include "installer_languages\english.nsh"
127 !include "installer_languages\french.nsh"
128 !include "installer_languages\german.nsh"
129 !include "installer_languages\italian.nsh"
130 !include "installer_languages\russian.nsh"
131 !include "installer_languages\spanish.nsh"
134 # Installer attributes
135 OutFile JabRefSetup.exe
136 InstallDir "$PROGRAMFILES\JabRef"
137 BrandingText "$(^Name) installer" ; appear at the bottom of the installer windows
138 XPStyle on ; use XP style for installer windows
139 LicenseData "$(JabRefLicenseData)"
141 ; creates file informations for the JabRefSetup.exe
142 VIAddVersionKey ProductName "JabRef"
143 VIAddVersionKey ProductVersion "${VERSION}"
144 VIAddVersionKey CompanyName "${COMPANY}"
145 VIAddVersionKey CompanyWebsite "${URL}"
146 VIAddVersionKey FileDescription "JabRef installation program"
147 VIAddVersionKey LegalCopyright "under the GPL version 3"
148 VIAddVersionKey FileVersion ""
152 Section "!JabRef" SecCore
156 Section "$(SecAssociateBibTitle)" SecAssociateBib
157 !insertmacro APP_ASSOCIATE "bib" "JabRef.BibTeX" "$(FileTypeTitle)" "$INSTDIR\${PRODUCT_EXE},0" "$(OpenIn)" "$INSTDIR\${PRODUCT_EXE} $\"%1$\""
160 Section "$(SecDesktopTitle)" SecDesktop
161 StrCpy $CreateDesktopIcon "true"
164 ; section descriptions
165 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
166 !insertmacro MUI_DESCRIPTION_TEXT ${SecAssociateBib} "$(SecAssociateBibDescription)"
167 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
168 !insertmacro MUI_FUNCTION_DESCRIPTION_END
170 Section "-Installation actions" SecInstallation
173 SetOutPath "$INSTDIR"
176 WriteRegStr SHCTX "${REGKEY}\Components" Main 1
178 WriteRegStr SHCTX "${REGKEY}" Path $INSTDIR
179 WriteUninstaller $INSTDIR\uninstall.exe
180 ; create shortcuts to startmenu
181 SetOutPath "$INSTDIR"
182 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
183 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\$(^Name).lnk" "$INSTDIR\${PRODUCT_EXE}" "" "$INSTDIR\JabRef.exe"
184 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall $(^Name).lnk" "$INSTDIR\uninstall.exe"
185 ; create desktop icon
186 ${if} $CreateDesktopIcon == "true"
187 SetOutPath "$INSTDIR"
188 CreateShortCut "$DESKTOP\$(^Name).lnk" "$INSTDIR\${PRODUCT_EXE}" "" "$INSTDIR\${PRODUCT_EXE}" ;$(^Name).lnk
190 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
191 ${if} $Answer == "yes" ; if user is admin
192 ; register information that appear in Windows' software listing
193 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
194 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${VERSION}"
195 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "Publisher" "${COMPANY}"
196 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${URL}"
197 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_EXE}"
198 WriteRegStr HKLM "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
199 WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
200 WriteRegDWORD HKLM "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
206 # Uninstaller sections
207 Section "un.JabRef" un.SecUnProgramFiles
210 ; delete installation folder
212 ; delete start menu entry
213 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu"
215 ; delete desktop icon
216 Delete "$DESKTOP\$(^Name).lnk"
217 ; delete registry entries
218 DeleteRegKey HKCU "${PRODUCT_UNINST_KEY}"
219 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY}"
220 DeleteRegKey HKCR "Applications\${PRODUCT_EXE}"
221 DeleteRegValue HKCR ".bib" "JabRef.BibTeX_backup"
222 DeleteRegValue HKCU "Software\Classes\.bib" "JabRef.BibTeX_backup"
223 DeleteRegValue SHCTX "Software\Classes\.bib" "JabRef.BibTeX_backup"
224 DeleteRegKey HKCU "${REGKEY}"
225 DeleteRegKey SHCTX "${REGKEY}"
226 ; remove file association with .bib-files
227 !insertmacro APP_UNASSOCIATE "bib" "JabRef.BibTeX"
228 ; close uninstaller automatically
234 # Installer functions
238 ; If the user does *not* have administrator privileges, abort
241 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
242 ${if} $Answer == "yes"
243 SetShellVarContext all ; set that e.g. shortcuts will be created for all users
245 SetShellVarContext current
246 StrCpy $INSTDIR "$APPDATA\$(^Name)"
252 # Uninstaller functions
255 ; If the user does *not* have administrator privileges, abort
257 !insertmacro IsUserAdmin $Answer $UserName
258 ${if} $Answer == "yes"
259 SetShellVarContext all
261 SetShellVarContext current
264 ; ask if it should really be removed
265 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2
270 Function un.onUninstSuccess
273 MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"