summaryrefslogtreecommitdiff
path: root/eclass/nuget.eclass
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2024-02-10 17:34:25 +0000
committerV3n3RiX <venerix@koprulu.sector>2024-02-10 17:34:25 +0000
commit0bb42730e8fc9c8e571f12e3189c6c6f8d532c24 (patch)
treecba6032fbed30be2b0764494607c3ec9dda0c18a /eclass/nuget.eclass
parentcc901a8ce7c6bfe97e3b4f048619693d360ae348 (diff)
gentoo auto-resync : 10:02:2024 - 17:34:25
Diffstat (limited to 'eclass/nuget.eclass')
-rw-r--r--eclass/nuget.eclass47
1 files changed, 46 insertions, 1 deletions
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: <path>
+# @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
+ <?xml version="1.0" encoding="utf-8"?>
+ <configuration>
+ <packageSources>
+ <clear />
+ <add key="nuget" value="${NUGET_PACKAGES}" />
+ </packageSources>
+ </configuration>
+ EOF
+}
+
# @FUNCTION: nuget_donuget
# @USAGE: <nuget-path> ...
# @DESCRIPTION: