Index: dev/install_python_gtk.ps1 ================================================================== --- dev/install_python_gtk.ps1 +++ dev/install_python_gtk.ps1 @@ -25,10 +25,11 @@ ) #-- paths $UsrFolder = $MyInvocation.MyCommand.Path -replace ("([\\/][^\\/]+){4}$","") $UninstallPath = "$UsrFolder\share\streamtuner2\dev\uninstall.cmd" +$ResetPrefsPath = $UninstallPath -replace ("uninstall", "resetprefs") $ModifyPath = $MyInvocation.MyCommand.Path -replace ("[.]ps1$", ".bat") $IconPath = "$UsrFolder\share\pixmaps\streamtuner2.ico" #-- system configuration $ErrorActionPreference = "SilentlyContinue" # ignore all path/registry lookup errors @@ -37,125 +38,113 @@ $regPathLM = "HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" #64-Bit machine if(!(Test-Path $regPathLM)) { #32-Bit machine $regPathLM = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall" $ProgramFiles = "%ProgramFiles%" } -New-Variable -Name STREAMRIPPER -Option AllScope -Value "$ProgramFiles\Streamripper" +New-Variable -Name STREAMRIPPER -Option AllScope -Value "$ProgramFiles\Streamripper" #can be changed in Check-Prerequisites - -#-- what and how to install -# each row is a list of (title, url, cmd, msi args, regkey, pathcheck, is_optional, prelookup) +#-- what and how to install (hash list as used by Run-Task and Check-Prerequisites) $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? - '' # check-prerequisite→$_found? - ), - @( - "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}\Lib\site-packages\gtk-2.0\pygtk-2.24.0-py2.7.egg-info", - "", - '' - ), - @( - "Python requests", - "requests", # no download url, pip handles this - "easy_install", - "", - "", - "{PYTHON}\Lib\site-packages\requests-2*py2.7.egg", - "", - '' - ), - @( - "LXML 2.3", - "https://pypi.python.org/packages/d4/fa/e4e0c7a8fe971b10e275cdc20efd16f553a225e700c400c11da25276e4f4/lxml-2.3-py2.7-win32.egg", - "easy_install", - "", - "", - "{PYTHON}\Lib\site-packages\lxml-2.3-py2.7-win32.egg", - "", - '' - ), - @( - "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", - "https://netcologne.dl.sourceforge.net/project/streamripper/streamripper%20%28current%29/1.64.6/streamripper-windows-installer-1.64.6.exe", - "", - "/S /D={STREAMRIPPER}" #NSIS does not use double quotes in /D parm, - "$regPathLM\Streamripper", - "{STREAMRIPPER}\streamripper.exe", - '($true)', # ← could use '((Ask "Install streamripper too [y/N]") -match N)' instead - '($optionalInstall -AND ($_found = (Get-ITPV "Streamripper")) -AND ($STREAMRIPPER = $_found) -OR ((!$optionalInstall) -AND $STREAMRIPPER=""))' # look up path in Check-Prerequisites - ), - @( - "Uninstall script", - "", - 'Create-Uninstallscript' - ), - @( - "Desktop shortcut", - "", - 'Make-Shortcut -dir $Home\Desktop -name Streamtuner2.lnk -target $PYTHON\pythonw.exe -arg $UsrFolder\bin\streamtuner2' - ), - @( - "Startmenu shortcut", - "", - 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Streamtuner2.lnk -target $PYTHON\pythonw.exe -arg $UsrFolder\bin\streamtuner2' - ), - @( - "Startmenu help.chm", - "", - 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Help.lnk -target $UsrFolder\share\streamtuner2\help\help.chm' - ), - @( - "Startmenu uninstall", - "", - 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name Uninstall.lnk -target $UninstallPath' - ), - @( - "Startmenu Internet", - "", - 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name "Streamtuner2 on the Web.lnk" -target "$AboutLink"' - ), - @( - "Startmenu Reconfigure", - "", - 'Make-Shortcut -dir "$StartMenu\Streamtuner2" -name "Reconfigure.lnk" -target $ModifyPath' - ), - @( - "FINISHED" - ) + @{ + title = "Python 2.7.12" + url = "https://www.python.org/ftp/python/2.7.12/python-2.7.12.msi" + cmd = "" + args = '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" + cmd = "" + args = 'TARGETDIR="{PYTHON}" ADDLOCAL=ALL REMOVE=PythonExtensionModulePyGtkSourceview2,PythonExtensionModulePyGoocanvas,PythonExtensionModulePyRsvg,DevelopmentTools /qb-!' + regkey = "$regPathLM\{09F82967-D26B-48AC-830E-33191EC177C8}" + testpth= "{PYTHON}\Lib\site-packages\gtk-2.0\pygtk-2.24.0-py2.7.egg-info" + }, + @{ + title = "Python requests" + url = "requests" # no download url, pip handles this + cmd = "easy_install" + testpth= "{PYTHON}\Lib\site-packages\requests-2*py2.7.egg" + }, + @{ + title = "LXML 2.3" + url = "https://pypi.python.org/packages/d4/fa/e4e0c7a8fe971b10e275cdc20efd16f553a225e700c400c11da25276e4f4/lxml-2.3-py2.7-win32.egg" + cmd = "easy_install" + testpth= "{PYTHON}\Lib\site-packages\lxml-2.3-py2.7-win32.egg" + }, + @{ + title = "PyQuery 1.2.1" + url = "https://pypi.python.org/packages/62/71/8ac1f5c0251e51714d20e4b102710d5eee1683c916616129552b0a025ba5/pyquery-1.2.17-py2.py3-none-any.whl" + cmd = "pip" + args = "--disable-pip-version-check" + testpth= "{PYTHON}\Lib\site-packages\pyquery-1.2.17.dist-info" + }, + @{ + title = "PIL 1.1.7" + url = "http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe" + regkey = "$regPathCU\PIL-py2.7" + testpth= "{PYTHON}\Lib\site-packages\PIL" + }, + @{ + 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 = "" + args = "/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 ($_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\Advanced" -name "Reconfigure.lnk" -target $ModifyPath' + }, + @{ + title = "Startmenu RunDebug" + cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2\Advanced" -name "Run in debug mode.lnk" -target $PYTHON\python.exe -arg "$UsrFolder\bin\streamtuner2" -parm "-D"' + }, + @{ + title = "Startmenu RunConsole" + cmd = 'Make-Shortcut -dir "$StartMenu\Streamtuner2\Advanced" -name "Run with console.lnk" -target $PYTHON\python.exe -arg "$UsrFolder\bin\streamtuner2"' + }, + @{ + title = "Startmenu ResetPrefs" + cmd = 'Make-Shortcut @task' + dir = "$StartMenu\Streamtuner2\Advanced" + name = "Reset preferences.lnk" + target = "$ResetPrefsPath" + }, + @{ + title = "FINISHED" + } ) #-- startup messages @@ -207,21 +196,20 @@ } } #-- create Desktop/Startmenu shortcuts function Make-Shortcut { - [CmdletBinding()] - param($dir, $name, $target, $arg=$false) + param($dir, $name, $target, $arg=$false, $parm=$false, [parameter(ValueFromRemainingArguments)]$kwargs) if (!(Test-Path -Path $dir)) { New-Item -Path $dir -ItemType directory > $null } $wsh = New-Object -ComObject WScript.Shell if (!$wsh) { return } $lnk = $wsh.CreateShortcut("$dir\$name") $lnk.TargetPath = $target if ($arg) { - $lnk.Arguments = '"'+$arg+'"' + ($lnk.Arguments = '"'+$arg+'"') | %{if ($parm) {$lnk.Arguments += " $parm"}} $lnk.IconLocation = "$IconPath" $lnk.WorkingDirectory = "$UsrFolder\bin" } $lnk.Save() } @@ -330,38 +318,36 @@ #-- check prereqs installation function Check-Prerequisites { [CmdletBinding()] param($result = 1) - ForEach ($task in $tasks) { - $title, $url, $cmd, $args, $regkey, $checkpath, $is_optional, $presearch, $_found = $task; - $checkpath = $checkpath -replace "{PYTHON}","$PYTHON" - #if ($is_optional -and !$optionalInstall) { - # $STREAMRIPPER = "" - # continue - #} - if (!$regkey -and !$checkpath) { - continue - } - if ($presearch) { # expression for e.g. registry → path lookup - Invoke-Expression $presearch > $null # should set $_found + global $PLACEHOLDER variable - } - elseif ($checkpath) { - if (Test-Path $checkpath) { - $_found = $checkpath - } - elseif ($regkey -and (Test-Path $regkey)) { - $_found = "installer/registry" - } - } - if (!$_found) { - Write-Host " - $title not found" - $result = 0; - } - else { - Write-Host -n " + $title found " # and display shortened path: - Write-Host -f DarkGray "($($_found -replace '(?nul +if %errorlevel% EQU 0 goto ST2isRunning +tasklist /fi "Imagename eq pythonw.exe" /fi "Windowtitle eq Streamtuner2*" /v | find "Streamtuner2" >nul +if %errorlevel% EQU 1 goto NotRunning + +:ST2isRunning +echo Streamtuner2 is still running! +echo Please close all instances of Streamtuner2 before uninstalling! +pause +exit + + + +:NotRunning echo | set /p=Do you want to uninstall Streamtuner2 for Windows? [y/N] set /P INPUT=%=% If /I NOT '%INPUT%' == 'Y' exit echo | set /p=Do you want to keep your Streamtuner2 settings? [Y/n] set /P INPUT=%=% If /I '%INPUT%' == 'N' ( echo Deleting personal settings... - del "%Userprofile%\AppData\Roaming\streamtuner2\*.*" /F /S /Q + del "%Userprofile%\AppData\Roaming\streamtuner2\*.*" /F /S /Q 1>nul ) set INPUT= if '"%StreamripperFolder%"' NEQ '' ( echo | set /p=Do you want to uninstall Streamripper? [y/N] @@ -102,12 +116,12 @@ echo Removing Streamtuner2 rd "%installFolder%" /S /Q echo Removing shortcuts -rd "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Streamtuner2" /S /Q +rd "%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Streamtuner2" /S /Q 1>nul del "%USERPROFILE%\Desktop\Streamtuner2.lnk" 1>nul reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Streamtuner2 /f 1>nul 2>&1 echo Finished uninstalling Streamtuner2 pause Index: gtk3.xml.gz ================================================================== --- gtk3.xml.gz +++ gtk3.xml.gz cannot compute difference between binary files