From 752d6256e5204b958b0ef7905675a940b5e9172f Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Thu, 12 May 2022 16:42:50 +0300 Subject: gentoo resync : 12.05.2022 --- metadata/install-qa-check.d/60libtool-la | 42 +++++++++++++++++++ metadata/install-qa-check.d/60tmpfiles-paths | 4 +- metadata/install-qa-check.d/60udev-eclass | 63 ++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 metadata/install-qa-check.d/60libtool-la create mode 100644 metadata/install-qa-check.d/60udev-eclass (limited to 'metadata/install-qa-check.d') diff --git a/metadata/install-qa-check.d/60libtool-la b/metadata/install-qa-check.d/60libtool-la new file mode 100644 index 000000000000..48849f42e154 --- /dev/null +++ b/metadata/install-qa-check.d/60libtool-la @@ -0,0 +1,42 @@ +# Check if we're installing .la files unnecessarily +# https://projects.gentoo.org/qa/policy-guide/installed-files.html#pg0303 + +libtool_la_check() { + if [[ ${CATEGORY}/${PN} == dev-libs/libltdl ]] ; then + # bug #293921 + return + fi + + # Bail out if there aren't any .la files being installed + # TODO: use -d'' w/ newer EAPIs (bash 4.4+) + readarray -t files < <(find "${ED}"/usr/lib* -name '*.la' -print 2>/dev/null) + [[ -n "${files[@]}" ]] || return + + if grep -q "dev-libs/libltdl" <<<${RDEPEND}; then + # Nothing to do here + return + fi + + # Iterate over all the .la files we are installing to verify there's + # a corresponding .a file - they're pointless without a corresponding + # static library. + local file + local dir + local base + local bad_files=() + for file in "${files[@]}" ; do + if [[ ! -f ${file%.la}.a ]] ; then + bad_files+=( ${file} ) + fi + done + + if [[ -n "${bad_files[@]}" ]] ; then + eqawarn "QA Notice: Installing libtool files (.la) without corresponding static libraries!" + eqatag -v libtool-la.unnecessary "${bad_files[@]#${D}}" + fi +} + +libtool_la_check +: # guarantee successful exit + +# vim:ft=sh diff --git a/metadata/install-qa-check.d/60tmpfiles-paths b/metadata/install-qa-check.d/60tmpfiles-paths index 1d46cab6ecc0..049f73aaf07d 100644 --- a/metadata/install-qa-check.d/60tmpfiles-paths +++ b/metadata/install-qa-check.d/60tmpfiles-paths @@ -1,11 +1,11 @@ -# Copyright 2021 Gentoo Authors +# Copyright 2021-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # QA check: ensure that packages installing tmpfiles configuration inherit the eclass # Maintainer: Sam James # Maintainer: Georgy Yakovlev -# Implements two checks: +# Implements three checks: # 1) Installation to /etc/tmpfiles.d (which is a user-customization location); # 2) Installation of any tmpfiles to /usr/lib/tmpfiles.d without inheriting the eclass # (needed for tmpfiles_process in pkg_postinst); diff --git a/metadata/install-qa-check.d/60udev-eclass b/metadata/install-qa-check.d/60udev-eclass new file mode 100644 index 000000000000..4aadc9b1f18d --- /dev/null +++ b/metadata/install-qa-check.d/60udev-eclass @@ -0,0 +1,63 @@ +# Copyright 2021-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# QA check: ensure that packages installing udev rules inherit the eclass +# Maintainer: Sam James + +# Implements three checks: +# 1) Installation to /etc/udev/rules.d (which is a user-customization location); +# 2) Installation of any udev rules to /lib/udev/rules.d without inheriting the eclass +# (needed for udev_reload in pkg_postinst); +# 3) Check for installation of udev rules without calling udev_reload in +# pkg_postinst. +udev_rules_check() { + # Check 1 + # Scan image for files in /etc/udev/rules.d which is a forbidden location + # (We use this glob to avoid triggering on keepdir) + shopt -s nullglob + local files=( "${ED}"/etc/udev/rules.d/* ) + shopt -u nullglob + + if [[ ${#files[@]} -gt 0 ]]; then + eqawarn "QA Notice: files installed to /etc/udev/rules.d found" + eqawarn "udev rules files supplied by ebuilds must be installed to /lib/udev/rules.d/" + fi + + # Check 2 + # We're now going to check for whether we install files to /lib/udev/rules.d/ without + # inheriting the eclass (weak catch for ebuilds not calling udev_reload in pkg_postinst) + + if [[ -n ${UDEV_OPTIONAL} ]] ; then + # While imperfect, using ${UDEV_OPTIONAL} is good enough to allow opting out + # for e.g. sys-apps/portage, sys-apps/systemd, sys-libs/pam, etc. We may want + # a better/more standardised way to opt out from QA checks in future. + # It's okay for some packages to do this because of circular dependencies and such + # See: https://archives.gentoo.org/gentoo-dev/message/0a96793036a4fdd9ac311a46950d7e7b + return + fi + + if [[ -d "${ED}"/lib/udev/rules.d/ ]] ; then + if ! has udev ${INHERITED} ; then + eqawarn "QA Notice: package is installing udev rules without inheriting udev.eclass!" + eqawarn "Packages must inherit udev.eclass then call udev_reload in pkg_postinst." + return + fi + + # Check 3 + # Check whether we're installing udev rules without explicitly + # calling udev_reload in pkg_postinst, but we have inherited + # the eclass. + # Small risk of false positives if called indirectly. + # See: https://archives.gentoo.org/gentoo-dev/message/7bdfdc9a7560fd07436defd0253af0b8 + local pkg_postinst_body="$(declare -fp pkg_postinst 2>&1)" + if [[ ! ${pkg_postinst_body} == *udev_reload* ]] ; then + eqawarn "QA Notice: package is installing udev rules without calling" + eqawarn "udev_reload in pkg_postinst phase" + fi + fi +} + +udev_rules_check +: # guarantee successful exit + +# vim:ft=sh -- cgit v1.2.3