1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // MPlayer for Windows - Install Script
3 ; // Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
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.
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.
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.
19 ; // http://www.gnu.org/licenses/gpl-2.0.txt
20 ; ///////////////////////////////////////////////////////////////////////////////
24 !error "MPLAYER_DATE is not defined !!!"
27 !ifndef MPLAYER_OUTFILE
28 !error "MPLAYER_OUTFILE is not defined !!!"
32 !error "UPX_PATH is not defined !!!"
36 !define MPlayerRegPath
"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{97D341C8-B0D1-4E4A-A49A-C30B52F168E9}"
38 ; ----------------------------------------------------------------------------
40 !define /date BUILD_DATE
"%Y%m%d"
41 !packhdr "exehead.tmp" '"${UPX_PATH}\upx.exe" --brute exehead.tmp'
43 ; ----------------------------------------------------------------------------
46 RequestExecutionLevel user
47 InstallColors /windows
52 ; ----------------------------------------------------------------------------
54 LoadLanguageFile
"${NSISDIR}\Contrib\Language files\English.nlf"
55 LoadLanguageFile
"${NSISDIR}\Contrib\Language files\German.nlf"
57 !include "Language\MPUI_EN.nsh"
58 !include "Language\MPUI_DE.nsh"
60 ; ----------------------------------------------------------------------------
62 Name "$(MPLAYER_LANG_MPLAYER_WIN32) $(MPLAYER_LANG_AUTO_UPDATE)"
63 Caption "$(MPLAYER_LANG_MPLAYER_WIN32) Auto-Update"
64 BrandingText "MPlayer Update [${MPLAYER_DATE}]"
65 Icon "Artwork\update.ico"
66 OutFile "${MPLAYER_OUTFILE}"
68 ; ----------------------------------------------------------------------------
70 !include "MPUI_Download.nsh"
72 ; ----------------------------------------------------------------------------
74 Var Update_CurrentBuildNo
75 Var Update_CurrentPkgDate
77 Var Update_LatestBuildNo
78 Var Update_DownloadFileName
79 Var Update_DownloadAddress
80 Var Update_DownloadChecksum
82 ; ----------------------------------------------------------------------------
90 ; ----------------------------------------------------------------------------
92 ReserveFile
"${NSISDIR}\Plugins\Aero.dll"
93 ReserveFile
"${NSISDIR}\Plugins\inetc.dll"
94 ReserveFile
"${NSISDIR}\Plugins\LangDLL.dll"
95 ReserveFile
"${NSISDIR}\Plugins\nsExec.dll"
96 ReserveFile
"${NSISDIR}\Plugins\StdUtils.dll"
97 ReserveFile
"${NSISDIR}\Plugins\System.dll"
99 ; ----------------------------------------------------------------------------
103 ${StdUtils
.GetParameter
} $0 "AutoCheck" "?"
106 ReadRegDWORD $1 HKCU "${MPlayerRegPath}" "LastUpdateCheck"
108 ${StdUtils
.GetDays
} $2
110 ${IfThen} $2 < $1 ${|
} Quit ${|
}
114 ; Handle command-line
115 ${StdUtils
.GetParameter
} $0 "L" "?"
116 ${If} "$0" ==
"${LANG_ENGLISH}"
117 ${OrIf} "$0" ==
"${LANG_GERMAN}"
118 StrCpy $LANGUAGE "$0"
122 ; Language selection dialog
129 LangDLL::LangDialog
"Updater Language" "Please select the language:"
131 ${IfThen} $LANGUAGE ==
"cancel" ${|
} Quit ${|
}
135 StrCpy $0 $HWNDPARENT
136 System::Call "user32::SetWindowPos(i r0, i -1, i 0, i 0, i 0, i 0, i 3)"
140 ; ----------------------------------------------------------------------------
142 !define VerfiySignature
"!insertmacro _VerfiySignature"
144 !macro _VerfiySignature filename
145 DetailPrint "$(MPLAYER_LANG_UPD_VERIFYING) ${filename}"
147 File "/oname=$PLUGINSDIR\gpgv.exe" "Resources\GnuPG.exe"
148 File "/oname=$PLUGINSDIR\pubring.gpg" "Resources\GnuPG.gpg"
150 SetOutPath $PLUGINSDIR
151 nsExec::ExecToLog
'"$PLUGINSDIR\gpgv.exe" --homedir . --keyring pubring.gpg "${filename}.sig" "${filename}"'
154 Delete "$PLUGINSDIR\pubring.gpg"
155 Delete "$PLUGINSDIR\${filename}.sig"
156 Delete "$PLUGINSDIR\gpgv.exe"
158 ${If} "$9" ==
"error"
159 ${OrIf} "$9" ==
"timeout"
160 Delete "$PLUGINSDIR\$1"
161 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
162 MessageBox MB_ICONSTOP|
MB_TOPMOST "$(MPLAYER_LANG_UPD_ERR_GNUPG)"
163 Abort "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
167 Delete "$PLUGINSDIR\$1"
168 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
169 MessageBox MB_ICONSTOP|
MB_TOPMOST "$(MPLAYER_LANG_UPD_ERR_VERIFY)"
170 Abort "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
174 ; ----------------------------------------------------------------------------
176 !define VerfiyChecksum
"!insertmacro _VerfiyChecksum"
178 !macro _VerfiyChecksum filename expected_value
179 DetailPrint "$(MPLAYER_LANG_UPD_VERIFYING) ${filename}"
181 ${StdUtils
.HashFile
} $9 "SHA3-384" '${filename}'
183 ${If} "$9" ==
"error"
184 ${OrIf} "$9" ==
"invalid"
186 MessageBox MB_ICONSTOP|
MB_TOPMOST "$(MPLAYER_LANG_UPD_ERR_VERIFY)"
187 Abort "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
190 DetailPrint "Expected checksum: ${expected_value}"
191 DetailPrint "Computed checksum: $9"
193 ${IfNot} "$9" ==
"${expected_value}"
195 MessageBox MB_ICONSTOP|
MB_TOPMOST "$(MPLAYER_LANG_UPD_ERR_VERIFY)"
196 Abort "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
201 ; ----------------------------------------------------------------------------
203 Section "-Read Version Info"
204 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_VERINFO)"
209 ReadINIStr $Update_CurrentBuildNo "$EXEDIR\version.tag" "mplayer_version" "build_no"
210 ReadINIStr $Update_CurrentPkgDate "$EXEDIR\version.tag" "mplayer_version" "pkg_date"
213 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
214 MessageBox MB_TOPMOST|
MB_ICONSTOP|
MB_OK "$(MPLAYER_LANG_UPD_ERR_VERINFO)"
215 Abort "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
218 DetailPrint "$(MPLAYER_LANG_UPD_INSTALLED_VER) $Update_CurrentPkgDate (Build #$Update_CurrentBuildNo)"
221 Section "-Select Mirror"
222 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_MIRROR)"
223 StrCpy $Update_MirrorURL "http://www.example.com/"
225 ; Randomize some more
227 ${StdUtils
.RandMax
} $0 15
230 ; Select the mirror now!
233 StrCpy $Update_MirrorURL "http://muldersoft.com/"
235 StrCpy $Update_MirrorURL "http://mulder.bplaced.net/"
237 StrCpy $Update_MirrorURL "http://mulder.6te.net/"
239 StrCpy $Update_MirrorURL "http://mulder.webuda.com/"
241 StrCpy $Update_MirrorURL "http://mulder.pe.hu/"
243 StrCpy $Update_MirrorURL "http://muldersoft.square7.ch/"
245 StrCpy $Update_MirrorURL "http://muldersoft.co.nf/"
247 StrCpy $Update_MirrorURL "http://muldersoft.eu.pn/"
249 StrCpy $Update_MirrorURL "http://muldersoft.lima-city.de/"
251 StrCpy $Update_MirrorURL "http://www.muldersoft.keepfree.de/"
253 StrCpy $Update_MirrorURL "http://lamexp.sourceforge.net/"
255 StrCpy $Update_MirrorURL "http://lordmulder.github.io/LameXP/"
257 StrCpy $Update_MirrorURL "http://lord_mulder.bitbucket.org/"
259 StrCpy $Update_MirrorURL "http://www.tricksoft.de/"
261 StrCpy $Update_MirrorURL "http://repo.or.cz/LameXP.git/blob_plain/gh-pages:/",
263 StrCpy $Update_MirrorURL "http://gitlab.com/lamexp/lamexp/raw/gh-pages/",
265 Abort "This is not supposed to happen!"
268 DetailPrint "$(MPLAYER_LANG_UPD_MIRROR) $Update_MirrorURL"
271 Section "-Download Update Info"
272 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_UPDINFO)"
274 ${DownloadFile
.Get
} "$(MPLAYER_LANG_UPD_STATUS_UPDINFO)" "$Update_MirrorURL/update.ver" "$PLUGINSDIR\update.ver"
275 ${DownloadFile
.Get
} "$(MPLAYER_LANG_UPD_STATUS_UPDINFO)" "$Update_MirrorURL/update.ver.sig2" "$PLUGINSDIR\update.ver.sig"
277 ${VerfiySignature} "update.ver"
280 ReadINIStr $Update_LatestBuildNo "$PLUGINSDIR\update.ver" "MPlayer for Windows" "BuildNo"
281 ReadINIStr $Update_DownloadFileName "$PLUGINSDIR\update.ver" "MPlayer for Windows" "DownloadFilename"
282 ReadINIStr $Update_DownloadAddress "$PLUGINSDIR\update.ver" "MPlayer for Windows" "DownloadAddress"
283 ReadINIStr $Update_DownloadChecksum "$PLUGINSDIR\update.ver" "MPlayer for Windows" "DownloadChecksum"
286 Delete "$PLUGINSDIR\update.ver"
287 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
288 MessageBox MB_TOPMOST|
MB_ICONSTOP|
MB_OK "$(MPLAYER_LANG_UPD_ERR_UPDINFO)"
289 Abort "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
292 StrCpy $0 "$Update_DownloadAddress" "" -1
293 ${IfNotThen} "$0" ==
"/" ${|
} StrCpy $Update_DownloadAddress "$Update_DownloadAddress/" ${|
}
295 Delete "$PLUGINSDIR\update.ver"
296 DetailPrint "$(MPLAYER_LANG_UPD_LATEST_VER) Build #$Update_LatestBuildNo"
299 Section "-Check Update Required"
300 ${If} $Update_CurrentBuildNo >=
$Update_LatestBuildNo
301 ${StdUtils
.GetDays
} $0
302 WriteRegDWORD HKCU "${MPlayerRegPath}" "LastUpdateCheck" $0
303 MessageBox MB_TOPMOST|MB_ICONINFORMATION
"$(MPLAYER_LANG_UPD_NO_UPDATES)"
308 Section "-Download Update"
309 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_DOWNLOAD)"
311 ${DownloadFile
.Popup
} "$(MPLAYER_LANG_UPD_STATUS_DOWNLOAD)" "$Update_DownloadAddress$Update_DownloadFileName" "$PLUGINSDIR\$Update_DownloadFileName"
312 ${VerfiyChecksum} "$Update_DownloadFileName" "$Update_DownloadChecksum"
315 Section "-Install Update Now"
316 ${StdUtils
.GetDays
} $0
317 WriteRegDWORD HKCU "${MPlayerRegPath}" "LastUpdateCheck" $0
319 StrCpy $5 '/Update /D=$EXEDIR'
321 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_INSTALL)"
324 ExecShell "open" "$PLUGINSDIR\$Update_DownloadFileName" '$5' SW_SHOWNORMAL
325 ${IfNotThen} ${Errors} ${|
} ${Break} ${|
}
328 ExecShell "" "$PLUGINSDIR\$Update_DownloadFileName" '$5' SW_SHOWNORMAL
329 ${IfNotThen} ${Errors} ${|
} ${Break} ${|
}
332 Exec '"$PLUGINSDIR\$Update_DownloadFileName" $5'
333 ${IfNotThen} ${Errors} ${|
} ${Break} ${|
}
335 ${IfCmd} MessageBox MB_ICONSTOP|
MB_TOPMOST|
MB_RETRYCANCEL "$(MPLAYER_LANG_UPD_ERR_LAUNCH)$\n$PLUGINSDIR\$Update_DownloadFileName$\n$\n$(MPLAYER_LANG_UPD_ACCESS_RIGHTS)" IDCANCEL ${||
} ${Break} ${|
}
338 Delete /REBOOTOK
"$PLUGINSDIR\$Update_DownloadFileName"
341 ; ----------------------------------------------------------------------------
343 Function .onInstFailed
344 ${IfCmd} MessageBox MB_ICONQUESTION|
MB_TOPMOST|
MB_YESNO "$(MPLAYER_LANG_UPD_FAILED)" IDYES ${||
} Exec `"$EXEPATH" /L=$LANGUAGE` ${|
}