Skip to content

Commit

Permalink
Release gstreamer 1.18.4.20210725
Browse files Browse the repository at this point in the history
This includes a modified version of the Uninstall-ChocolateyPath script from chocolatey/choco#1663
  • Loading branch information
jmcker committed Jul 26, 2021
1 parent 3a56f84 commit 967b1df
Show file tree
Hide file tree
Showing 12 changed files with 333 additions and 20 deletions.
9 changes: 7 additions & 2 deletions common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
function bump-nuspec-version() {
package="${1}"
new_version="${2}"
new_maj_min="${new_version%.*}"
new_version_without_year="${new_version%.$(date +%Y)*}"
new_maj_min="${new_version_without_year%.*}"

if [ -z "${package}" ] || [ -z "${new_version}" ]; then
echo "Usage: ${FUNCNAME[0]} PACKAGE_NAME VERSION"
return 1
fi

current_version=$(sed -nr 's|<version>(.+)</version>|\1|p' "${package}.nuspec" | xargs)
current_version_without_year="${current_version%.$(date +%Y)*}"
current_maj_min="${current_version%.*}"

echo "Current version: ${current_version}"
echo "Current package version: ${current_version}"
echo "Current version: ${current_version_without_year}"
echo "Major minor: ${current_maj_min}"
echo
echo "New version: ${new_version}"
echo "New version: ${new_version_without_year}"
echo "Major minor: ${new_maj_min}"
echo

Expand All @@ -32,6 +36,7 @@ function bump-nuspec-version() {
# Replace the full version
# Replace the major.minor version
sed -r -i "s|${current_version}|${new_version}|g" "${package}.nuspec"
sed -r -i "s|${current_version_without_year}|${new_version_without_year}|g" "${package}.nuspec"
sed -r -i "s|${current_maj_min}|${new_maj_min}|g" "${package}.nuspec"
}

Expand Down
4 changes: 2 additions & 2 deletions gstreamer/gstreamer-devel.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>gstreamer-devel</id>
<title>GStreamer (Development)</title>
<version>1.18.4</version>
<version>1.18.4.20210725</version>
<authors>GStreamer Team</authors>
<owners>John McKernan (jmcker)</owners>
<packageSourceUrl>https://github.com/jmcker/ChocolateyPackages/tree/main/gstreamer</packageSourceUrl>
Expand Down Expand Up @@ -31,7 +31,7 @@ This package performs a "Complete" install and may contain restricted codecs or
</description>

<dependencies>
<dependency id="gstreamer" version="1.18.4" />
<dependency id="gstreamer" version="1.18.4.20210725" />
</dependencies>

</metadata>
Expand Down
4 changes: 2 additions & 2 deletions gstreamer/gstreamer-mingw-devel.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>gstreamer-mingw-devel</id>
<title>GStreamer MinGW (Development)</title>
<version>1.18.4</version>
<version>1.18.4.20210725</version>
<authors>GStreamer Team</authors>
<owners>John McKernan (jmcker)</owners>
<packageSourceUrl>https://github.com/jmcker/ChocolateyPackages/tree/main/gstreamer</packageSourceUrl>
Expand Down Expand Up @@ -31,7 +31,7 @@ This package performs a "Complete" install and may contain restricted codecs or
</description>

<dependencies>
<dependency id="gstreamer-mingw" version="1.18.4" />
<dependency id="gstreamer-mingw" version="1.18.4.20210725" />
</dependencies>

</metadata>
Expand Down
2 changes: 1 addition & 1 deletion gstreamer/gstreamer-mingw.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>gstreamer-mingw</id>
<title>GStreamer MinGW</title>
<version>1.18.4</version>
<version>1.18.4.20210725</version>
<authors>GStreamer Team</authors>
<owners>John McKernan (jmcker)</owners>
<packageSourceUrl>https://github.com/jmcker/ChocolateyPackages/tree/main/gstreamer</packageSourceUrl>
Expand Down
2 changes: 1 addition & 1 deletion gstreamer/gstreamer.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>gstreamer</id>
<title>GStreamer</title>
<version>1.18.4</version>
<version>1.18.4.20210725</version>
<authors>GStreamer Team</authors>
<owners>John McKernan (jmcker)</owners>
<packageSourceUrl>https://github.com/jmcker/ChocolateyPackages/tree/main/gstreamer</packageSourceUrl>
Expand Down
63 changes: 63 additions & 0 deletions gstreamer/tools/EnvPathFunctions-GH1663.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright © 2018 Chocolatey Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# https://github.com/chocolatey/choco/pull/1663
# https://github.com/chocolatey/choco/blob/b89e64e9fd599c3244290d62096e0e7ab0c91742/src/chocolatey.resources/helpers/functions/EnvPathFunctions.ps1

# For internal use by Install-ChocolateyPath and Uninstall-ChocolateyPath.

function Parse-EnvPathList([string] $rawPathVariableValue) {
# Using regex (for performance) which correctly splits at each semicolon unless the semicolon is inside double quotes.
# Unlike semicolons, quotes are not allowed inside paths so there is thankfully no need to unescape them.
# (Verified using Windows 10’s environment variable editor.)
# Blank path entries are preserved, such as those caused by a trailing semicolon.
# This enables reserializing without gratuitous reformatting.
$paths = $rawPathVariableValue -split '(?<=\G(?:[^;"]|"[^"]*")*);'

# Remove quotes from each path if they are present
for ($i = 0; $i -lt $paths.Length; $i++) {
$path = $paths[$i]
if ($path.Length -ge 2 -and $path.StartsWith('"', [StringComparison]::Ordinal) -and $path.EndsWith('"', [StringComparison]::Ordinal)) {
$paths[$i] = $path.Substring(1, $path.Length - 2)
}
}

return $paths
}

function Format-EnvPathList([string[]] $paths) {
# Don’t mutate the original (externally visible if the argument is not type-coerced),
# but don’t clone if mutation is unnecessary.
$createdDefensiveCopy = $false

# Add quotes to each path if necessary
for ($i = 0; $i -lt $paths.Length; $i++) {
$path = $paths[$i]
if ($path -ne $null -and $path.Contains(';')) {
if (-not $createdDefensiveCopy) {
$createdDefensiveCopy = $true
$paths = $paths.Clone()
}
$paths[$i] = '"' + $path + '"'
}
}

return $paths -join ';'
}

function IndexOf-EnvPath([System.Collections.Generic.List[string]] $list, [string] $value) {
$list.FindIndex({
$value.Equals($args[0], [StringComparison]::OrdinalIgnoreCase)
})
}
95 changes: 95 additions & 0 deletions gstreamer/tools/Install-ChocolateyPath-GH1663.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright © 2017 Chocolatey Software, Inc.
# Copyright © 2015 - 2017 RealDimensions Software, LLC
# Copyright © 2011 - 2015 RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$modulePath = Join-Path "${toolsDir}" 'EnvPathFunctions-GH1663.ps1'
Import-Module "${modulePath}"

# https://github.com/chocolatey/choco/pull/1663
# https://github.com/chocolatey/choco/blob/b89e64e9fd599c3244290d62096e0e7ab0c91742/src/chocolatey.resources/helpers/functions/Install-ChocolateyPath.ps1

function Install-ChocolateyPath-GH1663 {
<#
.SYNOPSIS
**NOTE:** Administrative Access Required when `-PathType 'Machine'.`
This puts a directory to the PATH environment variable.
.DESCRIPTION
Ensures that the given path is present in the given type of PATH
environment variable as well as in the current session.
.NOTES
This command will assert UAC/Admin privileges on the machine if
`-PathType 'Machine'`.
This is used when the application/tool is not being linked by Chocolatey
(not in the lib folder).
.INPUTS
None
.OUTPUTS
None
.PARAMETER PathToInstall
The exact path to ensure in the environment PATH.
.PARAMETER PathType
Which PATH to add it to. If specifying `Machine`, this requires admin
privileges to run correctly.
.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply. Do not use directly.
.EXAMPLE
Install-ChocolateyPath -PathToInstall "$($env:SystemDrive)\tools\gittfs"
.EXAMPLE
Install-ChocolateyPath "$($env:SystemDrive)\Program Files\MySQL\MySQL Server 5.5\bin" -PathType 'Machine'
.LINK
Uninstall-ChocolateyPath
.LINK
Install-ChocolateyEnvironmentVariable
.LINK
Get-EnvironmentVariable
.LINK
Set-EnvironmentVariable
.LINK
Get-ToolsLocation
#>
param(
[parameter(Mandatory=$true, Position=0)][string] $pathToInstall,
[parameter(Mandatory=$false, Position=1)][System.EnvironmentVariableTarget] $pathType = [System.EnvironmentVariableTarget]::User,
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)

Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters
## Called from chocolateysetup.psm1 - wrap any Write-Host in try/catch

$paths = Parse-EnvPathList (Get-EnvironmentVariable -Name 'PATH' -Scope $pathType -PreserveVariables)
if ((IndexOf-EnvPath $paths $pathToInstall) -eq -1) {
try {
Write-Host "PATH environment variable does not have $pathToInstall in it. Adding..."
} catch {
Write-Verbose "PATH environment variable does not have $pathToInstall in it. Adding..."
}

if ($pathType -eq [EnvironmentVariableTarget]::Machine -and -not (Test-ProcessAdminRights)) {
$psArgs = "Install-ChocolateyPath -pathToInstall `'$pathToInstall`' -pathType `'$pathType`'"
Start-ChocolateyProcessAsAdmin "$psArgs"
} else {
$paths += $pathToInstall
Set-EnvironmentVariable -Name 'PATH' -Value $(Format-EnvPathList $paths) -Scope $pathType
}
}

# Make change immediately available
$paths = Parse-EnvPathList $env:PATH
if ((IndexOf-EnvPath $paths $pathToInstall) -eq -1) {
$paths += $pathToInstall
$env:Path = Format-EnvPathList $paths
}
}
97 changes: 97 additions & 0 deletions gstreamer/tools/Uninstall-ChocolateyPath-GH1663.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Copyright © 2018 Chocolatey Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$modulePath = Join-Path "${toolsDir}" 'EnvPathFunctions-GH1663.ps1'
Import-Module "${modulePath}"

# https://github.com/chocolatey/choco/pull/1663
# https://github.com/chocolatey/choco/blob/b89e64e9fd599c3244290d62096e0e7ab0c91742/src/chocolatey.resources/helpers/functions/Uninstall-ChocolateyPath.ps1

function Uninstall-ChocolateyPath-GH1663 {
<#
.SYNOPSIS
**NOTE:** Administrative Access Required when `-PathType 'Machine'.`
This puts a directory to the PATH environment variable.
.DESCRIPTION
Ensures that the given path is not present in the given type of PATH
environment variable as well as in the current session.
.NOTES
This command will assert UAC/Admin privileges on the machine if
`-PathType 'Machine'`.
This is used when the application/tool is not being linked by Chocolatey
(not in the lib folder).
.PARAMETER PathToUninstall
The exact path to remove from the environment PATH.
.PARAMETER PathType
Which PATH to add it to. If specifying `Machine`, this requires admin
privileges to run correctly.
.PARAMETER IgnoredArguments
Allows splatting with arguments that do not apply. Do not use directly.
.EXAMPLE
Uninstall-ChocolateyPath -PathToUninstall "$($env:SystemDrive)\tools\gittfs"
.EXAMPLE
Uninstall-ChocolateyPath "$($env:SystemDrive)\Program Files\MySQL\MySQL Server 5.5\bin" -PathType 'Machine'
.LINK
Install-ChocolateyPath
.LINK
Get-EnvironmentVariable
.LINK
Set-EnvironmentVariable
.LINK
Get-ToolsLocation
#>
param(
[parameter(Mandatory=$true, Position=0)][string] $pathToUninstall,
[parameter(Mandatory=$false, Position=1)][System.EnvironmentVariableTarget] $pathType = [System.EnvironmentVariableTarget]::User,
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)

Write-FunctionCallLogMessage -Invocation $MyInvocation -Parameters $PSBoundParameters

$paths = Parse-EnvPathList (Get-EnvironmentVariable -Name 'PATH' -Scope $pathType -PreserveVariables)
$removeIndex = (IndexOf-EnvPath $paths $pathToUninstall)
if ($removeIndex -ge 0) {
Write-Host "Found $pathToUninstall in PATH environment variable. Removing..."

if ($pathType -eq [EnvironmentVariableTarget]::Machine -and -not (Test-ProcessAdminRights)) {
Write-Error "Failed: This requires administrator rights."
} else {
$paths = [System.Collections.ArrayList] $paths
$paths.RemoveAt($removeIndex)
Set-EnvironmentVariable -Name 'PATH' -Value $(Format-EnvPathList $paths) -Scope $pathType
}
}

# Make change immediately available
$paths = Parse-EnvPathList $env:PATH
if ($removeIndex -ge 0) {
$paths = [System.Collections.ArrayList] $paths
$paths.RemoveAt($removeIndex)
$env:Path = Format-EnvPathList $paths
}
}
38 changes: 38 additions & 0 deletions gstreamer/tools/chocolateyBeforeModify.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$ErrorActionPreference = 'Stop';

$packageName = "${ENV:ChocolateyPackageName}"
$nameSplit = ${packageName}.Split('-')
$toolchain = "msvc"

if (${packageName}.Contains("devel")) {
Write-Output "No PATH changes required for devel package. Exiting..."
Exit
}

# gstreamer, gstreamer-devel, gstreamer-mingw, or gstreamer-mingw-devel
if (${nameSplit}.Length -gt 1 -and ${nameSplit}[1] -ne "devel") {
$toolchain = ${nameSplit}[1]
}

# ENV:ChocolateyForceX86 appears to never be set for uninstall
# No --x86 flag exists on the command
if (${ENV:OS_IS64BIT} -And -Not ${ENV:ChocolateyForceX86}) {
$pathForUninstall = "%GSTREAMER_1_0_ROOT_$(${toolchain}.ToUpper())_X86_64%\bin"
} else {
$pathForUninstall = "%GSTREAMER_1_0_ROOT_$(${toolchain}.ToUpper())_X86%\bin"
}

if (-not (Get-Command 'Uninstall-ChocolateyPath' -errorAction SilentlyContinue)) {
Write-Output "Using Uninstall-ChocolateyPath-GH1663 function";

$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$modulePath = Join-Path "${toolsDir}" 'Uninstall-ChocolateyPath-GH1663.ps1'
Import-Module "${modulePath}"

Uninstall-ChocolateyPath-GH1663 "${pathForUninstall}" "User"
}
else {
Write-Debug "Using native Uninstall-ChocolateyPath function";

Uninstall-ChocolateyPath "${pathForUninstall}" "User"
}
Loading

0 comments on commit 967b1df

Please sign in to comment.