From 8d03388413f6d35e4fbd6308c3819477729feaab Mon Sep 17 00:00:00 2001 From: Iristyle Date: Wed, 3 Apr 2013 12:28:08 -0400 Subject: [PATCH] fix(chrome installers): Check for existence - Don't launch Chrome installers if they're already installed - Heuristic for Canary is a path check - Heuristic for dev channel is path check + reg key --- .../GoogleChrome.Canary.nuspec | 1 + .../tools/chocolateyInstall.ps1 | 20 +++++++++-- GoogleChrome.Dev/GoogleChrome.Dev.nuspec | 1 + GoogleChrome.Dev/tools/chocolateyInstall.ps1 | 35 +++++++++++++++---- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/GoogleChrome.Canary/GoogleChrome.Canary.nuspec b/GoogleChrome.Canary/GoogleChrome.Canary.nuspec index 979b1c2..ed8f110 100644 --- a/GoogleChrome.Canary/GoogleChrome.Canary.nuspec +++ b/GoogleChrome.Canary/GoogleChrome.Canary.nuspec @@ -24,6 +24,7 @@ + diff --git a/GoogleChrome.Canary/tools/chocolateyInstall.ps1 b/GoogleChrome.Canary/tools/chocolateyInstall.ps1 index 09080d2..96f2358 100644 --- a/GoogleChrome.Canary/tools/chocolateyInstall.ps1 +++ b/GoogleChrome.Canary/tools/chocolateyInstall.ps1 @@ -2,9 +2,25 @@ $package = 'Chrome.Canary' try { - $url = 'https://dl.google.com/tag/s/appguid%3D%7B4ea16ac7-fd5a-47c3-875b-dbf4a2008c20%7D%26iid%3D%7B0281A7E2-6043-D983-8BBA-7FD622493C9D%7D%26lang%3Den%26browser%3D4%26usagestats%3D1%26appname%3DGoogle%2520Chrome%2520Canary%26needsadmin%3Dfalse/update2/installers/ChromeSetup.exe' + function Get-CurrentDirectory + { + $thisName = $MyInvocation.MyCommand.Name + [IO.Path]::GetDirectoryName((Get-Content function:$thisName).File) + } - Install-ChocolateyPackage 'ChromeSetup' 'exe' '' $url + . (Join-Path (Get-CurrentDirectory) 'ChromeHelpers.ps1') + + $installedPath = Get-ChromePath -Canary + if (Test-Path $installedPath) + { + Write-Host "Chrome Canary already installed at $installedPath" + } + else + { + $url = 'https://dl.google.com/tag/s/appguid%3D%7B4ea16ac7-fd5a-47c3-875b-dbf4a2008c20%7D%26iid%3D%7B0281A7E2-6043-D983-8BBA-7FD622493C9D%7D%26lang%3Den%26browser%3D4%26usagestats%3D1%26appname%3DGoogle%2520Chrome%2520Canary%26needsadmin%3Dfalse/update2/installers/ChromeSetup.exe' + + Install-ChocolateyPackage 'ChromeSetup' 'exe' '' $url + } Write-ChocolateySuccess $package } catch { diff --git a/GoogleChrome.Dev/GoogleChrome.Dev.nuspec b/GoogleChrome.Dev/GoogleChrome.Dev.nuspec index e706fa9..93a71ff 100644 --- a/GoogleChrome.Dev/GoogleChrome.Dev.nuspec +++ b/GoogleChrome.Dev/GoogleChrome.Dev.nuspec @@ -19,6 +19,7 @@ + diff --git a/GoogleChrome.Dev/tools/chocolateyInstall.ps1 b/GoogleChrome.Dev/tools/chocolateyInstall.ps1 index b3ffe88..76c4843 100644 --- a/GoogleChrome.Dev/tools/chocolateyInstall.ps1 +++ b/GoogleChrome.Dev/tools/chocolateyInstall.ps1 @@ -2,14 +2,37 @@ $package = 'Chrome.Dev' try { - $params = @{ - PackageName = $package; - FileType = 'exe'; - SilentArgs = '/silent /installsource silent /install'; - Url = 'https://dl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7B0AA7B49A-29EA-0AE3-8A45-61F351F89414%7D%26lang%3Den%26browser%3D2%26usagestats%3D0%26appname%3DGoogle%2520Chrome%26needsadmin%3Dfalse%26ap%3D2.0-dev%26installdataindex%3Ddefaultbrowser/update2/installers/ChromeSetup.exe' + function Get-CurrentDirectory + { + $thisName = $MyInvocation.MyCommand.Name + [IO.Path]::GetDirectoryName((Get-Content function:$thisName).File) } - Install-ChocolateyPackage @params + . (Join-Path (Get-CurrentDirectory) 'ChromeHelpers.ps1') + + $installedPath = Get-ChromePath + $params = @{ + Path = 'HKCU:\Software\Google\Update\ClientState\{8A69D345-D564-463C-AFF1-A69D9E530F96}'; + Name = 'ap'; + ErrorAction = 'SilentlyContinue'; + } + $installType = Get-ItemProperty @params | Select -ExpandProperty 'ap' + + if ((Test-Path $installedPath) -and ($installType -match 'dev')) + { + Write-Host "Chrome Dev already installed at $installedPath" + } + else + { + $params = @{ + PackageName = $package; + FileType = 'exe'; + SilentArgs = '/silent /installsource silent /install'; + Url = 'https://dl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7B0AA7B49A-29EA-0AE3-8A45-61F351F89414%7D%26lang%3Den%26browser%3D2%26usagestats%3D0%26appname%3DGoogle%2520Chrome%26needsadmin%3Dfalse%26ap%3D2.0-dev%26installdataindex%3Ddefaultbrowser/update2/installers/ChromeSetup.exe' + } + + Install-ChocolateyPackage @params + } Write-ChocolateySuccess $package } catch {