commit: 4484c577af41785358982daf4829f71091207567
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 19 18:48:58 2022 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Mar 19 18:52:15 2022 +0000
URL: https://gitweb.gentoo.org/proj/qa-scripts.git/commit/?id=4484c577
check-eapis.sh: new script to list each ebuild using each EAPI
Signed-off-by: Sam James <sam <AT> gentoo.org>
check-eapis.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/check-eapis.sh b/check-eapis.sh
new file mode 100755
index 0000000..cfd58a1
--- /dev/null
+++ b/check-eapis.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+# Arguments:
+# $1: output directory. Defaults to eapi-usage.
+
+. /lib/gentoo/functions.sh
+dir=${1}
+if [[ -n ${1} && ! -d ${dir} ]] ; then
+ eerror "Output directory given (${dir}) is not a directory! Exiting."
+ exit 1
+elif [[ -z ${dir} ]] ; then
+ ewarn "No output directory argument given! Defaulting to 'eapi-usage'."
+ dir=eapi-usage
+fi
+
+REPO_PATH=$(portageq get_repo_path ${EROOT:-/} gentoo || exit 1)
+
+mkdir -p ${dir} || exit 1
+
+ebegin "Getting list of supported EAPIs"
+eapi_list=$(python3 -c 'import portage.repository.config;
print("\n".join(list(portage._supported_eapis)))' || exit 1)
+eend $?
+einfo "EAPI list:" ${eapi_list}
+
+TMPDIR="$(mktemp -d || exit 1)"
+
+einfo "Working in TMPDIR=${TMPDIR}"
+pushd "${TMPDIR}" &>/dev/null || exit 1
+mkdir -p eapi-usage || exit 1
+cd eapi-usage || exit 1
+
+for eapi in ${eapi_list[@]} ; do
+ [[ -f ${eapi}.txt ]] && rm -r ${eapi}.txt
+ touch ${eapi}.txt
+done
+
+ebegin "Finding ebuilds"
+(
+ for ebuild in $(find "${REPO_PATH}/metadata/md5-cache" -mindepth 2
-maxdepth 2 -type f -name '*-[0-9]*') ; do
+ cpf=$(echo ${ebuild} | rev | cut -d/ -f1-2 | rev)
+ eapi=$(grep -oi "eapi=.*" ${ebuild} | sed -e 's:EAPI=::')
+
+ echo "${cpf}" >> ${eapi}.txt
+ done
+) || { eend $? || exit 1; }
+eend ${?}
+
+ebegin "Sorting EAPI files"
+for eapi in ${eapi_list[@]} ; do
+ sort -u ${eapi}.txt > ${eapi}.txt.sorted
+ mv ${eapi}.txt.sorted ${eapi}.txt
+done || { eend $? || exit 1; }
+eend $?
+
+popd &>/dev/null || exit 1
+mv ${TMPDIR}/eapi-usage/*.txt ${dir}/ || exit 1
+
+rm -r "${TMPDIR}" || exit 1