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
|
if(!(Test-Path $regPathLM)) { $regPathLM = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall" } #32-Bit machine
$pythonPathLM = (Get-ItemProperty -path ($regPathLM.substring(0,$regPathLM.indexOf("\Microsoft"))+ "\Python\PythonCore\2.7\InstallPath\")).'(default)' 2> $null
$pythonPathCU = (Get-ItemProperty -path ($regPathCU.substring(0,$regPathCU.indexOf("\Microsoft"))+ "\Python\PythonCore\2.7\InstallPath\")).'(default)' 2> $null
#-- what and how to install
# each row is a list of (title,url,cmd,msi args,regkey,reghive,optional)
$tasks = @(
<#
@(
"Package Dependencies",
"",
"Check-Prerequisites",
"",
"",
"",
""
),
#>
@(
"Python 2.7.12", # title
"https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi", # url
"", # custom cmd
'TARGETDIR="#PYTHON#" /qb-!', # msi args
"$regPathLM\{9DA28CE5-0AA5-429E-86D8-686ED898C665}", # registry
"#PYTHON#\pythonw.exe", # installed check
"" # optional component
),
@(
"PyGtk 2.24.2",
"http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi",
"",
'TARGETDIR="#PYTHON#" ADDLOCAL=ALL REMOVE=PythonExtensionModulePyGtkSourceview2,PythonExtensionModulePyGoocanvas,PythonExtensionModulePyRsvg,DevelopmentTools /qb-!',
"$regPathLM\{09F82967-D26B-48AC-830E-33191EC177C8}",
"$regPathLM\{09F82967-D26B-48AC-830E-33191EC177C8}",
""
),
@(
"Python requests",
"requests", # no download url, pip handles this
"easy_install",
"",
"",
"#PYTHON#\Lib\site-packages\requests-2.12.1-py2.7.egg",
""
),
@(
"LXML 2.3",
"https://pypi.python.org/packages/3d/ee/affbc53073a951541b82a0ba2a70de266580c00f94dd768a60f125b04fca/lxml-2.3.win32-py2.7.exe",
"",
"",
"$regPathCU\lxml-py2.7",
"#PYTHON#\Lib\site-packages\lxml-2.3-py2.7.egg-info",
""
),
@(
"PyQuery 1.2.1",
"https://pypi.python.org/packages/62/71/8ac1f5c0251e51714d20e4b102710d5eee1683c916616129552b0a025ba5/pyquery-1.2.17-py2.py3-none-any.whl",
"pip",
"--disable-pip-version-check",
"",
"#PYTHON#\Lib\site-packages\pyquery-1.2.17.dist-info",
""
),
@(
"PIL 1.1.7",
"http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe",
"",
"",
"$regPathCU\PIL-py2.7",
"#PYTHON#\Lib\site-packages\PIL",
""
),
@(
"Streamripper 1.64.6",
"http://downloads.sourceforge.net/project/streamripper/streamripper%20%28current%29/1.64.6/streamripper-windows-installer-1.64.6.exe?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fstreamripper%2Ffiles%2Fstreamripper%2520%2528current%2529%2F1.64.6%2F&ts=1480104543&use_mirror=kent"
"",
"",
"$regPathLM\Streamripper",
"#STREAMRIPPER#\streamripper.exe",
'($true)'
),
@(
"Uninstall script",
"",
'Create-Uninstallscript',
"",
|
|
<
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
|
|
|
|
|
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
|
if(!(Test-Path $regPathLM)) { $regPathLM = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall" } #32-Bit machine
$pythonPathLM = (Get-ItemProperty -path ($regPathLM.substring(0,$regPathLM.indexOf("\Microsoft"))+ "\Python\PythonCore\2.7\InstallPath\")).'(default)' 2> $null
$pythonPathCU = (Get-ItemProperty -path ($regPathCU.substring(0,$regPathCU.indexOf("\Microsoft"))+ "\Python\PythonCore\2.7\InstallPath\")).'(default)' 2> $null
#-- what and how to install
# each row is a list of (title,url,cmd,msi args,regkey,optional)
$tasks = @(
@(
"Python 2.7.12", # title
"https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi", # url
"", # custom cmd
'TARGETDIR="{PYTHON}" /qb-!', # msi args
"$regPathLM\{9DA28CE5-0AA5-429E-86D8-686ED898C665}", # registry
"{PYTHON}\pythonw.exe", # installed check
"" # is optional?
),
@(
"PyGtk 2.24.2",
"http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.2.win32-py2.7.msi",
"",
'TARGETDIR="{PYTHON}" ADDLOCAL=ALL REMOVE=PythonExtensionModulePyGtkSourceview2,PythonExtensionModulePyGoocanvas,PythonExtensionModulePyRsvg,DevelopmentTools /qb-!',
"$regPathLM\{09F82967-D26B-48AC-830E-33191EC177C8}",
"$regPathLM\{09F82967-D26B-48AC-830E-33191EC177C8}",
""
),
@(
"Python requests",
"requests", # no download url, pip handles this
"easy_install",
"",
"",
"{PYTHON}\Lib\site-packages\requests-2.12.1-py2.7.egg",
""
),
@(
"LXML 2.3",
"https://pypi.python.org/packages/3d/ee/affbc53073a951541b82a0ba2a70de266580c00f94dd768a60f125b04fca/lxml-2.3.win32-py2.7.exe",
"",
"",
"$regPathCU\lxml-py2.7",
"{PYTHON}\Lib\site-packages\lxml-2.3-py2.7.egg-info",
""
),
@(
"PyQuery 1.2.1",
"https://pypi.python.org/packages/62/71/8ac1f5c0251e51714d20e4b102710d5eee1683c916616129552b0a025ba5/pyquery-1.2.17-py2.py3-none-any.whl",
"pip",
"--disable-pip-version-check",
"",
"{PYTHON}\Lib\site-packages\pyquery-1.2.17.dist-info",
""
),
@(
"PIL 1.1.7",
"http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe",
"",
"",
"$regPathCU\PIL-py2.7",
"{PYTHON}\Lib\site-packages\PIL",
""
),
@(
"Streamripper 1.64.6",
"http://downloads.sourceforge.net/project/streamripper/streamripper%20%28current%29/1.64.6/streamripper-windows-installer-1.64.6.exe?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fstreamripper%2Ffiles%2Fstreamripper%2520%2528current%2529%2F1.64.6%2F&ts=1480104543&use_mirror=kent"
"",
"",
"$regPathLM\Streamripper",
"{STREAMRIPPER}\streamripper.exe",
'($true)'
),
@(
"Uninstall script",
"",
'Create-Uninstallscript',
"",
|
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
"",
'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name "Reconfigure.lnk" -target $UsrFolder\share\streamtuner2\dev\install_python_gtk.bat',
"",
"",
"",
""
),
@(
"FINISHED", "", 'Any-Key Green', "", "", "", ""
)
)
#-- startup messages
function Display-Logo {
# Clear-Host
# Console-MaxHeight
Write-Host -b DarkBlue @"
_____________________________________________________________________________
| |
| _____/\\\\\\\\\\\____/\\\\\\\\\\\\\\\____/\\\\\\\\\_____ |
| ___/\\\/////////\\\_\///////\\\/////___/\\\///////\\\___ |
| __\//\\\______\///________\/\\\_______\///______\//\\\__ |
| ___\////\\\_______________\/\\\_________________/\\\/___ |
| ______\////\\\____________\/\\\______________/\\\//_____ |
| _________\////\\\_________\/\\\___________/\\\//________ |
| __/\\\______\//\\\________\/\\\_________/\\\/___________ |
| _\///\\\\\\\\\\\/_________\/\\\________/\\\\\\\\\\\\\\\_ |
| ___\///////////___________\///________\///////////////__ |
| |
| |
| Streamtuner2 for Windows Version 2.2.0 |
| |
| Installer for Python 2.7.12 & Gtk 2.24.2 |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
"@
}
<#
function Warn-NonElevated {
if (Test-IsElevated) {
return
}
Write-Host ""
Write-Host -f red " ___________________________________________________________________________"
Write-Host -f red "| If you run this script in non-elevated mode you will not be able to |"
Write-Host -f red "| uninstall Streamtuner2, Python and Gtk |"
Write-Host -f red "| using the control panelsΒ΄ software list. |"
Write-Host -f red " ___________________________________________________________________________"
}
#>
function Ask-First {
Write-Host ""
Write-Host -f Yellow "Do you want to install Python 2.7.12 and Gtk dependencies now?"
Write-Host -f Yellow "ββββββββββββββββββββββββββββββββββββ---βββββββββββββββββββββββ"
Write-Host ""
if ((Read-Host "[Y/n]") -notmatch "^[yY]|^$") {
exit;
# or $tasks = $tasks[7..($tasks.length-1)]
}
Write-Host ""
Write-Host -f Yellow "Do you want to reuse any cached setup files?"
Write-Host -f Yellow "--------------------------------------------"
$reuseCachedFiles = Read-Host "[r]euse/[I]gnore)" -match "^[Rr]"
Write-Host ""
Write-Host -f Yellow "Do you want to check optional components?"
Write-Host -f Yellow "-----------------------------------------"
$optionalInstall = Read-Host "[y/N]" -match "^[Yy]"
Write-Host ""
$reuseCachedFiles
$optionalInstall
return
}
function Console-MaxHeight {
if ($Host.Name -match "console") {
$MaxHeight = $host.UI.RawUI.MaxPhysicalWindowSize.Height
$MaxWidth = $host.UI.RawUI.MaxPhysicalWindowSize.Width
$MyBuffer = $Host.UI.RawUI.BufferSize
$MyWindow = $Host.UI.RawUI.WindowSize
$MyWindow.Height = ($MaxHeight)
$MyWindow.Width = (80)
$MyBuffer.Height = (9999)
#$MyBuffer.Width = (80)
$host.UI.RawUI.set_bufferSize($MyBuffer)
$host.UI.RawUI.set_windowSize($MyWindow)
}
}
#-- create Desktop/Startmenu shortcuts
function Make-Shortcut {
[CmdletBinding()]
param($dir, $name, $target, $arg=$false)
if (!(Test-Path -Path $dir)) {
|
>
>
>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
|
<
<
<
|
<
<
|
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
"",
'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name "Reconfigure.lnk" -target $UsrFolder\share\streamtuner2\dev\install_python_gtk.bat',
"",
"",
"",
""
),
@(
"Basic configuration", "", 'Create-StreamtunerJSON', "", "", "", ""
),
@(
"FINISHED", "", 'Any-Key Green', "", "", "", ""
)
)
#-- startup messages
function Display-Logo {
Write-Host -b DarkBlue @"
_____________________________________________________________________________
| |
| _____/\\\\\\\\\\\____/\\\\\\\\\\\\\\\____/\\\\\\\\\_____ |
| ___/\\\/////////\\\_\///////\\\/////___/\\\///////\\\___ |
| __\//\\\______\///________\/\\\_______\///______\//\\\__ |
| ___\////\\\_______________\/\\\_________________/\\\/___ |
| ______\////\\\____________\/\\\______________/\\\//_____ |
| _________\////\\\_________\/\\\___________/\\\//________ |
| __/\\\______\//\\\________\/\\\_________/\\\/___________ |
| _\///\\\\\\\\\\\/_________\/\\\________/\\\\\\\\\\\\\\\_ |
| ___\///////////___________\///________\///////////////__ |
| |
| |
| Streamtuner2 for Windows Version 2.2.0 |
| |
| Installer for Python 2.7.12 & Gtk 2.24.2 |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
"@
}
function Ask-First {
Write-Host ""
if ((Ask "Do you want to install Python 2.7.12 and Gtk dependencies now? [Y/n] ") -notmatch "^[yY]|^$") {
exit;
# or $tasks = $tasks[7..($tasks.length-1)]
}
$reuseCachedFiles = (Ask "Do you want to reuse any cached setup files? [r]euse/[I]gnore) ") -match "^[Rr]"
$optionalInstall = (Ask "Do you want to check optional components? [y/N] ") -match "^[Yy]"
Write-Host ""
return $reuseCachedFiles, $optionalInstall
}
function Console-MaxHeight {
if ($Host.Name -match "console") {
$MaxHeight = $host.UI.RawUI.MaxPhysicalWindowSize.Height
$MaxWidth = $host.UI.RawUI.MaxPhysicalWindowSize.Width
$MyBuffer = $Host.UI.RawUI.BufferSize
$MyWindow = $Host.UI.RawUI.WindowSize
$MyWindow.Height = ($MaxHeight)
$MyWindow.Width = (80)
$MyBuffer.Height = (9999)
#$MyBuffer.Width = (80)
$host.UI.RawUI.set_bufferSize($MyBuffer)
$host.UI.RawUI.set_windowSize($MyWindow)
}
}
#-- create Desktop/Startmenu shortcuts
function Make-Shortcut {
[CmdletBinding()]
param($dir, $name, $target, $arg=$false)
if (!(Test-Path -Path $dir)) {
|
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
|
$streamripperPath
return
}
#-- ask before running
Console-MaxHeight
Display-Logo
$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$","") #temp fix for running on Windows 10
$PYTHON = Check-PythonInstall
$reuseCachedFiles, $optionalInstall = Ask-First
$STREAMRIPPER = Check-Prerequisites
Clear-Host
Display-Logo
#-- process
ForEach ($task in $tasks) {
ForEach ($key in $task.keys()) { $task[$key] = [regex]::Replace($task[$key], "#(\w+)#", { param($m) Invoke-Expression ("$"+$m.Groups[1].Value) }) }
$title, $url, $cmd, $args, $regkey, $testpath, $optional = $task;
# options
if ($optional -AND (Invoke-Expression $optional) -AND !$optionalInstall) {
continue # β expression test
}
# print step
if ($title -match "\d+\.\d+") { $title = "Installing $title" }
Write-Host -b DarkBlue "`n $title `n"
chdir($TEMP);
# test if element (file path or registry key) already exists:
if ($reinstall -eq "all") {
}
elseif ($testpath -AND (Test-Path -Path $testpath)) {
if ($reinstall -eq "none") {Write-Host " β Kept as is."; continue }
Write-Host -f Green -NoNewline " β Is already present."
#if ($title -match "Python 2.7.12") {Write-Host -f Green " (in $PYTHON)"}
#if ($title -match "Streamripper 1.64.6") {Write-Host -f Green " (in $STREAMRIPPER)"}
Write-Host -f Yellow -NoNewline " Reinstall [y/N/all/none]? " ; $y = Read-Host ; Write-Host ""
if ($y -match "^all|always|re|^A") { $reinstall = "all" }
elseif ($y -match "never|none|skip|^S") { $reinstall = "none"; continue }
elseif ($y -match "^y|yes|1|go|^R") { } # YES
else { continue } # everything else counts as NO
}
# get "filename" part from url
|
>
|
|
<
<
|
>
|
<
<
|
|
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
$streamripperPath
return
}
#-- ask before running
Clear-Host
Console-MaxHeight
Display-Logo
$UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$","") #temp fix for running on Windows 10
$PYTHON = Check-PythonInstall
$reuseCachedFiles, $optionalInstall = Ask-First
$STREAMRIPPER = Check-Prerequisites
#Clear-Host
#Display-Logo
#-- process
ForEach ($task in $tasks) {
$title, $url, $cmd, $args, $regkey, $testpath, $optional = $task |
% { [regex]::Replace($_, "[#{](\w+)[}#]", { param($m) Invoke-Expression ("$"+$m.Groups[1].Value) }) }
# options
if ($optional -AND (Invoke-Expression $optional) -AND !$optionalInstall) {
continue # optional expression test
}
# print step
if ($title -match "\d+\.\d+") { $title = "Installing $title" }
Write-Host -b DarkBlue "`n $title `n"
chdir($TEMP);
# test if element (file path or registry key) already exists:
if ($reinstall -eq "all") {
}
elseif ($testpath -AND (Test-Path -Path $testpath)) {
if ($reinstall -eq "none") {Write-Host " β Kept as is."; continue }
Write-Host -f Green -NoNewline " β Is already present."
$y = Ask " Reinstall [y/N/all/none]? "
if ($y -match "^all|always|re|^A") { $reinstall = "all" }
elseif ($y -match "never|none|skip|^S") { $reinstall = "none"; continue }
elseif ($y -match "^y|yes|1|go|^R") { } # YES
else { continue } # everything else counts as NO
}
# get "filename" part from url
|