Downloads:

204

Downloads of v 2019.09.03:

204

Last Update:

03 Sep 2019

Package Maintainer(s):

Software Author(s):

  • Bill Curran

Tags:

bcurran3 cdeprecate choco unofficial package deprecate retire script chocolateasy

(unofficial) Chocolatey Package Deprecater/Retirer (Script)

2019.09.03 | Updated: 03 Sep 2019

Downloads:

204

Downloads of v 2019.09.03:

204

Maintainer(s):

Software Author(s):

  • Bill Curran

(unofficial) Chocolatey Package Deprecater/Retirer (Script) 2019.09.03

All Checks are Passing

2 Passing Test


Validation Testing Passed


Verification Testing Passed

Details

To install (unofficial) Chocolatey Package Deprecater/Retirer (Script), run the following command from the command line or from PowerShell:

>

To upgrade (unofficial) Chocolatey Package Deprecater/Retirer (Script), run the following command from the command line or from PowerShell:

>

To uninstall (unofficial) Chocolatey Package Deprecater/Retirer (Script), run the following command from the command line or from PowerShell:

>

NOTE: This applies to both open source and commercial editions of Chocolatey.

1. Ensure you are set for organizational deployment

Please see the organizational deployment guide

  • Open Source or Commercial:
    • Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://chocolatey.org/api/v2. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
    • You can also just download the package and push it to a repository Download

3. Enter your internal repository url

(this should look similar to https://chocolatey.org/api/v2)

4. Choose your deployment method:


choco upgrade choco-package-deprecater -y --source="'STEP 3 URL'" [other options]

See options you can pass to upgrade.

See best practices for scripting.

Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.

If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:


choco upgrade choco-package-deprecater -y --source="'STEP 3 URL'"
$exitCode = $LASTEXITCODE

Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
  Exit 0
}

Exit $exitCode

- name: Ensure choco-package-deprecater installed
  win_chocolatey:
    name: choco-package-deprecater
    state: present
    version: 2019.09.03
    source: STEP 3 URL

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.

Coming early 2020! Central Managment Reporting available now! More information...


chocolatey_package 'choco-package-deprecater' do
  action    :install
  version  '2019.09.03'
  source   'STEP 3 URL'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


Chocolatey::Ensure-Package
(
    Name: choco-package-deprecater,
    Version: 2019.09.03,
    Source: STEP 3 URL
);

Requires Otter Chocolatey Extension. See docs at https://inedo.com/den/otter/chocolatey.


cChocoPackageInstaller choco-package-deprecater
{
   Name     = 'choco-package-deprecater'
   Ensure   = 'Present'
   Version  = '2019.09.03'
   Source   = 'STEP 3 URL'
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'choco-package-deprecater':
  provider => 'chocolatey',
  ensure   => '2019.09.03',
  source   => 'STEP 3 URL',
}

Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.


salt '*' chocolatey.install choco-package-deprecater version="2019.09.03" source="STEP 3 URL"

See docs at https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.chocolatey.html.

5. If applicable - Chocolatey configuration/installation

See infrastructure management matrix for Chocolatey configuration elements and examples.

This package was approved by moderator gep13 on 04 Sep 2019.

Description


choco://choco-package-deprecater

To use choco:// protocol URLs, install (unofficial) choco:// Protocol support


Screenshot of (unofficial) Chocolatey Package Deprecater/Retirer (Script)

choco-package-deprecater (CDEPRECATE) is a PowerShell script I designed for Chocolatey package maintainers/creators to easily deprecate or retire a package. Probably not something you have to do often but CDEPRECATE will save you the time of having to look up what you need to do to your .nuspec file.

FEATURES:

  • CDEPRECATE rewrites a .nuspec file modifying it ready for deprecation or retirement.
  • CDEPRECATE backups up your original .nuspec file, always!
  • CDEPRECATE will create the necessary chocolateyInstall.ps1 for retired packages.
  • CDEPRECATE can add a "cute" iconUrl.

Helps make packaging Chocolateasy!

INSTRUCTIONS:

  • CDEPRECATE -help for help with options and switches

PACKAGE NOTES

