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 A98C215815E for ; Wed, 7 Feb 2024 20:36:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DA5D6E2A3A; Wed, 7 Feb 2024 20:35:27 +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 8F94EE2A37 for ; Wed, 7 Feb 2024 20:35:27 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 3/8] llvm-utils.eclass: Fix llvm_prepend_path to avoid duplicates Date: Wed, 7 Feb 2024 21:11:38 +0100 Message-ID: <20240207203515.17640-4-mgorny@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207203515.17640-1-mgorny@gentoo.org> References: <20240207203515.17640-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 824af412-126d-4616-b605-2b2346446db6 X-Archives-Hash: 543dc9cf6143478fec2497d8b878b605 Fix llvm_prepend_path() not to append the new path multiple times, if the original PATH variable contained multiple LLVM directories. Thanks to @miller-alex who spotted it in: https://github.com/gentoo/gentoo/pull/35196#discussion_r1480330001 Signed-off-by: Michał Górny --- eclass/llvm-utils.eclass | 2 +- eclass/tests/llvm-utils.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/eclass/llvm-utils.eclass b/eclass/llvm-utils.eclass index f308667e3dc2..86933484fa94 100644 --- a/eclass/llvm-utils.eclass +++ b/eclass/llvm-utils.eclass @@ -132,7 +132,7 @@ llvm_prepend_path() { # prepend new path in front of the first LLVM version found for x in "${split_path[@]}"; do if [[ ${x} == */usr/lib/llvm/*/bin ]]; then - if [[ ${x} != ${llvm_path} ]]; then + if [[ ${x} != ${llvm_path} && ! ${added} ]]; then new_path+=( "${llvm_path}" ) elif [[ ${added} && ${x} == ${llvm_path} ]]; then # deduplicate diff --git a/eclass/tests/llvm-utils.sh b/eclass/tests/llvm-utils.sh index 5a46b25b7ad6..c786ef04ddcd 100755 --- a/eclass/tests/llvm-utils.sh +++ b/eclass/tests/llvm-utils.sh @@ -102,5 +102,11 @@ test_prepend_path 18 /usr/lib/llvm/17/bin:/usr/bin \ /usr/lib/llvm/18/bin:/usr/lib/llvm/17/bin:/usr/bin test_prepend_path 18 /usr/bin:/usr/lib/llvm/17/bin \ /usr/bin:/usr/lib/llvm/18/bin:/usr/lib/llvm/17/bin +test_prepend_path 18 /usr/lib/llvm/17/bin:/usr/lib/llvm/16/bin:/usr/bin \ + /usr/lib/llvm/18/bin:/usr/lib/llvm/17/bin:/usr/lib/llvm/16/bin:/usr/bin +test_prepend_path 18 /usr/bin:/usr/lib/llvm/17/bin:/usr/lib/llvm/16/bin \ + /usr/bin:/usr/lib/llvm/18/bin:/usr/lib/llvm/17/bin:/usr/lib/llvm/16/bin +test_prepend_path 18 /usr/lib/llvm/17/bin:/usr/bin:/usr/lib/llvm/16/bin \ + /usr/lib/llvm/18/bin:/usr/lib/llvm/17/bin:/usr/bin:/usr/lib/llvm/16/bin texit -- 2.43.0