-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathopenbuilds_drivers.nsi
More file actions
117 lines (98 loc) · 4.12 KB
/
openbuilds_drivers.nsi
File metadata and controls
117 lines (98 loc) · 4.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Import some useful functions.
!include WinVer.nsh # Windows version detection.
!include x64.nsh # X86/X64 version detection.
!define VERSION 2024.04.26.0
# Set attributes that describe the installer.
Icon "Assets\openbuilds.ico"
Caption "OpenBuilds USB to UART drivers"
Name "OpenBuilds USB Drivers"
Outfile "openbuilds_usb_drivers_${VERSION}.exe"
ManifestSupportedOS "all"
SpaceTexts "none"
ShowInstDetails "show"
# Install driver files to a temporary location (then dpinst will handle the real install).
InstallDir "$TEMP\openbuilds_drivers"
# Set properties on the installer exe that will be generated.
VIAddVersionKey /LANG=1033 "ProductName" "OpenBuilds USB to UART drivers"
VIAddVersionKey /LANG=1033 "CompanyName" "OpenBuilds"
VIAddVersionKey /LANG=1033 "LegalCopyright" "OpenBuilds"
VIAddVersionKey /LANG=1033 "FileDescription" "OpenBuilds USB to UART drivers (FTDI and Silicon Labs)"
VIAddVersionKey /LANG=1033 "FileVersion" "2024.04.26.0"
VIProductVersion ${VERSION}
VIFileVersion ${VERSION}
# Define variables used in sections.
Var dpinst # Will hold the path and name of dpinst being used (x86 or x64).
# Define the standard pages in the installer.
# License page shows the contents of license.rtf.
PageEx license
LicenseData "license.rtf"
PageExEnd
# Components page allows user to pick the drivers to install.
PageEx components
ComponentText "Select the drivers that you would like to install below. Click install to start the installation. If in doubt, select all of them." \
"" "Select drivers to install:"
PageExEnd
# Instfiles page does the actual installation.
Page instfiles
# Sections define the components (drivers) that can be installed.
# The section name is displayed in the component select screen and if selected
# the code in the section will be executed during the install.
# Note that /o before the name makes the section optional and not selected by default.
# This first section is hidden and always selected so it runs first and bootstraps
# the install by copying all the files and dpinst to the temp folder location.
Section
DetailPrint "Extract Drivers..."
# Copy all the drivers and dpinst exes to the temp location.
SetOutPath $INSTDIR
File /r "Drivers"
File "dpinst-x64.exe"
File "dpinst-x86.exe"
# Set dpinst variable based on the current OS type (x86/x64).
${If} ${RunningX64}
StrCpy $dpinst "$INSTDIR\dpinst-x64.exe"
${Else}
StrCpy $dpinst "$INSTDIR\dpinst-x86.exe"
${EndIf}
SectionEnd
Section "FTDI USB to Serial"
DetailPrint "Installing FTDI USB to Serial drivers..."
${If} ${AtLeastWin10}
${If} ${RunningX64}
ExecWait '"$dpinst" /q /se /path "$INSTDIR\Drivers\FTDI_UNI\x64"'
${Else}
ExecWait '"$dpinst" /q /se /path "$INSTDIR\Drivers\FTDI_UNI\x86"'
${EndIf}
${Else}
ExecWait '"$dpinst" /q /se /path "$INSTDIR\Drivers\FTDI_VCP_PORT"'
ExecWait '"$dpinst" /q /se /path "$INSTDIR\Drivers\FTDI_VCP_BUS"'
${EndIf}
SectionEnd
Section "Silicon Labs USB Uart"
DetailPrint "Installing Silicon Labs USB Uart drivers..."
${If} ${AtMostWinVista}
# Use older driver for XP & Vista.
ExecWait '"$dpinst" /sw /path "$INSTDIR\Drivers\SiLabs_CP210x\WinVista"'
${ElseIf} ${AtLeastWin10}
ExecWait '"$dpinst" /sw /path "$INSTDIR\Drivers\SiLabs_CP210x\Win1011"'
${Else}
# User newer driver for 7 and beyond.
ExecWait '"$dpinst" /sw /path "$INSTDIR\Drivers\SiLabs_CP210x\Win7"'
${EndIf}
SectionEnd
Section "WCH CH340/341 USB to Serial"
DetailPrint "WCH CH340/341 USB to Serial drivers..."
ExecWait '"$dpinst" /q /se /path "$INSTDIR\Drivers\CH341SER"'
SectionEnd
Function .onRebootFailed
MessageBox MB_OK|MB_ICONSTOP "Reboot failed. Please reboot manually." /SD IDOK
FunctionEnd
Function .onInstSuccess
MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to Reboot? A reboot is required to complete the Installation of the OpenBuilds USB to UART drivers. We strongly recommend you reboot now." IDNO +2
Reboot
FunctionEnd
# Unselect, disable, and hide the given section.
!macro HideSectionMacro SectionId
SectionSetFlags ${SectionId} ${SF_RO}
SectionSetText ${SectionId} ""
!macroend
!define HideSection '!insertMacro HideSectionMacro'