If you find choco-package-deprecater useful please consider donating: https://www.paypal.me/bcurran3donations or become a patron at https://www.patreon.com/bcurran3


tools\.SkipAutoUninstaller
 
tools\cdeprecate.config
<?xml version="1.0"?>
<Settings>
  <Preferences>
    <DeprecatedDescription>##This package has been deprecated. It has been replaced by the dependency shown below.</DeprecatedDescription>
    <DeprecatedIconUrl>https://raw.githubusercontent.com/bcurran3/ChocolateyPackages/master/mylogos/deprecated.png</DeprecatedIconUrl>
    <RetiredDescription>##This package has been retired.</RetiredDescription>
    <RetiredIconUrl>https://raw.githubusercontent.com/bcurran3/ChocolateyPackages/master/mylogos/retired.png</RetiredIconUrl>
  </Preferences>
</Settings>

<!--
choco-package-deprecater.config preferences notes:

DeprecatedDescription - 
DeprecatedIconUrl     - 
RetiredDescription    - 
RetiredIconUrl        - 

-->
tools\cdeprecate.ps1
# cdeprecate.ps1 Copyleft 2019 by Bill Curran AKA BCURRAN3
# LICENSE: GNU GPL v3 - https://www.gnu.org/licenses/gpl.html
# Open a GitHub issue at https://github.com/bcurran3/ChocolateyPackages/issues if you have suggestions for improvement.

# REF: https://docs.microsoft.com/en-us/nuget/reference/nuspec
# REF: https://chocolatey.org/docs/how-to-deprecate-a-chocolatey-package
#
# REF: https://github.com/chocolatey/choco-wiki/issues/109
# REF: https://github.com/chocolatey/choco-wiki/issues/110

param (
    [string]$path=(Get-Location).path
 )

Write-Host "cdeprecate.ps1 v2019.09.03 - (unofficial) Chocolatey Package Deprecater/Retirer" -Foreground White
Write-Host "Copyleft 2019 Bill Curran ([email protected]) - free for personal and commercial use`n" -Foreground White

$ErrorActionPreference = 'Stop'
$PSDefaultParameterValues['*:Encoding'] = 'utf8'

if (($args -eq '-help') -or ($args -eq '-?') -or (!$args)) {
    Write-Host "OPTIONS AND SWITCHES:" -Foreground Magenta
	Write-Host "-help, -?"
	Write-Host "   Displays this information."
	Write-Host "-Deprecate"
	Write-Host "   Deprecate the package."
	Write-Host "-Retire"
	Write-Host "   Retire the package."
	Write-Host "-AddIcon"
	Write-Host "   Add a fun icon instead of no icon."
	Write-Host "-EditConfig"
	Write-Host "   Edit cdeprecate config file."
	Write-Host "-OpenDeprecateDocs"
	Write-Host "   Opens https://chocolatey.org/docs/how-to-deprecate-a-chocolatey-package in your default browser."
	Write-Host
	return
}

if ($args -eq "-Deprecate") {$Deprecate=$True} else {$Deprecate=$False}
if ($args -eq "-Retire") {$Retire=$True} else {$Retire=$False}
if ($args -eq "-AddIcon") {$AddIcon=$True} else {$AddIcon=$False}
if ($args -eq "-Debug") {$Debug=$True} else {$Debug=$False}
if ($args -eq "-EditConfig") {
    Write-Host "  ** Editing contents of $ENV:ChocolateyToolsLocation\BCURRAN3\cdeprecate.config." -Foreground Magenta
    if (Test-Path $ENV:ChocolateyInstall\bin\notepad++.exe){$Editor="notepad++.exe"} else {$Editor="notepad.exe"}
	&$Editor "$ENV:ChocolateyToolsLocation\BCURRAN3\cdeprecate.config"
	return
	}
