1 ; ///////////////////////////////////////////////////////////////////////////////
2 ; // MPlayer for Windows - Install Script
3 ; // Copyright (C) 2004-2013 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_DownloadTicketId
80 Var Update_DownloadAddress
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 "Failed to verify signature!"
167 Delete "$PLUGINSDIR\$1"
168 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
169 MessageBox MB_ICONSTOP|
MB_TOPMOST "$(MPLAYER_LANG_UPD_ERR_VERIFY)"
170 Abort "Failed to verify signature!"
174 ; ----------------------------------------------------------------------------
176 Section "-Read Version Info"
177 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_VERINFO)"
182 ReadINIStr $Update_CurrentBuildNo "$EXEDIR\version.tag" "mplayer_version" "build_no"
183 ReadINIStr $Update_CurrentPkgDate "$EXEDIR\version.tag" "mplayer_version" "pkg_date"
186 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
187 MessageBox MB_TOPMOST|
MB_ICONSTOP|
MB_OK "$(MPLAYER_LANG_UPD_ERR_VERINFO)"
191 DetailPrint "$(MPLAYER_LANG_UPD_INSTALLED_VER) $Update_CurrentPkgDate (Build #$Update_CurrentBuildNo)"
194 Section "-Select Mirror"
195 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_MIRROR)"
196 StrCpy $Update_MirrorURL "http://www.example.com/"
198 ; Randomize some more
200 ${StdUtils
.RandMax
} $0 12
203 ; Select the mirror now!
206 StrCpy $Update_MirrorURL "http://muldersoft.com/"
208 StrCpy $Update_MirrorURL "http://mulder.bplaced.net/"
210 StrCpy $Update_MirrorURL "http://mulder.cwsurf.de/"
212 StrCpy $Update_MirrorURL "http://mulder.6te.net/"
214 StrCpy $Update_MirrorURL "http://mulder.webuda.com/"
216 StrCpy $Update_MirrorURL "http://mulder.byethost13.com/"
218 StrCpy $Update_MirrorURL "http://muldersoft.kilu.de/"
220 StrCpy $Update_MirrorURL "http://muldersoft.zxq.net/"
222 StrCpy $Update_MirrorURL "http://lamexp.sourceforge.net/"
224 StrCpy $Update_MirrorURL "http://lamexp.berlios.de/"
226 StrCpy $Update_MirrorURL "http://lordmulder.github.com/LameXP/"
228 StrCpy $Update_MirrorURL "http://lord_mulder.bitbucket.org/"
230 StrCpy $Update_MirrorURL "http://www.tricksoft.de/"
232 Abort "This is not supposed to happen!"
235 DetailPrint "$(MPLAYER_LANG_UPD_MIRROR) $Update_MirrorURL"
238 Section "-Download Update Info"
239 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_UPDINFO)"
241 ${DownloadFile
.Get
} "$(MPLAYER_LANG_UPD_STATUS_UPDINFO)" "$Update_MirrorURL/update.ver" "$PLUGINSDIR\update.ver"
242 ${DownloadFile
.Get
} "$(MPLAYER_LANG_UPD_STATUS_UPDINFO)" "$Update_MirrorURL/update.ver.sig" "$PLUGINSDIR\update.ver.sig"
244 ${VerfiySignature} "update.ver"
247 ReadINIStr $Update_LatestBuildNo "$PLUGINSDIR\update.ver" "MPlayer for Windows" "BuildNo"
248 ReadINIStr $Update_DownloadFileName "$PLUGINSDIR\update.ver" "MPlayer for Windows" "DownloadFilename"
249 ReadINIStr $Update_DownloadTicketId "$PLUGINSDIR\update.ver" "MPlayer for Windows" "DownloadFilecode"
250 ReadINIStr $Update_DownloadAddress "$PLUGINSDIR\update.ver" "MPlayer for Windows" "DownloadAddress"
253 Delete "$PLUGINSDIR\update.ver"
254 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_FAILED)"
255 MessageBox MB_TOPMOST|
MB_ICONSTOP|
MB_OK "$(MPLAYER_LANG_UPD_ERR_UPDINFO)"
259 Delete "$PLUGINSDIR\update.ver"
260 DetailPrint "$(MPLAYER_LANG_UPD_LATEST_VER) Build #$Update_LatestBuildNo"
263 Section "-Check Update Required"
264 ${If} $Update_CurrentBuildNo >=
$Update_LatestBuildNo
265 ${StdUtils
.GetDays
} $0
266 WriteRegDWORD HKCU "${MPlayerRegPath}" "LastUpdateCheck" $0
267 MessageBox MB_TOPMOST|MB_ICONINFORMATION
"$(MPLAYER_LANG_UPD_NO_UPDATES)"
272 Section "-Download Update"
273 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_DOWNLOAD)"
275 ${DownloadFile
.Post
} "file_name=$Update_DownloadFileName&file_code=$Update_DownloadTicketId" "$(MPLAYER_LANG_UPD_STATUS_DOWNLOAD)" "$Update_DownloadAddress" "$PLUGINSDIR\$Update_DownloadFileName"
276 ${DownloadFile
.Post
} "sign_name=$Update_DownloadFileName" "$(MPLAYER_LANG_UPD_STATUS_DOWNLOAD)" "$Update_DownloadAddress" "$PLUGINSDIR\$Update_DownloadFileName.sig"
278 ${VerfiySignature} "$Update_DownloadFileName"
281 Section "-Install Update Now"
282 ${StdUtils
.GetDays
} $0
283 WriteRegDWORD HKCU "${MPlayerRegPath}" "LastUpdateCheck" $0
285 StrCpy $5 '/Update /D=$EXEDIR'
287 ${SetStatus} "$(MPLAYER_LANG_UPD_STATUS_INSTALL)"
290 ExecShell "open" "$PLUGINSDIR\$Update_DownloadFileName" '$5' SW_SHOWNORMAL
291 ${IfNotThen} ${Errors} ${|
} ${Break} ${|
}
294 ExecShell "" "$PLUGINSDIR\$Update_DownloadFileName" '$5' SW_SHOWNORMAL
295 ${IfNotThen} ${Errors} ${|
} ${Break} ${|
}
298 Exec '"$PLUGINSDIR\$Update_DownloadFileName" $5'
299 ${IfNotThen} ${Errors} ${|
} ${Break} ${|
}
301 ${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} ${|
}
304 Delete /REBOOTOK
"$PLUGINSDIR\$Update_DownloadFileName"
307 ; ----------------------------------------------------------------------------
309 Function .onInstFailed
310 ${IfCmd} MessageBox MB_ICONQUESTION|
MB_TOPMOST|
MB_YESNO "$(MPLAYER_LANG_UPD_FAILED)" IDYES ${||
} Exec `"$EXEPATH" /L=$LANGUAGE` ${|
}