From 967b1df67237f8d5e0f7df2f5a0fff520dcb0de6 Mon Sep 17 00:00:00 2001 From: Jack McKernan Date: Sun, 25 Jul 2021 21:02:27 -0500 Subject: [PATCH] Release gstreamer 1.18.4.20210725 This includes a modified version of the Uninstall-ChocolateyPath script from chocolatey/choco#1663 --- common.sh | 9 +- gstreamer/gstreamer-devel.nuspec | 4 +- gstreamer/gstreamer-mingw-devel.nuspec | 4 +- gstreamer/gstreamer-mingw.nuspec | 2 +- gstreamer/gstreamer.nuspec | 2 +- gstreamer/tools/EnvPathFunctions-GH1663.ps1 | 63 ++++++++++++ .../tools/Install-ChocolateyPath-GH1663.ps1 | 95 ++++++++++++++++++ .../tools/Uninstall-ChocolateyPath-GH1663.ps1 | 97 +++++++++++++++++++ gstreamer/tools/chocolateyBeforeModify.ps1 | 38 ++++++++ gstreamer/tools/chocolateyInstall.ps1 | 27 +++++- gstreamer/tools/chocolateyUninstall.ps1 | 7 -- gstreamer/update.sh | 5 +- 12 files changed, 333 insertions(+), 20 deletions(-) create mode 100644 gstreamer/tools/EnvPathFunctions-GH1663.ps1 create mode 100644 gstreamer/tools/Install-ChocolateyPath-GH1663.ps1 create mode 100644 gstreamer/tools/Uninstall-ChocolateyPath-GH1663.ps1 create mode 100644 gstreamer/tools/chocolateyBeforeModify.ps1 delete mode 100644 gstreamer/tools/chocolateyUninstall.ps1 diff --git a/common.sh b/common.sh index ef2870f..8c1bc88 100644 --- a/common.sh +++ b/common.sh @@ -3,7 +3,8 @@ 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" @@ -11,12 +12,15 @@ function bump-nuspec-version() { fi current_version=$(sed -nr 's|(.+)|\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 @@ -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" } diff --git a/gstreamer/gstreamer-devel.nuspec b/gstreamer/gstreamer-devel.nuspec index 675f8f9..a3b97f2 100644 --- a/gstreamer/gstreamer-devel.nuspec +++ b/gstreamer/gstreamer-devel.nuspec @@ -3,7 +3,7 @@ gstreamer-devel GStreamer (Development) - 1.18.4 + 1.18.4.20210725 GStreamer Team John McKernan (jmcker) https://github.com/jmcker/ChocolateyPackages/tree/main/gstreamer @@ -31,7 +31,7 @@ This package performs a "Complete" install and may contain restricted codecs or - + diff --git a/gstreamer/gstreamer-mingw-devel.nuspec b/gstreamer/gstreamer-mingw-devel.nuspec index 0269de1..50a5696 100644 --- a/gstreamer/gstreamer-mingw-devel.nuspec +++ b/gstreamer/gstreamer-mingw-devel.nuspec @@ -3,7 +3,7 @@ gstreamer-mingw-devel GStreamer MinGW (Development) - 1.18.4 + 1.18.4.20210725 GStreamer Team John McKernan (jmcker) https://github.com/jmcker/ChocolateyPackages/tree/main/gstreamer @@ -31,7 +31,7 @@ This package performs a "Complete" install and may contain restricted codecs or - + diff --git a/gstreamer/gstreamer-mingw.nuspec b/gstreamer/gstreamer-mingw.nuspec index 139ae34..18eba6d 100644 --- a/gstreamer/gstreamer-mingw.nuspec +++ b/gstreamer/gstreamer-mingw.nuspec @@ -3,7 +3,7 @@ gstreamer-mingw GStreamer MinGW - 1.18.4 + 1.18.4.20210725 GStreamer Team John McKernan (jmcker) https://github.com/jmcker/ChocolateyPackages/tree/main/gstreamer diff --git a/gstreamer/gstreamer.nuspec b/gstreamer/gstreamer.nuspec index 35101bf..3eed1ab 100644 --- a/gstreamer/gstreamer.nuspec +++ b/gstreamer/gstreamer.nuspec @@ -3,7 +3,7 @@ gstreamer GStreamer - 1.18.4 + 1.18.4.20210725 GStreamer Team John McKernan (jmcker) https://github.com/jmcker/ChocolateyPackages/tree/main/gstreamer diff --git a/gstreamer/tools/EnvPathFunctions-GH1663.ps1 b/gstreamer/tools/EnvPathFunctions-GH1663.ps1 new file mode 100644 index 0000000..f12b478 --- /dev/null +++ b/gstreamer/tools/EnvPathFunctions-GH1663.ps1 @@ -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) + }) +} diff --git a/gstreamer/tools/Install-ChocolateyPath-GH1663.ps1 b/gstreamer/tools/Install-ChocolateyPath-GH1663.ps1 new file mode 100644 index 0000000..022be33 --- /dev/null +++ b/gstreamer/tools/Install-ChocolateyPath-GH1663.ps1 @@ -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 + } +} diff --git a/gstreamer/tools/Uninstall-ChocolateyPath-GH1663.ps1 b/gstreamer/tools/Uninstall-ChocolateyPath-GH1663.ps1 new file mode 100644 index 0000000..88845fe --- /dev/null +++ b/gstreamer/tools/Uninstall-ChocolateyPath-GH1663.ps1 @@ -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 + } +} diff --git a/gstreamer/tools/chocolateyBeforeModify.ps1 b/gstreamer/tools/chocolateyBeforeModify.ps1 new file mode 100644 index 0000000..82aa7f9 --- /dev/null +++ b/gstreamer/tools/chocolateyBeforeModify.ps1 @@ -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" +} diff --git a/gstreamer/tools/chocolateyInstall.ps1 b/gstreamer/tools/chocolateyInstall.ps1 index ba3a6f6..4f5c913 100644 --- a/gstreamer/tools/chocolateyInstall.ps1 +++ b/gstreamer/tools/chocolateyInstall.ps1 @@ -42,11 +42,32 @@ $packageArgs = @{ Install-ChocolateyPackage @packageArgs +if (${ENV:OS_IS64BIT} -And -Not ${ENV:ChocolateyForceX86}) { + $locationVarName = "GSTREAMER_1_0_ROOT_$(${toolchain}.ToUpper())_X86_64" +} else { + $locationVarName = "GSTREAMER_1_0_ROOT_$(${toolchain}.ToUpper())_X86" +} + +$installLocation = (Get-EnvironmentVariable -Name "${locationVarName}" -Scope "User") +Write-Output "" +Write-Output "GStreamer installed to ${installLocation}" Write-Output "" +Write-Output "Checking for PATH entry..." + +$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" +$modulePath = Join-Path "${toolsDir}" 'Install-ChocolateyPath-GH1663.ps1' +Import-Module "${modulePath}" + # Must install to User path since we need to expand a User environment variable -if (${ENV:OS_IS64BIT} -And -Not ${ENV:ChocolateyForceX86}) { - Install-ChocolateyPath -PathToInstall "%GSTREAMER_1_0_ROOT_$(${toolchain}.ToUpper())_X86_64%\bin" -PathType "User" +Install-ChocolateyPath-GH1663 -PathToInstall "%${locationVarName}%\bin" -PathType "User" +Update-SessionEnvironment + +$locationOnPath = (Get-Command gst-launch-1.0.exe -errorAction SilentlyContinue) +if ($locationOnPath) { + Write-Output "Confirmed gst-launch-1.0.exe on PATH at $(${locationOnPath}.source)" } else { - Install-ChocolateyPath -PathToInstall "%GSTREAMER_1_0_ROOT_$(${toolchain}.ToUpper())_X86%\bin" -PathType "User" + Write-Error 'GStreamer gst-launch-1.0.exe could not be found on PATH after install!' } + +Write-Output "" diff --git a/gstreamer/tools/chocolateyUninstall.ps1 b/gstreamer/tools/chocolateyUninstall.ps1 deleted file mode 100644 index fa23376..0000000 --- a/gstreamer/tools/chocolateyUninstall.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -$ErrorActionPreference = 'Stop'; - -# Let the auto-uninstaller take care of things - -# Don't mess with PATH for now since there is currently no easy way to remove -# our entry without possibly mangling everything -# https://github.com/chocolatey/choco/issues/310 diff --git a/gstreamer/update.sh b/gstreamer/update.sh index c94b2f4..42b9ee8 100755 --- a/gstreamer/update.sh +++ b/gstreamer/update.sh @@ -20,6 +20,7 @@ fi old_dir="${PWD}" package="gstreamer" new_version="${1}" +new_version_without_date="${new_version%.$(date +%Y)*}" # Ex: 1.1.1.20210725 -> 1.1.1 packages=("gstreamer" "gstreamer-devel" "gstreamer-mingw" "gstreamer-mingw-devel") @@ -40,8 +41,8 @@ for package in ${packages[@]}; do [ "${first}" == "devel" ] && devel="devel-" [ "${second}" == "devel" ] && devel="devel-" - download_url=$(version="${new_version}" eval "echo ${download_url}") - download_url_64=$(version="${new_version}" eval "echo ${download_url_64}") + download_url=$(version="${new_version_without_date}" eval "echo ${download_url}") + download_url_64=$(version="${new_version_without_date}" eval "echo ${download_url_64}") echo "x86 Download URL: ${download_url}" echo "x64 Download URL: ${download_url_64}"