blob: b7a111277f70aca832ef38f1ac90aa0ae76fa618 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/bash
# This script respects EINFO_QUIET=1 etc to silence stdout
# Always puts a summary in $1/README.html.
# Arguments:
# $1: output directory. Defaults to eapi-usage.
# $2: file to place stats in within $1.
. /lib/gentoo/functions.sh
dir=${1}
if [[ -n ${1} && -e ${dir} && ! -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
stats=${2:-$dir/STATS.txt}
mkdir -p ${dir} || exit 1
REPO_PATH=$(portageq get_repo_path ${EROOT:-/} gentoo || exit 1)
TMPDIR="$(mktemp -d || exit 1)"
shopt -s nullglob
einfo "Working in TMPDIR=${TMPDIR}"
pushd "${TMPDIR}" &>/dev/null || exit 1
mkdir -p eapi-usage || exit 1
cd eapi-usage || exit 1
ebegin "Finding ebuilds"
(
while IFS= read -r ebuild ; do
cpf_eapi="${ebuild#${REPO_PATH}/metadata/md5-cache/}"
cpf="${cpf_eapi%%:*}"
eapi="${cpf_eapi##*:EAPI=}"
echo "${cpf}" >> ${eapi}.txt
done < <(find "${REPO_PATH}/metadata/md5-cache" -mindepth 2 -maxdepth 2 -type f -name '*-[0-9]*' -exec grep '^EAPI=' {} +)
) || { eend $? || exit 1; }
eend ${?}
ebegin "Sorting EAPI files"
for eapi in *.txt ; do
sort -u ${eapi} > ${eapi}.sorted
mv ${eapi}.sorted ${eapi}
done || { eend $? || exit 1; }
eend $?
popd &>/dev/null || exit 1
# No exit here because it's fine if we removed nothing
rm ${dir}/*.txt
mv ${TMPDIR}/eapi-usage/*.txt ${dir}/ || exit 1
rm -r "${TMPDIR}" || exit 1
# Now generate the numbers/summary (copied in from previous eapi_usage.sh script)
# Someday it would be nice to graph this output, or maybe keep some running history?
# TODO: We used pinspect in the past which is cleaner but it's slower than the
# awk method used below (we also stopped using it because at the time, pkgcore
# lacked newer EAPI support).
#[[ $(type pinspect 2> /dev/null) ]] || exit 1
#
#pinspect eapi_usage /usr/portage
find "${REPO_PATH}"/metadata/md5-cache -type f ! -name '*.gz' \
-exec grep -h '^EAPI=' '{}' + \
| awk '
{ sub("EAPI=",""); eapi[$1]++ }
END {
PROCINFO["sorted_in"]="@val_num_desc"
for (i in eapi) {
s=""; for (j=1; j<eapi[i]*50./NR+0.5; j++) s=s"#"
printf "EAPI %s: %7d ebuilds (%5.02f%%) %s\n",
i, eapi[i], eapi[i]*100.0/NR, s
}
printf "total: %7d ebuilds\n", NR
}' > ${stats}
echo >> ${stats}
echo "Date generated: $(date -u '+%Y-%m-%d %H:%M:%S %Z')" >> ${stats}
echo "<pre>" > ${dir}/README.html
cat ${stats} >> ${dir}/README.html
echo "</pre>" >> ${dir}/README.html
|