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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CED731382C5 for ; Thu, 18 Feb 2021 10:52:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2B784E0825; Thu, 18 Feb 2021 10:52:27 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0DC44E0825 for ; Thu, 18 Feb 2021 10:52:27 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9DA4E340C50 for ; Thu, 18 Feb 2021 10:52:25 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2CD514C6 for ; Thu, 18 Feb 2021 10:52:24 +0000 (UTC) From: "Andrew Ammerlaan" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrew Ammerlaan" Message-ID: <1613645493.04573fbb57a934aae0e23369b013c31f1a3e4969.andrewammerlaan@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: scripts/ X-VCS-Repository: repo/proj/guru X-VCS-Files: scripts/check-duplicates.sh X-VCS-Directories: scripts/ X-VCS-Committer: andrewammerlaan X-VCS-Committer-Name: Andrew Ammerlaan X-VCS-Revision: 04573fbb57a934aae0e23369b013c31f1a3e4969 X-VCS-Branch: dev Date: Thu, 18 Feb 2021 10:52:24 +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: bba6779c-441c-4fbe-9205-34286fcff732 X-Archives-Hash: bb02fdb0b1425459ebf8b5f8809ddfb6 commit: 04573fbb57a934aae0e23369b013c31f1a3e4969 Author: Andrew Ammerlaan riseup net> AuthorDate: Thu Feb 18 10:51:33 2021 +0000 Commit: Andrew Ammerlaan riseup net> CommitDate: Thu Feb 18 10:51:33 2021 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=04573fbb scripts/check-duplicates.sh: read repo-name from profiles/ - also match foo-bar and foo_bar Signed-off-by: Andrew Ammerlaan riseup.net> scripts/check-duplicates.sh | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/check-duplicates.sh b/scripts/check-duplicates.sh index fe86a89e..85af7839 100755 --- a/scripts/check-duplicates.sh +++ b/scripts/check-duplicates.sh @@ -2,7 +2,7 @@ # Maintainer: Andrew Ammerlaan # Maintainer: Theo Anderson # -# This checks for potential and exact package matches within ::guru & ::gentoo +# This checks for potential and exact package matches within an overlay & ::gentoo # Note that this is not going to be 100% accurate # @@ -12,41 +12,45 @@ GENTOO_PACKAGES=( | sort | grep -Ev "^(.git|.github|metadata|profiles|scripts)/" ) ) -GURU_PACKAGES=( +REPO_PACKAGES=( $(find . -mindepth 2 -maxdepth 2 -printf "%P\n" \ | sort | grep -Ev "^(.git|.github|metadata|profiles|scripts)/" ) ) +REPO_NAME="$(cat profiles/repo_name)" + printf "\nChecking for duplicates...\n" for GENTOO_PKG in ${GENTOO_PACKAGES[@]}; do GENTOO_CATEGORIES+=( ${GENTOO_PKG%%/*} ) # Separate category GENTOO_PKG_NAME=${GENTOO_PKG##*/} # Separate name - GENTOO_PKG_NAME=${GENTOO_PKG_NAME,,} # Force lower case + GENTOO_PKG_NAME=${GENTOO_PKG_NAME,,} # Force lower case, e.g. to match foobar and FooBar + GENTOO_PKG_NAME=${GENTOO_PKG_NAME/[-_]} # Remove underscores and dashes, e.g. to match foo-bar and foo_bar GENTOO_PKG_NAMES+=( ${GENTOO_PKG_NAME} ) done -printf "Testing ${#GURU_PACKAGES[@]} GURU packages against ${#GENTOO_PKG_NAMES[@]} Gentoo packages\n" +printf "Testing ${#REPO_PACKAGES[@]} ${REPO_NAME^} packages against ${#GENTOO_PKG_NAMES[@]} Gentoo packages\n" -for GURU_PKG in ${GURU_PACKAGES[@]}; do - GURU_PKG_CATEGORY=${GURU_PKG%%/*} - GURU_PKG_NAME=${GURU_PKG##*/} - GURU_PKG_NAME=${GURU_PKG_NAME,,} +for REPO_PKG in ${REPO_PACKAGES[@]}; do + REPO_PKG_CATEGORY=${REPO_PKG%%/*} + REPO_PKG_NAME=${REPO_PKG##*/} + REPO_PKG_NAME=${REPO_PKG_NAME,,} + REPO_PKG_NAME=${REPO_PKG_NAME/[-_]} - if [[ ${GENTOO_PKG_NAMES[@]} =~ " ${GURU_PKG_NAME} " ]]; then # Check for a matcing name in the Gentoo tree, + if [[ ${GENTOO_PKG_NAMES[@]} =~ " ${REPO_PKG_NAME} " ]]; then # Check for a matcing name in the Gentoo tree, for (( i=0; i<${#GENTOO_PKG_NAMES[@]}; i++ )); do # otherwise there is no need to continue - [[ ${GENTOO_PKG_NAMES[$i]} == ${GURU_PKG_NAME} ]] && index+=( $i ) # Find the category/index for multiple matching names + [[ ${GENTOO_PKG_NAMES[$i]} == ${REPO_PKG_NAME} ]] && index+=( $i ) # Find the category/index for multiple matching names done for i in ${index[@]}; do # For each possible match - if [[ ${GENTOO_PACKAGES[$i]} == ${GURU_PKG} ]]; then - PKG_EXACT_MATCH+="\t${GURU_PKG}::guru exact match of ${GENTOO_PACKAGES[$i]}::gentoo\n" + if [[ ${GENTOO_PACKAGES[$i]} == ${REPO_PKG} ]]; then + PKG_EXACT_MATCH+="\t${REPO_PKG}::${REPO_NAME} exact match of ${GENTOO_PACKAGES[$i]}::gentoo\n" break # An exact match is fatal, no need to continue - elif [[ ${GENTOO_CATEGORIES[$i]} == ${GURU_PKG_CATEGORY} ]]; then # Possible match within the same category - PKG_CATEGORY_MATCH+="\t${GURU_PKG}::guru possible duplicate of ${GENTOO_PACKAGES[$i]}::gentoo\n" + elif [[ ${GENTOO_CATEGORIES[$i]} == ${REPO_PKG_CATEGORY} ]]; then # Possible match within the same category + PKG_CATEGORY_MATCH+="\t${REPO_PKG}::${REPO_NAME} possible duplicate of ${GENTOO_PACKAGES[$i]}::gentoo\n" else # Possible match in a different category - PKG_SPECULATIVE_MATCH+="\t${GURU_PKG}::guru possible duplicate of ${GENTOO_PACKAGES[$i]}::gentoo\n" + PKG_SPECULATIVE_MATCH+="\t${REPO_PKG}::${REPO_NAME} possible duplicate of ${GENTOO_PACKAGES[$i]}::gentoo\n" fi done unset index