aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Ammerlaan <andrewammerlaan@riseup.net>2021-02-17 20:38:52 +0100
committerAndrew Ammerlaan <andrewammerlaan@riseup.net>2021-02-17 20:38:52 +0100
commitc8511a14fec6323b99300f881502ba49c9878b32 (patch)
treec4bbd4c736a08030c10b223f61b97f8c867ade53 /scripts
parentsys-cluster/lmod: lmod is now in ::gentoo (diff)
downloadsci-c8511a14fec6323b99300f881502ba49c9878b32.tar.gz
sci-c8511a14fec6323b99300f881502ba49c9878b32.tar.bz2
sci-c8511a14fec6323b99300f881502ba49c9878b32.zip
.github/workflows/duplicates.yml: add script to check for duplicates
Signed-off-by: Andrew Ammerlaan <andrewammerlaan@riseup.net>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-duplicates.sh76
1 files changed, 76 insertions, 0 deletions
diff --git a/scripts/check-duplicates.sh b/scripts/check-duplicates.sh
new file mode 100755
index 000000000..8f6b89af7
--- /dev/null
+++ b/scripts/check-duplicates.sh
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+# Maintainer: Andrew Ammerlaan <andrewammerlaan@riseup.net>
+#
+# This checks if packages in ::guru are also in ::gentoo
+#
+# Note that this is not going to be 100% accurate
+#
+#
+
+printf "\nChecking for duplicates....\n"
+
+gentoo_location="/var/db/repos/gentoo"
+guru_location="."
+
+gentoo_packs=$(find ${gentoo_location} -mindepth 2 -maxdepth 2 -printf "%P\n" | sort | grep -Ev "^(.git|.github|metadata|profiles|scripts)/")
+guru_packs=$(find ${guru_location} -mindepth 2 -maxdepth 2 -printf "%P\n" | sort | grep -Ev "^(.git|.github|metadata|profiles|scripts)/")
+
+pack_overrides="" pack_close_match_in_cat="" pack_close_match=""
+for guru_pack in ${guru_packs}; do
+ # separate category and packages
+ guru_pack_cat="${guru_pack%%/*}"
+ guru_pack_name="${guru_pack##*/}"
+
+ # convert all to lowercase
+ guru_pack_name="${guru_pack_name,,}"
+
+ # stip all numbers, dashes, underscores and pluses
+ guru_pack_name="${guru_pack_name/[0-9-_+]}"
+
+ for gentoo_pack in ${gentoo_packs}; do
+ # separate category and packages
+ gentoo_pack_cat="${gentoo_pack%%/*}"
+ gentoo_pack_name="${gentoo_pack##*/}"
+
+ # convert all to lowercase
+ gentoo_pack_name="${gentoo_pack_name,,}"
+
+ # stip all numbers, dashes, underscores and pluses
+ gentoo_pack_name="${gentoo_pack_name/[0-9-_+]}"
+
+ #TODO: check DESCRIPTION, HOMEPAGE and SRC_URI for close matches
+
+ if [[ "${gentoo_pack_name}" == "${guru_pack_name}" ]]; then
+ if [[ "${gentoo_pack_cat}" == "${guru_pack_cat}" ]]; then
+ if [[ "${gentoo_pack}" == "${guru_pack}" ]]; then
+ pack_overrides+="\t${guru_pack}::guru exact match of ${gentoo_pack}::gentoo\n"
+ else
+ pack_close_match_in_cat+="\t${guru_pack}::guru possible duplicate of ${gentoo_pack}::gentoo\n"
+ fi
+ else
+ pack_close_match+="\t${guru_pack}::guru possible duplicate of ${gentoo_pack}::gentoo\n"
+ fi
+ fi
+ done
+done
+
+if [ -n "${pack_close_match}" ]; then
+ printf "\nWARNING: The following packages closely match packages in the main Gentoo repository\n"
+ printf "${pack_close_match}"
+ printf "Please check these manually\n"
+fi
+
+if [ -n "${pack_close_match_in_cat}" ]; then
+ printf "\nWARNING: The following packages closely match packages in the main Gentoo repository in the same category\n"
+ printf "${pack_close_match_in_cat}"
+ printf "Please check these manually\n"
+fi
+
+if [ -n "${pack_overrides}" ]; then
+ printf "\nERROR: The following packages override packages in the main Gentoo repository\n"
+ printf "${pack_overrides}"
+ printf "Please remove these packages\n"
+ # do not exit fatally on ::science
+ # exit 1
+fi
+exit 0