input: minor robustness improvement, close fd leak
[sigrok-cli.git] / contrib / sigrok-cli_cross.nsi.in
blob6f60540fa19cfd31969dbacff3b624403cf3b4a6
1 ##
2 ## This file is part of the sigrok-cli project.
3 ##
4 ## Copyright (C) 2011-2020 Uwe Hermann <uwe@hermann-uwe.de>
5 ##
6 ## This program is free software; you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 2 of the License, or
9 ## (at your option) any later version.
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
21 # This file is used to create the sigrok-cli Windows installer via NSIS.
22 # It is meant for use in a cross-compile setup (not for native builds).
23 # See the 'sigrok-cross-mingw' script in the sigrok-util repo for details.
25 # NSIS documentation:
26 # http://nsis.sourceforge.net/Docs/
27 # http://nsis.sourceforge.net/Docs/Modern%20UI%202/Readme.html
30 # Include the "Modern UI" header, which gives us the usual Windows look-n-feel.
31 !include "MUI2.nsh"
34 # --- Global stuff ------------------------------------------------------------
36 # Installer/product name.
37 Name "@PACKAGE_NAME@"
39 # Filename of the installer executable.
40 OutFile "@PACKAGE_NAME@-@SC_PACKAGE_VERSION@-installer.exe"
42 # Where to install the application.
43 !ifdef PE64
44 InstallDir "$PROGRAMFILES64\sigrok\@PACKAGE_NAME@"
45 !else
46 InstallDir "$PROGRAMFILES\sigrok\@PACKAGE_NAME@"
47 !endif
49 # Request admin privileges for Windows Vista and Windows 7.
50 # http://nsis.sourceforge.net/Docs/Chapter4.html
51 RequestExecutionLevel admin
53 # Local helper definitions.
54 !define REGSTR "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PACKAGE_NAME@"
57 # --- MUI interface configuration ---------------------------------------------
59 # Use the following icon for the installer EXE file.
60 !define MUI_ICON "@top_srcdir@/contrib/sigrok-logo-notext.ico"
62 # Show a nice image at the top of each installer page.
63 !define MUI_HEADERIMAGE
65 # Don't automatically go to the Finish page so the user can check the log.
66 !define MUI_FINISHPAGE_NOAUTOCLOSE
68 # Upon "cancel", ask the user if he really wants to abort the installer.
69 !define MUI_ABORTWARNING
71 # Don't force the user to accept the license, just show it.
72 # Details: http://trac.videolan.org/vlc/ticket/3124
73 !define MUI_LICENSEPAGE_BUTTON $(^NextBtn)
74 !define MUI_LICENSEPAGE_TEXT_BOTTOM "Click Next to continue."
76 # Path where the cross-compiled sigrok tools and libraries are located.
77 # Change this to where-ever you installed libsigrok.a and so on.
78 !define CROSS "@prefix@"
81 # --- MUI pages ---------------------------------------------------------------
83 # Show a nice "Welcome to the ... Setup Wizard" page.
84 !insertmacro MUI_PAGE_WELCOME
86 # Show the license of the project.
87 !insertmacro MUI_PAGE_LICENSE "@top_srcdir@/COPYING"
89 # Show a screen which allows the user to select which components to install.
90 !insertmacro MUI_PAGE_COMPONENTS
92 # Allow the user to select a different install directory.
93 !insertmacro MUI_PAGE_DIRECTORY
95 # Perform the actual installation, i.e. install the files.
96 !insertmacro MUI_PAGE_INSTFILES
98 # Show a final "We're done, click Finish to close this wizard" message.
99 !insertmacro MUI_PAGE_FINISH
101 # Pages used for the uninstaller.
102 !insertmacro MUI_UNPAGE_WELCOME
103 !insertmacro MUI_UNPAGE_CONFIRM
104 !insertmacro MUI_UNPAGE_INSTFILES
105 !insertmacro MUI_UNPAGE_FINISH
108 # --- MUI language files ------------------------------------------------------
110 # Select an installer language (required!).
111 !insertmacro MUI_LANGUAGE "English"
114 # --- Default section ---------------------------------------------------------
116 Section "@PACKAGE_NAME@ (required)" Section1
117 # This section is gray (can't be disabled) in the component list.
118 SectionIn RO
120 # Install the file(s) specified below into the specified directory.
121 SetOutPath "$INSTDIR"
123 # License file.
124 File "@top_srcdir@/COPYING"
126 # sigrok-cli.exe.
127 File "${CROSS}/bin/@PACKAGE_NAME@.exe"
129 # Zadig (used for installing WinUSB drivers).
130 File "${CROSS}/zadig.exe"
131 File "${CROSS}/zadig_xp.exe"
133 # Python
134 File "${CROSS}/python34.dll"
135 File "${CROSS}/python34.zip"
136 File "${CROSS}/*.pyd"
138 SetOutPath "$INSTDIR\share"
140 # Protocol decoders.
141 File /r /x "__pycache__" /x "*.pyc" "${CROSS}/share/libsigrokdecode"
143 # Firmware files.
144 File /r "${CROSS}/share/sigrok-firmware"
146 # Generate the uninstaller executable.
147 WriteUninstaller "$INSTDIR\Uninstall.exe"
149 # Create a sub-directory in the start menu.
150 CreateDirectory "$SMPROGRAMS\sigrok"
151 CreateDirectory "$SMPROGRAMS\sigrok\@PACKAGE_NAME@"
153 # Create a shortcut for sigrok-cli (this merely opens a "DOS box").
154 # Set the working directory (where the user will be placed into when
155 # the DOS box starts) to the installation directory.
156 SetOutPath "$INSTDIR"
157 CreateShortCut "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\sigrok command-line tool.lnk" \
158 "$SYSDIR\cmd.exe" \
159 "/K echo For instructions run @PACKAGE_NAME@ --help." \
160 "$SYSDIR\cmd.exe" 0 \
161 SW_SHOWNORMAL "" "Run @PACKAGE_NAME@"
163 # Create a shortcut for the uninstaller.
164 CreateShortCut "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\Uninstall @PACKAGE_NAME@.lnk" \
165 "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0 \
166 SW_SHOWNORMAL "" "Uninstall @PACKAGE_NAME@"
168 # Create a shortcut for the Zadig executable.
169 CreateShortCut "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\Zadig (@PACKAGE_NAME@).lnk" \
170 "$INSTDIR\zadig.exe" "" "$INSTDIR\zadig.exe" 0 \
171 SW_SHOWNORMAL "" "Zadig"
173 # Create a shortcut for the Zadig executable (for Win XP).
174 CreateShortCut "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\Zadig (@PACKAGE_NAME@, Win XP).lnk" \
175 "$INSTDIR\zadig_xp.exe" "" "$INSTDIR\zadig_xp.exe" 0 \
176 SW_SHOWNORMAL "" "Zadig (Win XP)"
178 # Create registry keys for "Add/remove programs" in the control panel.
179 WriteRegStr HKLM "${REGSTR}" "DisplayName" "@PACKAGE_STRING@"
180 WriteRegStr HKLM "${REGSTR}" "UninstallString" \
181 "$\"$INSTDIR\Uninstall.exe$\""
182 WriteRegStr HKLM "${REGSTR}" "InstallLocation" "$\"$INSTDIR$\""
183 WriteRegStr HKLM "${REGSTR}" "DisplayIcon" \
184 "$\"$INSTDIR\sigrok-logo-notext.ico$\""
185 WriteRegStr HKLM "${REGSTR}" "Publisher" "sigrok"
186 WriteRegStr HKLM "${REGSTR}" "HelpLink" \
187 "http://sigrok.org/wiki/Sigrok-cli"
188 WriteRegStr HKLM "${REGSTR}" "URLUpdateInfo" \
189 "http://sigrok.org/wiki/Downloads"
190 WriteRegStr HKLM "${REGSTR}" "URLInfoAbout" "http://sigrok.org"
191 WriteRegStr HKLM "${REGSTR}" "DisplayVersion" "@SC_PACKAGE_VERSION@"
192 WriteRegStr HKLM "${REGSTR}" "Contact" \
193 "sigrok-devel@lists.sourceforge.org"
194 WriteRegStr HKLM "${REGSTR}" "Comments" \
195 "This is the sigrok command-line application."
197 # Display "Remove" instead of "Modify/Remove" in the control panel.
198 WriteRegDWORD HKLM "${REGSTR}" "NoModify" 1
199 WriteRegDWORD HKLM "${REGSTR}" "NoRepair" 1
201 # TODO: Add sigrok-cli directory to the PATH env. variable.
202 SectionEnd
204 Section /o "Example data" Section2
205 # Example *.sr files.
206 SetOutPath "$INSTDIR\examples"
208 File "${CROSS}/share/sigrok-dumps/arm_trace/stm32f105/trace_example.sr"
209 File "${CROSS}/share/sigrok-dumps/am230x/am2301/am2301_1mhz.sr"
210 File "${CROSS}/share/sigrok-dumps/avr_isp/atmega88/isp_atmega88_erase_chip.sr"
211 File "${CROSS}/share/sigrok-dumps/can/microchip_mcp2515dm-bm/mcp2515dm-bm-125kbits_msg_222_5bytes.sr"
212 File "${CROSS}/share/sigrok-dumps/dcf77/pollin_dcf1_module/dcf77_120s.sr"
213 File "${CROSS}/share/sigrok-dumps/i2c/eeprom_24xx/microchip_24lc02b/hantek_6022be_powerup.sr"
214 File "${CROSS}/share/sigrok-dumps/i2c/eeprom_24xx/microchip_24lc64/sainsmart_dds120_powerup_scl_sda_analog.sr"
215 File "${CROSS}/share/sigrok-dumps/i2c/potentiometer/analog_devices_ad5258/ad5258_read_once_write_continuously_triangle.sr"
216 File "${CROSS}/share/sigrok-dumps/mdio/lan8720a/lan8720a_read_write_read.sr"
217 File "${CROSS}/share/sigrok-dumps/onewire/owfs/ds28ea00.sr"
218 File "${CROSS}/share/sigrok-dumps/sdcard/sd_mode/rcar-h2/cmd23_cmd18.sr"
219 File "${CROSS}/share/sigrok-dumps/spi/mx25l1605d/mx25l1605d_read.sr"
220 File "${CROSS}/share/sigrok-dumps/uart/gps/mtk3339/mtk3339_8n1_9600.sr"
221 File "${CROSS}/share/sigrok-dumps/usb/hid/mouse/olimex_stm32-h103_usb_hid/olimex_stm32-h103_usb_hid.sr"
222 File "${CROSS}/share/sigrok-dumps/z80/kc85/kc85-20mhz.sr"
224 # Create a shortcut for the example data folder.
225 CreateShortCut "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\Examples (@PACKAGE_NAME@).lnk" \
226 "$INSTDIR\examples" "" "$INSTDIR\examples" 0 \
227 SW_SHOWNORMAL "" ""
228 SectionEnd
231 # --- Uninstaller section -----------------------------------------------------
233 Section "Uninstall"
234 # Always delete the uninstaller first (yes, this really works).
235 Delete "$INSTDIR\Uninstall.exe"
237 # Delete the application, the application data, and related libs.
238 Delete "$INSTDIR\COPYING"
239 Delete "$INSTDIR\@PACKAGE_NAME@.exe"
240 Delete "$INSTDIR\zadig.exe"
241 Delete "$INSTDIR\zadig_xp.exe"
242 Delete "$INSTDIR\python34.dll"
243 Delete "$INSTDIR\python34.zip"
244 Delete "$INSTDIR\*.pyd"
246 # Delete all decoders and everything else in libsigrokdecode/.
247 # There could be *.pyc files or __pycache__ subdirs and so on.
248 RMDir /r "$INSTDIR\share\libsigrokdecode"
250 # Delete the firmware files.
251 RMDir /r "$INSTDIR\share\sigrok-firmware"
253 # Delete the example *.sr files.
254 RMDir /r "$INSTDIR\examples\*"
256 # Delete the install directory and its sub-directories.
257 RMDir "$INSTDIR\share"
258 RMDir "$INSTDIR\examples"
259 RMDir "$INSTDIR"
261 # Delete the links from the start menu.
262 Delete "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\sigrok command-line tool.lnk"
263 Delete "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\Uninstall @PACKAGE_NAME@.lnk"
264 Delete "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\Zadig (@PACKAGE_NAME@).lnk"
265 Delete "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\Zadig (@PACKAGE_NAME@, Win XP).lnk"
266 Delete "$SMPROGRAMS\sigrok\@PACKAGE_NAME@\Examples (@PACKAGE_NAME@).lnk"
268 # Delete the sub-directory in the start menu.
269 RMDir "$SMPROGRAMS\sigrok\@PACKAGE_NAME@"
270 RMDir "$SMPROGRAMS\sigrok"
272 # Delete the registry key(s).
273 DeleteRegKey HKLM "${REGSTR}"
274 SectionEnd
277 # --- Component selection section descriptions --------------------------------
279 LangString DESC_Section1 ${LANG_ENGLISH} "This installs the sigrok command-line tool, some firmware files, the protocol decoders, and all required libraries."
280 LangString DESC_Section2 ${LANG_ENGLISH} "This installs some example files that you can use to try out the features sigrok has to offer."
282 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
283 !insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
284 !insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
285 !insertmacro MUI_FUNCTION_DESCRIPTION_END