Downloads:
1,890
Downloads of v 2022.03.15:
887
Last Update:
16 Mar 2022
Package Maintainer(s):
Software Author(s):
- Bill Curran
Tags:
bcurran3 cdeprecate choco unofficial package deprecate retire script chocolateasy(unofficial) Chocolatey Package Deprecater/Retirer (Script)
- 1
- 2
- 3
2022.03.15 | Updated: 16 Mar 2022
Downloads:
1,890
Downloads of v 2022.03.15:
887
Maintainer(s):
Software Author(s):
- Bill Curran
(unofficial) Chocolatey Package Deprecater/Retirer (Script) 2022.03.15
Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by Bill Curran. The inclusion of Bill Curran trademark(s), if any, upon this webpage is solely to identify Bill Curran goods or services and not for commercial purposes.
- 1
- 2
- 3
All Checks are Passing
3 Passing Tests
Deployment Method: Individual Install, Upgrade, & Uninstall
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:
Deployment Method:
This applies to both open source and commercial editions of Chocolatey.
1. Enter Your Internal Repository Url
(this should look similar to https://community.chocolatey.org/api/v2/)
2. Setup Your Environment
1. Ensure you are set for organizational deployment
Please see the organizational deployment guide
2. Get the package into your environment
Option 1: Cached Package (Unreliable, Requires Internet - Same As Community)-
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://community.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
-
Open Source
-
Download the package:
Download - Follow manual internalization instructions
-
-
Package Internalizer (C4B)
-
Run: (additional options)
choco download choco-package-deprecater --internalize --source=https://community.chocolatey.org/api/v2/
-
For package and dependencies run:
choco push --source="'INTERNAL REPO URL'"
- Automate package internalization
-
Run: (additional options)
3. Copy Your Script
choco upgrade choco-package-deprecater -y --source="'INTERNAL REPO 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="'INTERNAL REPO URL'"
$exitCode = $LASTEXITCODE
Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
- name: Install choco-package-deprecater
win_chocolatey:
name: choco-package-deprecater
version: '2022.03.15'
source: INTERNAL REPO URL
state: present
See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.
chocolatey_package 'choco-package-deprecater' do
action :install
source 'INTERNAL REPO URL'
version '2022.03.15'
end
See docs at https://docs.chef.io/resource_chocolatey_package.html.
cChocoPackageInstaller choco-package-deprecater
{
Name = "choco-package-deprecater"
Version = "2022.03.15"
Source = "INTERNAL REPO URL"
}
Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.
package { 'choco-package-deprecater':
ensure => '2022.03.15',
provider => 'chocolatey',
source => 'INTERNAL REPO URL',
}
Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.
4. If applicable - Chocolatey configuration/installation
See infrastructure management matrix for Chocolatey configuration elements and examples.
This package was approved by moderator virtualex on 16 Mar 2022.
choco://choco-package-deprecater
To use choco:// protocol URLs, install (unofficial) choco:// Protocol support
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 finding and re-reading the Chocolatey docs.
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
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
<?xml version="1.0"?>
<Settings>
<Preferences>
<DeprecatedDescription>## This package has been deprecated. It has been replaced by the dependency shown below.</DeprecatedDescription>
<DeprecatedIconUrl>https://cdn.staticaly.com/gh/bcurran3/ChocolateyPackages/master/mylogos/deprecated.png</DeprecatedIconUrl>
<RetiredDescription>## This package has been retired.</RetiredDescription>
<RetiredIconUrl>https://cdn.staticaly.com/gh/bcurran3/ChocolateyPackages/master/mylogos/retired.png</RetiredIconUrl>
</Preferences>
</Settings>
<!--
choco-package-deprecater.config preferences notes:
DeprecatedDescription - Custom nuspec description for deprecattion.
DeprecatedIconUrl - Custom URL to image to use for deprecattion.
RetiredDescription - Custom nuspec description for retirement.
RetiredIconUrl - Custom URL to image to use for retirement.
-->
param ([string]$Path=(Get-Location).path)
$ErrorActionPreference = 'Stop'
# cdeprecate.ps1 Copyleft 2019-2022 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
Write-Host "cdeprecate.ps1 v2022.03.15 - (unofficial) Chocolatey Package Deprecater/Retirer" -Foreground White
Write-Host "Copyleft 2019-2022 Bill Curran ([email protected]) - free for personal and commercial use`n" -Foreground White
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
$scriptDir = "$env:ChocolateyToolsLocation\BCURRAN3"
$ScriptConfig = 'cdeprecate.config'
# Verify ChocolateyToolsLocation was created by Get-ToolsLocation during install and is in the environment
If (!($env:ChocolateyToolsLocation)) {$env:ChocolateyToolsLocation = "$env:SystemDrive\tools"}
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 "-AddDependency"
Write-Host " Not implemented yet."
Write-Host "-AddIcon"
Write-Host " Add a fun icon instead of boring 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
}
# Setup conditions
if ($args -eq "-Deprecate") {$Deprecate=$True} else {$Deprecate=$False}
if ($args -eq "-Retire") {$Retire=$True} else {$Retire=$False}
if ($args -eq "-AddDependency") {$AddDependency=$True} else {$AddDependency=$False}
if ($args -eq "-AddIcon") {$AddIcon=$True} else {$AddIcon=$False}
if ($args -eq "-Debug") {$Debug=$True} else {$Debug=$False}
If (Test-Path $env:ChocolateyInstall\bin\notepad++.exe){$Editor="notepad++.exe" } else {$Editor="notepad.exe"}
If ($args -eq "-EditConfig") {
Write-Host " ** Editing contents of $ScriptConfig." -Foreground Magenta
&$Editor "$scriptDir\$ScriptConfig"
return
}
if ($args -eq "-OpenDeprecateDocs") {&start https://docs.chocolatey.org/en-us/community-repository/maintainers/deprecate-a-chocolatey-package ; return }
# Set default preferences incase of corrupt or missing cdeprecate.config
$DeprecatedDescription = '## This package has been deprecated. It has been replaced by the dependency shown below.'
$DeprecatedIconUrl = 'https://cdn.staticaly.com/gh/bcurran3/ChocolateyPackages/master/mylogos/deprecated.png'
$RetiredDescription = '## This package has been retired.'
$RetiredIconUrl = 'https://cdn.staticaly.com/gh/bcurran3/ChocolateyPackages/master/mylogos/retired.png'
# Import preferences - see comments in cdeprecate.config for settings
If (Test-Path "$scriptDir\$ScriptConfig") {
[xml]$ConfigFile = Get-Content "$scriptDir\$ScriptConfig"
$DeprecatedDescription = $ConfigFile.Settings.Preferences.DeprecatedDescription
$DeprecatedIconUrl = $ConfigFile.Settings.Preferences.DeprecatedIconUrl
$RetiredDescription = $ConfigFile.Settings.Preferences.RetiredDescription
$RetiredIconUrl = $ConfigFile.Settings.Preferences.RetiredIconUrl
} else {
Write-Warning " ** $ScriptConfig not found, using defaults."
}
# 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 -eq "\"){$path=(Get-Location).Drive.Name + ":" + "\"}
if (!(Test-Path $path)){Write-Host " ** $path is an invalid path." -Foreground Red; return}
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 delete 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 ($debug){
Write-Host "Path equals $path"
Write-Host "LocalnuspecFile equals $LocalnuspecFile"
Write-Host "nuspecXML equals $nuspecXML"
Write-Host "NuspecTitle equals $NuspecTitle"
Write-Host "nuspecFile.package.metadata.requireLicenseAcceptance equals $nuspecFile.package.metadata.requireLicenseAcceptance"
Write-Host "NuspecRequireLicenseAcceptance equals $NuspecRequireLicenseAcceptance"
}
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=$DeprecatedDescription}
if ($retire){$UpdatednuspecFile.package.metadata.description=$RetiredDescription}
if ($NuspecDocsURL){$UpdatednuspecFile.package.metadata.docsurl=''}
if ($NuspecIconURL){$UpdatednuspecFile.package.metadata.iconurl=''}
if ($deprecate -and $addicon){$UpdatednuspecFile.package.metadata.iconurl=$DeprecatedIconUrl}
if ($retire -and $addicon){$UpdatednuspecFile.package.metadata.iconurl=$RetiredIconUrl}
if ($NuspecLicenseURL) {$UpdatednuspecFile.package.metadata.licenseurl=''}
if ($NuspecRequireLicenseAcceptance) {$UpdatednuspecFile.package.metadata.requireLicenseAcceptance='false'}
if ($NuspecMailingListURL) {$UpdatednuspecFile.package.metadata.mailinglisturl=''}
if ($NuspecProjectSourceURL) {$UpdatednuspecFile.package.metadata.projectsourceurl=''}
if ($NuspecReleaseNotes) {$UpdatednuspecFile.package.metadata.releasenotes=''}
if ($NuspecSummary) {$UpdatednuspecFile.package.metadata.summary=''}
if ($NuspecTags){
if ($deprecate){$UpdatednuspecFile.package.metadata.tags='deprecated'}
if ($retire){$UpdatednuspecFile.package.metadata.tags='retired'}
}
if ($NuspecTitle -notmatch "deprecated" -and $deprecate){$UpdatednuspecFile.package.metadata.title='[DEPRECATED] ' + $NuspecTitle}
if ($NuspecTitle -notmatch "retire" -and $retire){$UpdatednuspecFile.package.metadata.title='[RETIRED] ' + $NuspecTitle}
$UpdatednuspecFile.package.metadata.version='99.99.99.99'
#TDL: Need to handle <files> still <<<<<<<<<<<<<---------------------------------------------------------------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#TDL: Need to handle <dependencies> still <<<<<<<<<<<<<---------------------------------------------------------------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$xfile = [System.Xml.XmlWriter]::Create($LocalnuspecFile, $settings)
try{
$UpdatednuspecFile.Save($xfile)
} finally {
$xfile.Dispose()
}
}
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! Get it at https://community.chocolatey.org/packages/choco-nuspec-checker" -Foreground Magenta }
#TDL
# create xml tags that don't exist; i.e. dependencies and files
# add superceding package as a parameter to create the dependency
# clean up pathing
$ErrorActionPreference = 'Stop'
$packageName = 'choco-package-deprecater'
$scriptDir = "$(Get-ToolsLocation)\BCURRAN3"
Remove-Item "$ENV:ChocolateyInstall\bin\cdeprecate.bat" -Force | Out-Null
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.
Add to Builder | Version | Downloads | Last Updated | Status |
---|---|---|---|---|
(unofficial) Chocolatey Package Deprecater/Retirer (Script) 2022.03.15 | 887 | Wednesday, March 16, 2022 | Approved | |
(unofficial) Chocolatey Package Deprecater/Retirer (Script) 2019.09.03 | 1003 | Tuesday, September 3, 2019 | Approved |
Copyleft Bill Curran
CHANGELOG:
- 2022.03.15 - Updated messages with markdown that are incompatible with the Sept. 2019 changes to chocolatey.org, set requireLicenseAcceptance to false to avoid schema error (new behavior?), -addicon will now work if iconUrl was originally blank; changed iconUrl to use CDN URLs, now won't add [DEPRECATED] or [RETIRED] if you run cdeprecate a 2nd time, implemented a config file and defaults, now removes "shim" when uninstalled, updated Chocolatey's DEPRECATE A PACKAGE URL
- 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.
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.