From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C400315815E for ; Sat, 10 Feb 2024 16:25:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 29205E2A4A; Sat, 10 Feb 2024 16:24:59 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 09D09E2A4A for ; Sat, 10 Feb 2024 16:24:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 14CCB343084 for ; Sat, 10 Feb 2024 16:24:58 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5665814D0 for ; Sat, 10 Feb 2024 16:24:55 +0000 (UTC) From: "Maciej Barć" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Maciej Barć" Message-ID: <1707582286.bdfc07876f80d92d22d1d124d0f925cdc8f71984.xgqt@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/dotnet-pkg.eclass eclass/nuget.eclass X-VCS-Directories: eclass/ X-VCS-Committer: xgqt X-VCS-Committer-Name: Maciej Barć X-VCS-Revision: bdfc07876f80d92d22d1d124d0f925cdc8f71984 X-VCS-Branch: master Date: Sat, 10 Feb 2024 16:24:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5f611bad-9b34-456b-b800-82ff825b201d X-Archives-Hash: d9038c5c26175f0370a615dd1f43843c commit: bdfc07876f80d92d22d1d124d0f925cdc8f71984 Author: Maciej Barć gentoo org> AuthorDate: Sat Feb 3 16:08:24 2024 +0000 Commit: Maciej Barć gentoo org> CommitDate: Sat Feb 10 16:24:46 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bdfc0787 eclass/dotnet-pkg.eclass: prepare for safely using Nuget prevent NuGet executable (part of "dotnet-sdk") from fetching remote NuGet package sources, add two new features to the nuget ecalss: find and remove all nuget.config files, add and use "nuget_writeconfig" function that creates a "nuget.config" file which forces the use of NuGet packages specified in the ebuild file Signed-off-by: Maciej Barć gentoo.org> eclass/dotnet-pkg.eclass | 8 ++++++-- eclass/nuget.eclass | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/eclass/dotnet-pkg.eclass b/eclass/dotnet-pkg.eclass index eba46c2af2a5..59a8ae799f86 100644 --- a/eclass/dotnet-pkg.eclass +++ b/eclass/dotnet-pkg.eclass @@ -225,12 +225,16 @@ dotnet-pkg_remove-bad() { # Default "src_prepare" for the "dotnet-pkg" eclass. # Prepare the package sources. # -# Run "dotnet-pkg-base_remove-global-json" -# and "dotnet-pkg-base_remove-bad" for each found solution file. +# Run "dotnet-pkg-base_remove-global-json", "dotnet-pkg-base_remove-bad" +# for each found solution file and prepare for using Nuget. dotnet-pkg_src_prepare() { dotnet-pkg-base_remove-global-json dotnet-pkg-base_foreach-solution "$(pwd)" dotnet-pkg_remove-bad + find "$(pwd)" -maxdepth 1 -iname "nuget.config" -delete || + die "${FUNCNAME[0]}: failed to remove unwanted \"NuGet.config\" config files" + nuget_writeconfig "$(pwd)/" + default } 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: