Ebuilds do not declare @system members, but the default qa-vdb exclude list only covers the toolchain, so every package linking libuuid, libkmod or liblzma got a missing dependency notice for util-linux, kmod or xz-utils. Signed-off-by: Zakk <zakk@gentoozh.org>
99 lines
3.6 KiB
Bash
Executable File
99 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# usage: emerge-qa.sh before
|
|
# emerge-qa.sh after
|
|
# Adds the qa-vdb and LDFLAGS QA checks to emerge-on-pr, and moves their notices
|
|
# out of the elog in elog-report/, so they are listed in the pull request comment
|
|
# and do not fail the job.
|
|
set -euo pipefail
|
|
REPORT=elog-report
|
|
|
|
# before: install iwdevtools, run qa-vdb after pkg_postinst as qa-vdb(1) shows, and
|
|
# mark LDFLAGS with the symbol Portage checks for in every ELF file
|
|
before() {
|
|
FEATURES=getbinpkg emerge --oneshot --quiet app-portage/iwdevtools
|
|
# ebuilds do not declare @system members, so qa-vdb must not ask for them
|
|
python3 -I -c 'import portage; print(*sorted({portage.dep.Atom(a.lstrip("*")).cp for a in portage.settings.packages}), sep="\n")' \
|
|
>> /etc/iwdevtools/qa-vdb.exclude
|
|
cat >> /etc/portage/bashrc << 'EOF'
|
|
QA_VDB_ARGS="--no-color --no-extra"
|
|
source /usr/share/iwdevtools/qa-vdb.bashrc
|
|
|
|
post_pkg_postinst() {
|
|
qa-vdb_post_pkg_postinst
|
|
}
|
|
EOF
|
|
cat >> /etc/portage/make.conf << 'EOF'
|
|
LDFLAGS="${LDFLAGS} -Wl,--defsym=__gentoo_check_ldflags__=0"
|
|
EOF
|
|
echo "LDFLAGS=$(portageq envvar LDFLAGS)"
|
|
}
|
|
|
|
# split_notices <elog> <vdb> <ldflags>: print the elog without the notices. The
|
|
# dependency lines of qa-vdb go to <vdb> and the files built without LDFLAGS to <ldflags>.
|
|
split_notices() {
|
|
awk -v vdb="$2" -v ldflags="$3" '
|
|
function flush( i) {
|
|
if (kept) {
|
|
if (pkg != "") print pkg
|
|
pkg = ""
|
|
print header
|
|
for (i = 1; i <= kept; i++) print keep[i]
|
|
}
|
|
kept = 0
|
|
state = ""
|
|
}
|
|
/^>>> / { flush(); header = ""; pkg = $0; next }
|
|
/^(LOG|WARN|ERROR|QA): [a-z]+$/ { flush(); header = $0; qa = $0 ~ /^QA/; next }
|
|
{
|
|
line = $0
|
|
gsub(/\x1b\[[0-9;]*m/, "", line)
|
|
if (qa && line ~ /^QA Notice: Files built without respecting LDFLAGS have been detected/)
|
|
state = "ldflags"
|
|
else if (state == "ldflags" && line !~ /^( Please include the following list of files in your report:$|\/)/)
|
|
state = ""
|
|
# qa-vdb runs after pkg_postinst, so its output ends the section
|
|
if (qa && line ~ /^VDB: detected possibly incorrect R?DEPEND /)
|
|
state = "vdb"
|
|
if (state == "ldflags") {
|
|
if (line ~ /^\//) print line > ldflags
|
|
} else if (state == "vdb") {
|
|
# qa-vdb marks a missing slot or binding operator with | and a missing
|
|
# dependency with >; --no-extra leaves out the unneeded ones
|
|
sub(/ +$/, "", line)
|
|
if (line ~ /(^| )[|>]( |$)/) print line > vdb
|
|
} else
|
|
keep[++kept] = $0
|
|
}
|
|
END { flush() }
|
|
' "$1"
|
|
}
|
|
|
|
# after: move the notices out of elog and target-elog, keeping only the target's in
|
|
# notices-vdb and notices-ldflags
|
|
after() {
|
|
local kind
|
|
[ -f "$REPORT/elog" ] || return 0
|
|
split_notices "$REPORT/elog" /dev/null /dev/null > "$REPORT/elog.new"
|
|
mv "$REPORT/elog.new" "$REPORT/elog"
|
|
rm -f "$REPORT/notices-vdb" "$REPORT/notices-ldflags"
|
|
split_notices "$REPORT/target-elog" "$REPORT/notices-vdb" "$REPORT/notices-ldflags" > "$REPORT/target-elog.new"
|
|
mv "$REPORT/target-elog.new" "$REPORT/target-elog"
|
|
for kind in vdb ldflags; do
|
|
[ -s "$REPORT/notices-$kind" ] || continue
|
|
echo "notices-$kind:"
|
|
cat "$REPORT/notices-$kind"
|
|
done
|
|
}
|
|
|
|
command=${1:-}
|
|
case $command in
|
|
before|after)
|
|
shift
|
|
"$command" "$@"
|
|
;;
|
|
*)
|
|
echo 'usage: emerge-qa.sh before | after' >&2
|
|
exit 2
|
|
;;
|
|
esac
|