OSDN Git Service

Small installer tweak.
[lamexp/LameXP.git] / etc / NSIS / wrapper.nsi
1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // LameXP - Audio Encoder Front-End
3 ; // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
4 ; //
5 ; // This program is free software; you can redistribute it and/or modify
6 ; // it under the terms of the GNU General Public License as published by
7 ; // the Free Software Foundation; either version 2 of the License, or
8 ; // (at your option) any later version.
9 ; //
10 ; // This program is distributed in the hope that it will be useful,
11 ; // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ; // GNU General Public License for more details.
14 ; //
15 ; // You should have received a copy of the GNU General Public License along
16 ; // with this program; if not, write to the Free Software Foundation, Inc.,
17 ; // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 ; //
19 ; // http://www.gnu.org/licenses/gpl-2.0.txt
20 ; ///////////////////////////////////////////////////////////////////////////////
21
22 ;--------------------------------
23 ;Basic Defines
24 ;--------------------------------
25
26 !ifndef LAMEXP_VERSION
27   !error "LAMEXP_VERSION is not defined !!!"
28 !endif
29 !ifndef LAMEXP_BUILD
30   !error "LAMEXP_BUILD is not defined !!!"
31 !endif
32 !ifndef LAMEXP_INSTTYPE
33   !error "LAMEXP_INSTTYPE is not defined !!!"
34 !endif
35 !ifndef LAMEXP_PATCH
36   !error "LAMEXP_PATCH is not defined !!!"
37 !endif
38 !ifndef LAMEXP_DATE
39   !error "LAMEXP_DATE is not defined !!!"
40 !endif
41 !ifndef LAMEXP_OUTPUT_FILE
42   !error "LAMEXP_OUTPUT_FILE is not defined !!!"
43 !endif
44 !ifndef LAMEXP_SOURCE_FILE
45   !error "LAMEXP_SOURCE_FILE is not defined !!!"
46 !endif
47 !ifndef LAMEXP_UPX_PATH
48   !error "LAMEXP_UPX_PATH is not defined !!!"
49 !endif
50
51 ;Web-Site
52 !define MyWebSite "http://mulder.at.gg/"
53
54 ;Installer file name
55 !define InstallerFileName "$PLUGINSDIR\LameXP-SETUP-r${LAMEXP_BUILD}.exe"
56
57 ;--------------------------------
58 ;Includes
59 ;--------------------------------
60
61 !include `LogicLib.nsh`
62 !include `StdUtils.nsh`
63
64
65 ;--------------------------------
66 ;Installer Attributes
67 ;--------------------------------
68
69 XPStyle on
70 RequestExecutionLevel user
71 InstallColors /windows
72 Name "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
73 OutFile "${LAMEXP_OUTPUT_FILE}"
74 BrandingText "${LAMEXP_DATE} / Build #${LAMEXP_BUILD}"
75 Icon "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
76 ChangeUI all "${NSISDIR}\Contrib\UIs\sdbarker_tiny.exe"
77 ShowInstDetails nevershow
78 AutoCloseWindow true
79 InstallDir ""
80
81
82 ;--------------------------------
83 ;Page Captions
84 ;--------------------------------
85
86 SubCaption 0 " "
87 SubCaption 1 " "
88 SubCaption 2 " "
89 SubCaption 3 " "
90 SubCaption 4 " "
91
92
93 ;--------------------------------
94 ;Compressor
95 ;--------------------------------
96
97 !packhdr "$%TEMP%\exehead.tmp" '"${LAMEXP_UPX_PATH}\upx.exe" --brute "$%TEMP%\exehead.tmp"'
98
99
100 ;--------------------------------
101 ;Reserved Files
102 ;--------------------------------
103
104 ReserveFile "${NSISDIR}\Plugins\System.dll"
105 ReserveFile "${NSISDIR}\Plugins\StdUtils.dll"
106 ReserveFile "${NSISDIR}\Plugins\SelfDel.dll"
107
108
109 ;--------------------------------
110 ;Version Info
111 ;--------------------------------
112
113 !searchreplace PRODUCT_VERSION_DATE "${LAMEXP_DATE}" "-" "."
114 VIProductVersion "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD}"
115
116 VIAddVersionKey "Author" "LoRd_MuldeR <mulder2@gmx.de>"
117 VIAddVersionKey "Comments" "This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version."
118 VIAddVersionKey "CompanyName" "Free Software Foundation"
119 VIAddVersionKey "FileDescription" "LameXP v${LAMEXP_VERSION} ${LAMEXP_INSTTYPE}-${LAMEXP_PATCH} [Build #${LAMEXP_BUILD}]"
120 VIAddVersionKey "FileVersion" "${PRODUCT_VERSION_DATE}.${LAMEXP_BUILD} (${LAMEXP_VERSION})"
121 VIAddVersionKey "LegalCopyright" "Copyright 2004-2015 LoRd_MuldeR"
122 VIAddVersionKey "LegalTrademarks" "GNU"
123 VIAddVersionKey "OriginalFilename" "LameXP.${LAMEXP_DATE}.Build-${LAMEXP_BUILD}.exe"
124 VIAddVersionKey "ProductName" "LameXP - Audio Encoder Frontend"
125 VIAddVersionKey "ProductVersion" "${LAMEXP_VERSION}, Build #${LAMEXP_BUILD} (${LAMEXP_DATE})"
126 VIAddVersionKey "Website" "${MyWebSite}"
127
128
129 ;--------------------------------
130 ;Installer initialization
131 ;--------------------------------
132
133 Section "-LaunchTheInstaller"
134         SetDetailsPrint textonly
135         DetailPrint "Launching installer, please stay tuned..."
136         SetDetailsPrint listonly
137         
138         InitPluginsDir
139         SetOutPath "$PLUGINSDIR"
140         
141         ${StdUtils.TestParameter} $R0 "Update"
142         ${If} "$R0" == "true"
143                 SetFileAttributes "$EXEPATH" FILE_ATTRIBUTE_NORMAL
144                 SelfDel::del /RMDIR
145         ${EndIf}
146         
147         SetOverwrite on
148         File "/oname=${InstallerFileName}" "${LAMEXP_SOURCE_FILE}"
149
150         ; --------
151         
152         ${If} "$EXEFILE" == "LameXP.exe"
153         ${OrIf} "$EXEFILE" == "LameXP-Portable.exe"
154                 MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, you must NOT rename the LameXP installation program to 'LameXP.exe' or 'LameXP-Portable.exe'. Please re-rename the installer executable file (e.g. to 'LameXP-Setup.exe') and then try again!"
155                 Quit
156         ${EndIf}
157
158         ; --------
159
160         ${StdUtils.GetAllParameters} $R9 0
161         ${IfThen} "$R9" == "too_long" ${|} StrCpy $R9 "" ${|}
162
163         ${IfNot} "$R9" == ""
164                 DetailPrint "Parameters: $R9"
165         ${EndIf}
166
167         ; --------
168
169         ${Do}
170                 SetOverwrite ifdiff
171                 File "/oname=${InstallerFileName}" "${LAMEXP_SOURCE_FILE}"
172                 
173                 DetailPrint "ExecShellWait: ${InstallerFileName}"
174                 ${StdUtils.ExecShellWaitEx} $R1 $R2 "${InstallerFileName}" "open" '$R9'
175                 DetailPrint "Result: $R1 ($R2)"
176                 
177                 ${IfThen} $R1 == "no_wait" ${|} Goto RunSuccess ${|}
178                 
179                 ${If} $R1 == "ok"
180                         Sleep 333
181                         HideWindow
182                         ${StdUtils.WaitForProcEx} $R1 $R2
183                         Goto RunSuccess
184                 ${EndIf}
185                 
186                 MessageBox MB_RETRYCANCEL|MB_ICONSTOP|MB_TOPMOST "Failed to launch the installer. Please try again!" IDCANCEL FallbackMode
187         ${Loop}
188         
189
190         ; -----------
191
192         FallbackMode:
193
194         DetailPrint "Installer not launched yet, trying fallback mode!"
195
196         SetOverwrite ifdiff
197         File "/oname=${InstallerFileName}" "${LAMEXP_SOURCE_FILE}"
198
199         ClearErrors
200         ExecShell "open" "${InstallerFileName}" '$R9' SW_SHOWNORMAL
201         IfErrors 0 RunSuccess
202
203         ClearErrors
204         ExecShell "" "${InstallerFileName}" '$R9' SW_SHOWNORMAL
205         IfErrors 0 RunSuccess
206
207         ; --------
208
209         SetDetailsPrint both
210         DetailPrint "Failed to launch installer :-("
211         SetDetailsPrint listonly
212
213         SetErrorLevel 1
214         SetOutPath "$TEMP"
215         Abort "Aborted."
216
217         ; --------
218         
219         RunSuccess:
220
221         Delete /REBOOTOK "${InstallerFileName}"
222         SetErrorLevel 0
223         SetOutPath "$TEMP"
224 SectionEnd