︙ | | | ︙ | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#-- defaults / parameters
[CmdletBinding()]
Param(
[string]$reinstall = "ask",
[string]$TEMP = $env:TEMP,
[string]$PYTHON = "C:\Python27",
[string]$StartMenu = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs",
#[string]$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$",""),
[string]$ProgramFiles = "%ProgramFiles(x86)%",
[string]$AboutLink = "http://freshcode.club/projects/streamtuner2",
[string]$VERSION = "2.2.0"
)
|
>
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#-- defaults / parameters
[CmdletBinding()]
Param(
[string]$reinstall = "ask",
[string]$TEMP = $env:TEMP,
[string]$PYTHON = "C:\Python27",
[string]$PythonGUID = "{4A656C6C-D24A-473F-9747-3A8D00907A03}", #Python 2.7.13
[string]$StartMenu = "$env:USERPROFILE\AppData\Roaming\Microsoft\Windows\Start Menu\Programs",
#[string]$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$",""),
[string]$ProgramFiles = "%ProgramFiles(x86)%",
[string]$AboutLink = "http://freshcode.club/projects/streamtuner2",
[string]$VERSION = "2.2.0"
)
|
︙ | | | ︙ | |
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
$ProgramFiles = "%ProgramFiles%"
}
New-Variable -Name STREAMRIPPER -Option AllScope -Value "$ProgramFiles\Streamripper" #can be changed in Check-Prerequisites
#-- what and how to install (hash list as used by Run-Task and Check-Prerequisites)
$tasks = @(
@{
title = "Python 2.7.12"
url = "https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi"
cmd = ""
iargs = 'TARGETDIR="{PYTHON}" /qb-!'
regkey = "$regPathLM\{9DA28CE5-0AA5-429E-86D8-686ED898C665}"
testpth= "{PYTHON}\pythonw.exe"
is_opt = ''
prescn = ''
},
@{
title = "PyGtk 2.24.2"
url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi"
|
|
|
|
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
$ProgramFiles = "%ProgramFiles%"
}
New-Variable -Name STREAMRIPPER -Option AllScope -Value "$ProgramFiles\Streamripper" #can be changed in Check-Prerequisites
#-- what and how to install (hash list as used by Run-Task and Check-Prerequisites)
$tasks = @(
@{
title = "Python 2.7.13"
url = "https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi"
cmd = ""
iargs = 'TARGETDIR="{PYTHON}" /qb-!'
regkey = "$regPathLM\$PythonGUID"
testpth= "{PYTHON}\pythonw.exe"
is_opt = ''
prescn = ''
},
@{
title = "PyGtk 2.24.2"
url = "http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi"
|
︙ | | | ︙ | |
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
title = "Streamripper 1.64.6"
url = "https://netcologne.dl.sourceforge.net/project/streamripper/streamripper%20%28current%29/1.64.6/streamripper-windows-installer-1.64.6.exe"
cmd = ""
iargs = "/S /D={STREAMRIPPER}" #NSIS does not use double quotes in /D parm
regkey = "$regPathLM\Streamripper"
testpth= "{STREAMRIPPER}\streamripper.exe"
is_opt = '($optionalInstall)' # โ could use '((Ask "Install streamripper too [y/N]") -match N)' instead
prescn = 'if ($optionalInstall) {if ($t.found = (Get-ITPV "Streamripper")) {$STREAMRIPPER = $_found}} else {$STREAMRIPPER=""; continue;}'
},
@{
title = "Uninstall script"
cmd = 'Create-Uninstallscript'
},
@{
title = "Desktop shortcut"
cmd = 'Make-Shortcut -dir $Home\Desktop -name Streamtuner2.lnk -target $PYTHON\pythonw.exe -arg $UsrFolder\bin\streamtuner2'
},
@{
title = "Startmenu shortcut"
cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Streamtuner2.lnk -target $PYTHON\pythonw.exe -arg $UsrFolder\bin\streamtuner2'
},
@{
title = "Startmenu help.chm"
cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Help.lnk -target $UsrFolder\share\streamtuner2\help\help.chm'
},
@{
title = "Startmenu uninstall"
cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Uninstall.lnk -target $UninstallPath'
},
@{
title = "Startmenu Internet"
cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name "Streamtuner2 on the Web.lnk" -target "$AboutLink"'
},
@{
title = "Startmenu Reconfigure"
cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2\Extra" -name "Reconfigure.lnk" -target $ModifyPath'
},
@{
title = "Startmenu RunDebug"
cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2\Extra" -name "Run in debug mode (-D).lnk" -target $PYTHON\python.exe -arg "$UsrFolder\bin\streamtuner2" -parm "-D"'
},
@{
title = "Startmenu RunConsole"
cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2\Extra" -name "Run with console.lnk" -target $PYTHON\python.exe -arg "$UsrFolder\bin\streamtuner2"'
},
@{
title = "Startmenu ResetPrefs"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2\Extra"
name = "Reset preferences.lnk"
target = "$ResetPrefsPath"
|
|
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
>
>
>
>
>
>
>
|
|
>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
>
>
|
>
>
>
>
|
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
title = "Streamripper 1.64.6"
url = "https://netcologne.dl.sourceforge.net/project/streamripper/streamripper%20%28current%29/1.64.6/streamripper-windows-installer-1.64.6.exe"
cmd = ""
iargs = "/S /D={STREAMRIPPER}" #NSIS does not use double quotes in /D parm
regkey = "$regPathLM\Streamripper"
testpth= "{STREAMRIPPER}\streamripper.exe"
is_opt = '($optionalInstall)' # โ could use '((Ask "Install streamripper too [y/N]") -match N)' instead
prescn = 'if ($optionalInstall) {if ($t.found = (Get-ITPV "Streamripper")) {$STREAMRIPPER = $t.found}} else {$STREAMRIPPER=""; continue;}'
},
@{
title = "Mutagen (ID3-Support)"
url = "mutagen" # no download url
cmd = "pip"
iargs = "--disable-pip-version-check"
testpth= "{PYTHON}\Lib\site-packages\mutagen-1*py2.7.egg-info"
is_opt = '($optionalInstall)'
prescn = 'if ($optionalInstall) {if ($t.found = (test-path -path $t.testpth)) {$t.found = $t.testpth}} else {continue}'
},
@{
title = "Uninstall script"
cmd = 'Create-Uninstallscript'
},
@{
title = "Desktop shortcut"
cmd = 'Make-Shortcut @task'
dir = "$Home\Desktop"
name = "Streamtuner2.lnk"
target = "$PYTHON\pythonw.exe"
arg = "$UsrFolder\bin\streamtuner2"
},
@{
title = "Startmenu shortcut"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2"
name = "Streamtuner2.lnk"
target = "$PYTHON\pythonw.exe"
arg = "$UsrFolder\bin\streamtuner2"
},
@{
title = "Startmenu help.chm"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2"
name = "Help.lnk"
target = "$UsrFolder\share\streamtuner2\help\help.chm"
},
@{
title = "Startmenu uninstall"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2"
name = "Uninstall.lnk"
target = "$UninstallPath"
},
@{
title = "Startmenu Internet"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2"
name = "Streamtuner2 on the Web.lnk"
target = "$AboutLink"
},
@{
title = "Startmenu Reconfigure"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2\Extra"
name = "Reconfigure.lnk"
target = "$ModifyPath"
},
@{
title = "Startmenu RunDebug"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2\Extra"
name = "Run in debug mode (-D).lnk"
target = "$PYTHON\python.exe"
arg = "$UsrFolder\bin\streamtuner2"
parm = "-D"
},
@{
title = "Startmenu RunConsole"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2\Extra"
name = "Run with console.lnk"
target = "$PYTHON\python.exe"
arg = "$UsrFolder\bin\streamtuner2"
},
@{
title = "Startmenu ResetPrefs"
cmd = 'Make-Shortcut @task'
dir = "$StartMenu\Streamtuner2\Extra"
name = "Reset preferences.lnk"
target = "$ResetPrefsPath"
|
︙ | | | ︙ | |
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
| __/\\\______\//\\\________\/\\\_________/\\\/___________ |
| _\///\\\\\\\\\\\/_________\/\\\________/\\\\\\\\\\\\\\\_ |
| ___\///////////___________\///________\///////////////__ |
| |
| |
| Streamtuner2 for Windows Version $VERSION |
| |
| Installer for Python 2.7.12 & Gtk 2.24.2 |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"@
}
function Ask-First {
Write-Host ""
if ((Ask "Do you want to install Streamtuner2 and its Python dependencies now? [Y/n] ") -notmatch "^[yY]|^$") {
#$tasks = $tasks[7..($tasks.length-1)]; return 0,0
|
|
|
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
| __/\\\______\//\\\________\/\\\_________/\\\/___________ |
| _\///\\\\\\\\\\\/_________\/\\\________/\\\\\\\\\\\\\\\_ |
| ___\///////////___________\///________\///////////////__ |
| |
| |
| Streamtuner2 for Windows Version $VERSION |
| |
| Installer for Python 2.7.13 & Gtk 2.24.2 |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
"@
}
function Ask-First {
Write-Host ""
if ((Ask "Do you want to install Streamtuner2 and its Python dependencies now? [Y/n] ") -notmatch "^[yY]|^$") {
#$tasks = $tasks[7..($tasks.length-1)]; return 0,0
|
︙ | | | ︙ | |
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
[CmdletBinding()]
param()
# update uninstall.cmd with current values
$installFolder = $usrFolder.substring(0,$usrFolder.LastIndexOf('\'))
$UninstallScript = Get-Content -Path $UninstallPath
Out-File -FilePath $UninstallPath -Encoding ascii -InputObject @"
@set installFolder=$installFolder
@set usrFolder=$usrFolder
@set Python=$PYTHON
@set StreamripperFolder=$STREAMRIPPER
"@
$UninstallScript | %{if ($_ -notmatch "@set") {Out-File -FilePath $UninstallPath -Encoding ascii -Append -InputObject $_}}
# registry entry for ST2
Remove-Item -Path $regPathCU\Streamtuner2 2> $null
New-Item $regPathCU -Name "Streamtuner2" > $null
|
<
|
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
[CmdletBinding()]
param()
# update uninstall.cmd with current values
$installFolder = $usrFolder.substring(0,$usrFolder.LastIndexOf('\'))
$UninstallScript = Get-Content -Path $UninstallPath
Out-File -FilePath $UninstallPath -Encoding ascii -InputObject @"
@set installFolder=$installFolder
@set Python=$PYTHON
@set StreamripperFolder=$STREAMRIPPER
"@
$UninstallScript | %{if ($_ -notmatch "@set") {Out-File -FilePath $UninstallPath -Encoding ascii -Append -InputObject $_}}
# registry entry for ST2
Remove-Item -Path $regPathCU\Streamtuner2 2> $null
New-Item $regPathCU -Name "Streamtuner2" > $null
|
︙ | | | ︙ | |
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
}
}
#-- Check if previous Python 2.7 installation exists
function Check-PythonInstall {
$PythonInstalledPath = Get-ITPV('Python\PythonCore\2.7\InstallPath\')
#-- if Python 2.7.12 installed, reuse installation folder
if (Get-Item -path "$regPathLM\{9DA28CE5-0AA5-429E-86D8-686ED898C665}" 2> $null ) {
$PYTHON = $pythonInstalledPath -replace "\\$", ""
}
#-- older 2.7 version found
else {
if ($PythonInstalledPath) {
Write-Host ""
|
|
|
|
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
}
}
#-- Check if previous Python 2.7 installation exists
function Check-PythonInstall {
$PythonInstalledPath = Get-ITPV('Python\PythonCore\2.7\InstallPath\')
#-- if Python 2.7.13 installed, reuse installation folder
if (Get-Item -path "$regPathLM\$PythonGUID" 2> $null ) {
$PYTHON = $pythonInstalledPath -replace "\\$", ""
}
#-- older 2.7 version found
else {
if ($PythonInstalledPath) {
Write-Host ""
|
︙ | | | ︙ | |
373
374
375
376
377
378
379
380
381
382
383
384
385
386
|
# ยท $prescn โ used in check-prereq()
#
filter Run-Task {
# extract flags/vars from $tasks pipe
$title=""; $cmd=""; $url=""; $iargs=""; $testpth=""; $regkey=""; $is_opt=""; $prescn=""; $found=""
($task = $_).GetEnumerator() | % { Set-Variable -Scope Local -Name $_.key -Value ([regex]::Replace($_.value, "[#{](\w+)[}#]", { param($m) Invoke-Expression ("$"+$m.Groups[1].Value) })) }
# skip optionals
if ($is_opt -AND !(Invoke-Expression $is_opt)) { return }
# print step
if ($title -match "\d+\.\d+") { $title = "Installing $title" }
Write-Host -b DarkBlue "`n $title `n"
chdir($TEMP);
|
>
>
|
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
|
# ยท $prescn โ used in check-prereq()
#
filter Run-Task {
# extract flags/vars from $tasks pipe
$title=""; $cmd=""; $url=""; $iargs=""; $testpth=""; $regkey=""; $is_opt=""; $prescn=""; $found=""
($task = $_).GetEnumerator() | % { Set-Variable -Scope Local -Name $_.key -Value ([regex]::Replace($_.value, "[#{](\w+)[}#]", { param($m) Invoke-Expression ("$"+$m.Groups[1].Value) })) }
# $iargs = $iargs -replace "{PYTHON}","$PYTHON"
# skip optionals
if ($is_opt -AND !(Invoke-Expression $is_opt)) { return }
# print step
if ($title -match "\d+\.\d+") { $title = "Installing $title" }
Write-Host -b DarkBlue "`n $title `n"
chdir($TEMP);
|
︙ | | | ︙ | |
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
|
$wget.DownloadFile($url, "$TEMP\$file");
}
# run shorthand or custom command
if ($cmd) {
if (Test-Path $PYTHON) { chdir($PYTHON) }
if ($cmd -eq "pip") {
$cmd = "& `"$PYTHON\Scripts\pip.exe`" install $TEMP\$file", $iargs #"
}
elseif ($cmd -match "^(easy|easy_install|silent)$") {
if (!($file)) {
$cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $url" #"
}
else {
$cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $TEMP\$file" #"
}
}
Write-Host -f DarkGray " โ $cmd"
Invoke-Expression "$cmd"
}
# msi
elseif ($file -match ".+.msi$") {
|
>
|
>
>
>
>
|
|
|
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
|
$wget.DownloadFile($url, "$TEMP\$file");
}
# run shorthand or custom command
if ($cmd) {
if (Test-Path $PYTHON) { chdir($PYTHON) }
if ($cmd -eq "pip") {
if (!($file)) {
$cmd = "& `"$PYTHON\Scripts\pip.exe`" install $url", $iargs
}
else {
$cmd = "& `"$PYTHON\Scripts\pip.exe`" install $TEMP\$file", $iargs
}
}
elseif ($cmd -match "^(easy|easy_install|silent)$") {
if (!($file)) {
$cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $url", $iargs
}
else {
$cmd = "& `"$PYTHON\Scripts\easy_install.exe`" $TEMP\$file", $iargs
}
}
Write-Host -f DarkGray " โ $cmd"
Invoke-Expression "$cmd"
}
# msi
elseif ($file -match ".+.msi$") {
|
︙ | | | ︙ | |