From b84fb56df896ed4a94402c8cf6d0dc768d75358e Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Thu, 10 Dec 2015 20:49:13 +0000 Subject: [PATCH] (GH-57) Updating to reflect chocolatey.org package which has been pushed already https://chocolatey.org/packages/openlivewriter --- OpenLiveWriter.Install.nuspec | 44 +++++++++++++++------------ choco/chocolateyInstall.ps1 | 10 ++++--- choco/chocolateyUninstall.ps1 | 56 +++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 choco/chocolateyUninstall.ps1 diff --git a/OpenLiveWriter.Install.nuspec b/OpenLiveWriter.Install.nuspec index 86ac1ff4..9853e539 100644 --- a/OpenLiveWriter.Install.nuspec +++ b/OpenLiveWriter.Install.nuspec @@ -1,20 +1,26 @@ - - - - openlivewriter.install - 0.0.0.0 - Open Live Writer - Open Live Writer - https://github.com/OpenLiveWriter/OpenLiveWriter/blob/master/license.txt?raw=true - http://openlivewriter.github.io/favicon.ico - true - Open Live Writer makes it easy to write, preview and post to your blog. - Open Live Writer - Blog WindowsLiveWriter Open Live Writer - https://github.com/OpenLiveWriter/OpenLiveWriter/releases - - - - - + + + + openlivewriter + 0.5.0.0 + OpenLiveWriter (Install) + See list of authors at http://openlivewriter.org/ + Darwin Sanoy, OpenLiveWriter + https://github.com/OpenLiveWriter/OpenLiveWriter/blob/master/license.txt + http://openlivewriter.org/ + https://cdn.rawgit.com/csi-windowschocolatey/openlivewriter/master/app.png + false + Open Live Writer is an open source application enabling users to author, edit, and publish blog posts. + It is based on a fork of the well-loved but not actively developed Windows Live Writer code. + Open Live Writer makes it easy to write, preview, and post to your blog. + .NET Foundation + Blog WindowsLiveWriter OpenLiveWriter + https://github.com/OpenLiveWriter/OpenLiveWriter/releases + + + + + + + \ No newline at end of file diff --git a/choco/chocolateyInstall.ps1 b/choco/chocolateyInstall.ps1 index 1fd10109..357b955b 100644 --- a/choco/chocolateyInstall.ps1 +++ b/choco/chocolateyInstall.ps1 @@ -1,7 +1,9 @@ -$packageName = 'openLiveWriter.install' -$fileType = 'exe' +$packageName= 'openlivewriter' +$fileType = 'EXE' $silentArgs = '--silent' $scriptPath = $(Split-Path $MyInvocation.MyCommand.Path) -$fileFullPath = Join-Path $scriptPath 'Setup.exe' +$fileFullPath = Join-Path $scriptPath 'OpenLiveWriterSetup.exe' -Install-ChocolateyInstallPackage $packageName $fileType $silentArgs $fileFullPath \ No newline at end of file +Install-ChocolateyInstallPackage $packageName $fileType $silentArgs $fileFullPath + +Write-Output "The install log is at `"$env:localappdata\SquirrelTemp\SquirrelSetup.log`"" \ No newline at end of file diff --git a/choco/chocolateyUninstall.ps1 b/choco/chocolateyUninstall.ps1 new file mode 100644 index 00000000..7bb820c0 --- /dev/null +++ b/choco/chocolateyUninstall.ps1 @@ -0,0 +1,56 @@ +$ErrorActionPreference = 'Stop'; + +$packageName = 'openlivewriter' +$softwareName = 'open live writer*' +$installerType = 'EXE' +$file = "$env:localappdata\OpenLiveWriter\Update.exe" + +$silentArgs = '--uninstall -s' + +if ($installerType -ne 'MSI') { + $validExitCodes = @(0) +} + +$uninstalled = $false +$local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' +$machine_key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*' +$machine_key6432 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' + +$key = Get-ItemProperty -Path @($machine_key6432,$machine_key, $local_key) ` + -ErrorAction SilentlyContinue ` + | ? { $_.DisplayName -like "$softwareName" } + +if (!(Test-Path "$env:localappdata\openlivewriter\openlivewriter.exe")) +{ + If (!(Test-Path $file)) + { + throw "Could not find $file - because this software is always installed to a user profile folder, it must be uninstalled in the context of the user who installed it." + } + else + { + Try { + Uninstall-ChocolateyPackage -PackageName $packageName ` + -FileType $installerType ` + -SilentArgs "$silentArgs" ` + -ValidExitCodes $validExitCodes ` + -File "$file" + + #Remove leftovers so new install will succeed + If (test-path "$env:localappdata\openlivewriter\.dead") + { + remove-item "$env:localappdata\openlivewriter" -Recurse -Force -ErrorAction 'SilentlyContinue' + } + If (test-path "C:\ProgramData\SquirrelMachineInstalls\OpenLiveWriter.exe") + { + remove-item "C:\ProgramData\SquirrelMachineInstalls\OpenLiveWriter.exe" -Force -ErrorAction 'SilentlyContinue' + } + Write-Output "The install log is at `"$env:localappdata\SquirrelTemp\SquirrelSetup.log`"" + } + Catch + { + throw $_.Exception + } + } +} else { + Write-Warning "$packageName has already been uninstalled by other means or it is installed to a user's profile who is not the current user ($env:username)." +}