if ($args -eq "-OpenDeprecateDocs") {&start https://chocolatey.org/docs/how-to-deprecate-a-chocolatey-package ; return }


if ($path -eq "\"){
    $path=(Get-Location).Drive.Name + ":" + "\"
}

if (!(Test-Path $path)){
    Write-Host "           ** $path is an invalid path." -Foreground Red
	return
   }

# Finds nuspec file for processing. Defaults to current working directory.
# You can specify a directory path, but do NOT specify the file itself, just the directory.
#if (!$path) {$LocalnuspecFile = Get-Item -Path $path\*.nuspec}
if ($path) {$LocalnuspecFile = Get-Item $path\*.nuspec}
if (!($LocalnuspecFile)) {
    Write-Host "           ** No .nuspec file found in $path" -Foreground Red
	return
   }
if ($LocalnuspecFile.count -gt 1){
    Write-Host "           ** Multiple .nuspec files found in $path. Please remove or rename the extras." -Foreground Red
	return
   }

# Import package.nuspec file to get values
$nuspecXML = $LocalnuspecFile
[xml]$nuspecFile = Get-Content $nuspecXML
$NuspecAuthors = $nuspecFile.package.metadata.authors
$NuspecBugTrackerURL = $nuspecFile.package.metadata.bugtrackerurl	
#$NuspecConflicts = $nuspecFile.package.metadata.conflicts # Built for the future
$NuspecCopyright = $nuspecFile.package.metadata.copyright
$NuspecDependencies = $nuspecFile.package.metadata.dependencies
$NuspecDescription = $nuspecFile.package.metadata.description
$NuspecDocsURL = $nuspecFile.package.metadata.docsurl
$NuspecFiles = $nuspecFile.package.files.file
$NuspecIconURL = $nuspecFile.package.metadata.iconurl
$NuspecID = $nuspecFile.package.metadata.id
$NuspecLicenseURL = $nuspecFile.package.metadata.licenseurl
$NuspecMailingListURL = $nuspecFile.package.metadata.mailinglisturl
$NuspecOwners = $nuspecFile.package.metadata.owners
$NuspecPackageSourceURL = $nuspecFile.package.metadata.packagesourceurl
$NuspecProjectSourceURL = $nuspecFile.package.metadata.projectsourceurl
$NuspecProjectURL = $nuspecFile.package.metadata.projecturl
#$NuspecProvides = $nuspecFile.package.metadata.provides # Built for the future
$NuspecReleaseNotes = $nuspecFile.package.metadata.releasenotes
#$NuspecReplaces = $nuspecFile.package.metadata.replaces # Built for the future
$NuspecRequireLicenseAcceptance = $nuspecFile.package.metadata.requirelicenseacceptance
$NuspecSummary = $nuspecFile.package.metadata.summary
$NuspecTags = $nuspecFile.package.metadata.tags
$NuspecTitle = $nuspecFile.package.metadata.title
$NuspecVersion = $nuspecFile.package.metadata.version
#$NuspecXMLComment = $nuspecFile.'#comment'
#$NuspecXMLNamespace = $nuspecFile.package.xmlns

$NuspecDisplayName=$LocalnuspecFile.Name
$NuspecDisplayName=$NuspecDisplayName.ToUpper()

if ($deprecate) {Write-Host "Deprecating $NuspecDisplayName`:" -Foreground Magenta}
if ($retire){Write-Host "Retiring $NuspecDisplayName`:" -Foreground Magenta}

# Update the nuspec with changes and save as UTF-8 w/o BOM # Thanks https://stackoverflow.com/questions/8160613/powershell-saving-xml-and-preserving-format
Function Update-nuspec{
      $UpdatednuspecFile = [xml]([System.IO.File]::ReadAllText($LocalnuspecFile))
      $UpdatednuspecFile.PreserveWhitespace = $true
      $settings = New-Object System.Xml.XmlWriterSettings
      $settings.Indent = $true
      $settings.NewLineChars ="`r`n"
      $settings.Encoding = New-Object System.Text.UTF8Encoding($false)   
#
# Don't change:
#$UpdatednuspecFile.package.metadata.authors
#$UpdatednuspecFile.package.metadata.id
#$UpdatednuspecFile.package.metadata.owners
#$UpdatednuspecFile.package.metadata.packagesourceurl
#$UpdatednuspecFile.package.metadata.projecturl

# Changes
if ($NuspecBugTrackerURL) {$UpdatednuspecFile.package.metadata.bugtrackerurl=''}
if ($NuspecCopyright) {$UpdatednuspecFile.package.metadata.copyright=''}
if ($NuspecDependencies){
    if ($deprecate){
        $UpdatednuspecFile.package.metadata.dependencies='Add your superceding package here.'
       }
    if ($retire){
        $UpdatednuspecFile.package.metadata.dependencies=''
      }
   } else {
     if ($deprecate){
         Write-Host "  ** You need to add a dependency pointing to the replacement package." -Foreground Red
         Write-Host "  ** If there is no replacement package, then retire this package instead of deprecating it." -Foreground Red
        }
   }
if ($deprecate){$UpdatednuspecFile.package.metadata.description='##This package has been deprecated. It has been replaced by the dependency shown below.'}
if ($retire){$UpdatednuspecFile.package.metadata.description='##This package has been retired.'}
if ($NuspecDocsURL){$UpdatednuspecFile.package.metadata.docsurl=''}
if ($NuspecIconURL){
    $UpdatednuspecFile.package.metadata.iconurl=''
    if ($deprecate -and $addicon){$UpdatednuspecFile.package.metadata.iconurl='https://raw.githubusercontent.com/bcurran3/ChocolateyPackages/master/mylogos/deprecated.png'}
    if ($retire -and $addicon){$UpdatednuspecFile.package.metadata.iconurl='https://raw.githubusercontent.com/bcurran3/ChocolateyPackages/master/mylogos/retired.png'}
	}
if ($NuspecLicenseURL) {$UpdatednuspecFile.package.metadata.licenseurl=''}
if ($NuspecMailingListURL) {$UpdatednuspecFile.package.metadata.mailinglisturl=''}
if ($NuspecProjectSourceURL) {$UpdatednuspecFile.package.metadata.projectsourceurl=''}
if ($NuspecReleaseNotes) {$UpdatednuspecFile.package.metadata.releasenotes=''}
if ($NuspecRequireLicenseAcceptance) {$UpdatednuspecFile.package.metadata.requirelicenseacceptance=''}
if ($NuspecSummary) {$UpdatednuspecFile.package.metadata.summary=''}
if ($NuspecTags){
     if ($deprecate){$UpdatednuspecFile.package.metadata.tags='deprecated'}
     if ($retire){$UpdatednuspecFile.package.metadata.tags='retired'}
    }
#TDL: Add checking so deprecated/retired doesn't get added twice
if ($deprecate){$UpdatednuspecFile.package.metadata.title='[DEPRECATED] ' + $NuspecTitle}
if ($retire){$UpdatednuspecFile.package.metadata.title='[RETIRED] ' + $NuspecTitle}
$UpdatednuspecFile.package.metadata.version='99.99.99.99'
#TDL: Need to handle <files> still                                        <<<<<<<<<<<<<---------------------------------------------------------------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#$UpdatednuspecFile.package.files.file
#
      $xfile = [System.Xml.XmlWriter]::Create($LocalnuspecFile, $settings)
      try{
        $UpdatednuspecFile.Save($xfile)
      } finally {
        $xfile.Dispose()
      }
}

if ($debug) {
Write-Host "  ** DEBUG: path=$path" -Foreground Cyan
Write-Host "  ** DEBUG: LocalnuspecFile=$LocalnuspecFile" -Foreground Cyan
Write-Host "  ** DEBUG: LocalnuspecFile.cdeprecate.bak=$LocalnuspecFile.cdeprecate.bak" -Foreground Cyan
Write-Host "  ** DEBUG: test-path result = $((Test-Path $path\$LocalnuspecFile.cdeprecate.bak))" -Foreground Cyan
}

if ($deprecate -or $retire) {
    if (Test-Path $path\$LocalnuspecFile.cdeprecate.bak) {Write-Host "  ** Please delete your current backup before continuing." -Foreground Red ; break} # <<<-- doesn't work for some reason
    Copy-Item "$LocalnuspecFile" "$LocalnuspecFile.cdeprecate.bak" -Force | Out-Null # ALWAYS make backup copy!
    Write-Host "  ** Backup saved to $LocalnuspecFile.cdeprecate.bak." -Foreground Green
    Update-nuspec
	if ($retire){
	    if (!(Test-Path "$path\tools")) {New-Item -Path $path -Name "tools" -ItemType "directory" | Out-Null}
	    Write-Output 'Write-Host ""  ** This package has been retired."" -Foreground Magenta' | Out-File "$path\tools\chocolateyInstall.ps1"
	    }
	Write-Host "  ** Done!" -Foreground Green
	} else {
	  Write-Host "  ** Nothing done. You must specify -Deprecate or -Retire." -Foreground Magenta
	}


Write-Host "`nFound cdeprecate.ps1 useful?" -Foreground White
Write-Host "Buy me a beer at https://www.paypal.me/bcurran3donations" -Foreground White
Write-Host "Become a patron at https://www.patreon.com/bcurran3" -Foreground White
if (!(Test-Path "$ENV:ChocolateyToolsLocation\BCURRAN3\CNC.ps1")) {Write-Host "You need CNC!" -Foreground Magenta }

#TDL
# check deprecated/retired title prefacing so it's not duplicated
# -addicon doesn't work if iconurl is originally blank
# create tags that don't exist; i.e. dependencies
# create files tag if it doesn't exisit
# add superceding package as a parameter to create the dependency
# find and kill get-object display at end of script (??????????????????????????)
# clean up pathing
tools\ChocolateyInstall.ps1
$ErrorActionPreference = 'Stop'
$packageName = 'choco-package-deprecater'
$toolsDir    = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$scriptDir   = "$(Get-ToolsLocation)\BCURRAN3"
$script      = 'cdeprecate.ps1'

# Setup
# New storage location moving forward for all my Chocolatey scripts
if (!(Test-Path "$ENV:ChocolateyToolsLocation\BCURRAN3")) { New-Item -Path "$ENV:ChocolateyToolsLocation" -Name "BCURRAN3" -ItemType "directory" | Out-Null }

# Install
# Move new files and support files (if applicable)
Move-Item "$toolsDir\$script" "$scriptDir" -Force
Install-ChocolateyPowershellCommand -PackageName 'cdeprecate' -PSFileFullPath "$scriptDir\$script"
if (!(Test-Path "$scriptDir\cdeprecate.config")) {Move-Item "$toolsDir\cdeprecate.config" "$scriptDir" -Force} else {Remove-Item "$toolsDir\cdeprecate.config" | Out-Null}

# Cleanup
if ($ENV:Path -NotMatch "BCURRAN3"){ Install-ChocolateyPath "$scriptDir" "Machine" ; refreshenv }
tools\ChocolateyUninstall.ps1
$ErrorActionPreference = 'Stop'
$packageName = 'choco-package-deprecater'
$scriptDir   = "$(Get-ToolsLocation)\BCURRAN3"

Remove-Item "$scriptDir\cdeprecate.*" -Force -ErrorAction SilentlyContinue | Out-Null
if (!(Get-ChildItem -Path "$ENV:ChocolateyToolsLocation\BCURRAN3" | Measure-Object | %{$_.Count})) {
   $ENV:Path.Replace("$ChocolateyToolsLocation\BCURRAN3","") | Out-Null
   Remove-Item "$ENV:ChocolateyToolsLocation\BCURRAN3" | Out-Null
   }

Log in or click on link to see number of positives.

In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).

Chocolatey Pro provides runtime protection from possible malware.

Version Downloads Last Updated Status

CHANGELOG:

  • 2019.09.03 - initial release. Does most of what's needed. Finishing touches and improvements to come. MIWMIP - "Make it work. Make it pretty."

This package has no dependencies.

Discussion for the (unofficial) Chocolatey Package Deprecater/Retirer (Script) Package

Ground Rules:

  • This discussion is only about (unofficial) Chocolatey Package Deprecater/Retirer (Script) and the (unofficial) Chocolatey Package Deprecater/Retirer (Script) package. If you have feedback for Chocolatey, please contact the Google Group.
  • This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
  • The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
  • Tell us what you love about the package or (unofficial) Chocolatey Package Deprecater/Retirer (Script), or tell us what needs improvement.
  • Share your experiences with the package, or extra configuration or gotchas that you've found.
  • If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.
comments powered by Disqus