From 0bb42730e8fc9c8e571f12e3189c6c6f8d532c24 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sat, 10 Feb 2024 17:34:25 +0000 Subject: gentoo auto-resync : 10:02:2024 - 17:34:25 --- eclass/nuget.eclass | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'eclass/nuget.eclass') diff --git a/eclass/nuget.eclass b/eclass/nuget.eclass index 669e21300ef2..ac8629848eca 100644 --- a/eclass/nuget.eclass +++ b/eclass/nuget.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2023 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: nuget.eclass @@ -226,6 +226,51 @@ nuget_unpack-non-nuget-archives() { done } +# @FUNCTION: nuget_writeconfig +# @USAGE: +# @DESCRIPTION: +# Create a "NuGet.config" config file that can be used to overwrite any other +# Nuget configuration file in order to prevent Nuget executable from accessing +# the network or undesired NuPkg package sources. +# +# If given path ends with a slash, a file name "NuGet.config" is assumed, +# otherwise contents are written to specified file path exactly. +# +# Created configuration file clears all other NuPkg sources and inserts +# "NUGET_PACKAGES" as the only one source. +# +# This function is used inside "dotnet-pkg_src_prepare" +# from the "dotnet-pkg" eclass. +# +# This function is used inside "dotnet-pkg_src_prepare" +# from the "dotnet-pkg" eclass. +nuget_writeconfig() { + debug-print-function "${FUNCNAME[0]}" "${@}" + + case "${1}" in + "" ) die "${FUNCNAME[0]}: no directory/file path specified" ;; + */ ) mkdir -p "${1}" || die ;; + esac + + local nuget_config_path + + if [[ -d "${1}" ]] ; then + nuget_config_path="${1}/NuGet.config" + else + nuget_config_path="${1}" + fi + + cat <<-EOF > "${nuget_config_path}" || die + + + + + + + + EOF +} + # @FUNCTION: nuget_donuget # @USAGE: ... # @DESCRIPTION: -- cgit v1.2.3