3 ; This NSIS script creates an installer for QEMU on Windows.
5 ; Copyright (C) 2006-2021 Stefan Weil
7 ; This program is free software: you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 2 of the License, or
10 ; (at your option) version 3 or any later version.
12 ; This program is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ; GNU General Public License for more details.
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
22 !define PRODUCT
"QEMU"
23 !define URL
"https://www.qemu.org/"
25 !define UNINST_EXE
"$INSTDIR\qemu-uninstall.exe"
26 !define UNINST_KEY
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}"
29 !define BINDIR nsis
.tmp
32 !define DATADIR
"${BINDIR}\share"
38 !define OUTFILE
"qemu-setup.exe"
41 ; Use maximum compression.
42 SetCompressor
/SOLID lzma
44 ; Generate a Unicode installer.
49 ; The name of the installer.
55 ; The default installation directory.
57 InstallDir $PROGRAMFILES64\qemu
59 InstallDir $PROGRAMFILES\qemu
62 ; Registry key to check for directory (so if you install again, it will
63 ; overwrite the old one automatically)
65 InstallDirRegKey HKLM "Software\qemu64" "Install_Dir"
67 InstallDirRegKey HKLM "Software\qemu32" "Install_Dir"
70 ; Request administrator privileges for Windows Vista.
71 RequestExecutionLevel admin
73 ;--------------------------------
75 ;!define MUI_HEADERIMAGE "qemu-nsis.bmp"
76 ; !define MUI_SPECIALBITMAP "qemu.bmp"
77 !define MUI_ICON
"${SRCDIR}\pc-bios\qemu-nsis.ico"
78 !define MUI_UNICON
"${SRCDIR}\pc-bios\qemu-nsis.ico"
79 !define MUI_WELCOMEFINISHPAGE_BITMAP
"${SRCDIR}\pc-bios\qemu-nsis.bmp"
80 ; !define MUI_HEADERIMAGE_BITMAP "qemu-install.bmp"
81 ; !define MUI_HEADERIMAGE_UNBITMAP "qemu-uninstall.bmp"
82 ; !define MUI_COMPONENTSPAGE_SMALLDESC
83 ; !define MUI_WELCOMEPAGE_TEXT "Insert text here.$\r$\n$\r$\n$\r$\n$_CLICK"
85 ;--------------------------------
88 !insertmacro MUI_PAGE_WELCOME
89 !insertmacro MUI_PAGE_LICENSE
"${SRCDIR}\COPYING"
90 !insertmacro MUI_PAGE_COMPONENTS
91 !insertmacro MUI_PAGE_DIRECTORY
92 !insertmacro MUI_PAGE_INSTFILES
93 !define MUI_FINISHPAGE_LINK
$(Visit_QEMU_Wiki_Link
)
94 !define MUI_FINISHPAGE_LINK_LOCATION
"${URL}"
95 !insertmacro MUI_PAGE_FINISH
97 !insertmacro MUI_UNPAGE_CONFIRM
98 !insertmacro MUI_UNPAGE_INSTFILES
100 ;--------------------------------
103 !insertmacro MUI_LANGUAGE
"English"
104 !insertmacro MUI_LANGUAGE
"French"
105 !insertmacro MUI_LANGUAGE
"German"
106 !insertmacro MUI_LANGUAGE
"Italian"
107 !insertmacro MUI_LANGUAGE
"Spanish"
109 ;--------------------------------
113 !insertmacro MUI_LANGDLL_DISPLAY
117 ;--------------------------------
119 ; The stuff to install.
121 ; Remember to keep the "Uninstall" section in sync.
123 Section "${PRODUCT}" QEMU_System_File_Section_Description
127 ; Set output path to the installation directory.
128 SetOutPath "$INSTDIR"
130 File "${SRCDIR}\COPYING"
131 File "${SRCDIR}\COPYING.LIB"
132 File "${SRCDIR}\README.rst"
133 File "${SRCDIR}\VERSION"
135 File /r
"${BINDIR}\share"
137 SetOutPath "$INSTDIR\lib\gdk-pixbuf-2.0\2.10.0"
138 FileOpen $0 "loaders.cache" w
145 ; Write the installation path into the registry
146 WriteRegStr HKLM SOFTWARE\
${PRODUCT} "Install_Dir" "$INSTDIR"
148 ; Write the uninstall keys for Windows
149 WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "QEMU"
150 !ifdef DISPLAYVERSION
151 WriteRegStr HKLM "${UNINST_KEY}" "DisplayVersion" "${DISPLAYVERSION}"
153 WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" '"${UNINST_EXE}"'
154 WriteRegDWORD HKLM "${UNINST_KEY}" "NoModify" 1
155 WriteRegDWORD HKLM "${UNINST_KEY}" "NoRepair" 1
156 WriteUninstaller "qemu-uninstall.exe"
159 Section "$(Tools_Section_Name)" Tools_Section_Description
160 SetOutPath "$INSTDIR"
161 File "${BINDIR}\qemu-edid.exe"
162 File "${BINDIR}\qemu-ga.exe"
163 File "${BINDIR}\qemu-img.exe"
164 File "${BINDIR}\qemu-io.exe"
167 SectionGroup
"$(System_Emulation_Section_Name)" System_Emulation_Section_Description
169 !include "${BINDIR}\system-emulations.nsh"
173 Section "$(Desktop_Icon_Section_Name)" Desktop_Icon_Section_Description
174 SetOutPath "$INSTDIR\share"
176 File /r
/usr
/x86_64
-w64
-mingw32
/sys
-root
/mingw
/share
/icons
178 File /r
/usr
/i686
-w64
-mingw32
/sys
-root
/mingw
/share
/icons
183 Section "$(DLL_Library_Section_Name)" DLL_Library_Section_Description
184 SetOutPath "$INSTDIR"
185 File "${DLLDIR}\*.dll"
189 !ifdef CONFIG_DOCUMENTATION
190 Section "$(Documentation_Section_Name)" Documentation_Section_Description
191 ; SetOutPath "$INSTDIR\share\doc"
192 ; File /r "${BINDIR}\share\doc"
193 SetOutPath "$INSTDIR"
194 CreateDirectory "$SMPROGRAMS\${PRODUCT}"
195 CreateShortCut "$SMPROGRAMS\${PRODUCT}\$(Link_Description_User_Documentation).lnk" "$INSTDIR\share\doc\index.html" "" "$INSTDIR\share\doc\index.html" 0
199 ; Optional section (can be disabled by the user)
200 Section "$(Start_Menu_Section_Name)" Start_Menu_Section_Description
201 CreateDirectory "$SMPROGRAMS\${PRODUCT}"
202 CreateShortCut "$SMPROGRAMS\${PRODUCT}\$(Link_Description_Uninstall).lnk" "${UNINST_EXE}" "" "${UNINST_EXE}" 0
205 ;--------------------------------
209 Section "Uninstall" Uninstall_Section_Description
210 ; Remove registry keys
214 DeleteRegKey HKLM "${UNINST_KEY}"
215 DeleteRegKey HKLM SOFTWARE\
${PRODUCT}
217 ; Remove shortcuts, if any
218 Delete "$SMPROGRAMS\${PRODUCT}\$(Link_Description_User_Documentation).lnk"
219 Delete "$SMPROGRAMS\${PRODUCT}\$(Link_Description_Technical_Documentation).lnk"
220 Delete "$SMPROGRAMS\${PRODUCT}\$(Link_Description_Uninstall).lnk"
221 RMDir "$SMPROGRAMS\${PRODUCT}"
223 ; Remove files and directories used
224 Delete "$INSTDIR\COPYING"
225 Delete "$INSTDIR\COPYING.LIB"
226 Delete "$INSTDIR\README.rst"
227 Delete "$INSTDIR\VERSION"
228 Delete "$INSTDIR\*.dll"
229 Delete "$INSTDIR\qemu.svg"
230 Delete "$INSTDIR\qemu-io.exe"
231 Delete "$INSTDIR\qemu-img.exe"
232 Delete "$INSTDIR\qemu-ga.exe"
233 Delete "$INSTDIR\qemu-edid.exe"
234 Delete "$INSTDIR\qemu.exe"
235 Delete "$INSTDIR\qemu-system-*.exe"
236 RMDir /r
"$INSTDIR\share"
237 ; Remove generated files
238 Delete "$INSTDIR\stderr.txt"
239 Delete "$INSTDIR\stdout.txt"
241 Delete "${UNINST_EXE}"
245 ; Include files with language installer strings.
246 ; Language ID table - https://www.science.co.il/language/Locale-codes.php
247 ; Language ID 1033 - English
248 ; Language ID 1031 - German
249 ; Language ID 1034 - Spanish
250 ; Language ID 1036 - French
251 ; Language ID 1040 - Italian
252 !addincludedir ${SRCDIR}/installer
253 !include installer_strings_english
.nsh
254 !include installer_strings_french
.nsh
255 !include installer_strings_german
.nsh
256 !include installer_strings_italian
.nsh
257 !include installer_strings_spanish
.nsh
260 ; ---------------------
262 ; Descriptions (mouse-over).
263 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
264 !insertmacro MUI_DESCRIPTION_TEXT
${QEMU_System_File_Section_Description} $(QEMU_System_File_Section_Description_Text
)
265 !insertmacro MUI_DESCRIPTION_TEXT
${Tools_Section_Description} $(Tools_Section_Description_Text
)
266 !insertmacro MUI_DESCRIPTION_TEXT
${System_Emulation_Section_Description} $(System_Emulation_Section_Description_Text
)
267 !insertmacro MUI_DESCRIPTION_TEXT
${Desktop_Icon_Section_Description} $(Desktop_Icon_Section_Description_Text
)
268 !insertmacro MUI_DESCRIPTION_TEXT
${Uninstall_Section_Description} $(Uninstall_Section_Description_Text
)
270 !insertmacro MUI_DESCRIPTION_TEXT
${DLL_Library_Section_Description} $(DLL_Library_Section_Description_Text
)
272 !ifdef CONFIG_DOCUMENTATION
273 !insertmacro MUI_DESCRIPTION_TEXT
${Documentation_Section_Description} $(Documentation_Section_Description_Text
)
275 !insertmacro MUI_DESCRIPTION_TEXT
${Start_Menu_Section_Description} $(Start_Menu_Section_Description_Text
)
276 !insertmacro MUI_FUNCTION_DESCRIPTION_END