version bumps and a few new packages
[dbus-free.git] / scripts / check-duplicates.sh
bloba094dbf549360ac9a3e58698a0c8bd19100091bb
1 #! /usr/bin/env bash
2 # Maintainer: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
3 # Maintainer: James Beddek <telans@posteo.de>
5 # This checks for potential and exact package matches within an overlay & ::gentoo
6 # Note that this is not going to be 100% accurate
8 EXCLUDE='^(.git|.github|metadata|profiles|scripts)/|^eclass/tests$|metadata.xml'
10 GENTOO_DIR="/var/db/repos/gentoo"
11 GENTOO_PACKAGES=(
12 $(find ${GENTOO_DIR} -mindepth 2 -maxdepth 2 -printf "%P\n" \
13 | sort | grep -Ev "${EXCLUDE}"
16 REPO_PACKAGES=(
17 $(find . -mindepth 2 -maxdepth 2 -printf "%P\n" \
18 | sort | grep -Ev "${EXCLUDE}"
22 REPO_NAME="$(cat profiles/repo_name)"
24 printf "\nChecking for duplicates...\n"
26 for GENTOO_PKG in ${GENTOO_PACKAGES[@]}; do
27 GENTOO_CATEGORIES+=( ${GENTOO_PKG%%/*} ) # Separate category
28 GENTOO_PKG_NAME=${GENTOO_PKG##*/} # Separate name
29 GENTOO_PKG_NAME=${GENTOO_PKG_NAME,,} # Force lower case, e.g. to match foobar and FooBar
30 GENTOO_PKG_NAME=${GENTOO_PKG_NAME/[-_]} # Remove underscores and dashes, e.g. to match foo-bar and foo_bar
31 GENTOO_PKG_NAMES+=( ${GENTOO_PKG_NAME} )
32 done
34 printf "Testing ${#REPO_PACKAGES[@]} ${REPO_NAME^} packages against ${#GENTOO_PKG_NAMES[@]} Gentoo packages\n"
36 for REPO_PKG in ${REPO_PACKAGES[@]}; do
37 REPO_PKG_CATEGORY=${REPO_PKG%%/*}
38 REPO_PKG_NAME=${REPO_PKG##*/}
39 REPO_PKG_NAME=${REPO_PKG_NAME,,}
40 REPO_PKG_NAME=${REPO_PKG_NAME/[-_]}
42 if [[ ${GENTOO_PKG_NAMES[@]} =~ " ${REPO_PKG_NAME} " ]]; then # Check for a matcing name in the Gentoo tree,
43 for (( i=0; i<${#GENTOO_PKG_NAMES[@]}; i++ )); do # otherwise there is no need to continue
44 [[ ${GENTOO_PKG_NAMES[$i]} == ${REPO_PKG_NAME} ]] && index+=( $i ) # Find the category/index for multiple matching names
45 done
47 for i in ${index[@]}; do # For each possible match
48 if [[ ${GENTOO_PACKAGES[$i]} == ${REPO_PKG} ]]; then
49 PKG_EXACT_MATCH+="\t${REPO_PKG}::${REPO_NAME} exact match of ${GENTOO_PACKAGES[$i]}::gentoo\n"
50 break # An exact match is fatal, no need to continue
51 elif [[ ${GENTOO_CATEGORIES[$i]} == ${REPO_PKG_CATEGORY} ]]; then # Possible match within the same category
52 PKG_CATEGORY_MATCH+="\t${REPO_PKG}::${REPO_NAME} possible duplicate of ${GENTOO_PACKAGES[$i]}::gentoo\n"
53 else # Possible match in a different category
54 PKG_SPECULATIVE_MATCH+="\t${REPO_PKG}::${REPO_NAME} possible duplicate of ${GENTOO_PACKAGES[$i]}::gentoo\n"
56 done
57 unset index
59 done
61 if [[ -n ${PKG_SPECULATIVE_MATCH} ]]; then
62 printf "\nWARNING: The following packages closely match packages in the main Gentoo repository:\n"
63 printf "${PKG_SPECULATIVE_MATCH}"
64 printf "Please check these manually.\n"
67 if [[ -n ${PKG_CATEGORY_MATCH} ]]; then
68 printf "\nWARNING: The following packages closely match packages in the main Gentoo repository, in the same category:\n"
69 printf "${PKG_CATEGORY_MATCH}"
70 printf "Please check these manually.\n"
73 if [[ -n ${PKG_EXACT_MATCH} ]]; then
74 printf "\nERROR: The following packages override packages in the main Gentoo repository:\n"
75 printf "${PKG_EXACT_MATCH}"
76 printf "Please remove these packages.\n"
77 exit 1