Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 1/2] Support post-postinst QA checks
Date: Tue, 15 Aug 2017 10:32:14
Message-Id: 20170815103200.15680-1-mgorny@gentoo.org
1 Extend the QA check mechanics in Portage to support post-postinst QA
2 checks. They are like post-install QA checks, except they are run after
3 pkg_postinst(), and so they can be used to verify that necessary
4 postinst actions were performed (e.g. regenerating caches).
5 ---
6 bin/misc-functions.sh | 57 ++++++++++++++++++++++++++++++++++
7 pym/portage/package/ebuild/doebuild.py | 5 ++-
8 2 files changed, 61 insertions(+), 1 deletion(-)
9
10 diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
11 index 079369313..18cddea21 100755
12 --- a/bin/misc-functions.sh
13 +++ b/bin/misc-functions.sh
14 @@ -256,6 +256,63 @@ install_qa_check() {
15 rm -f "${ED}"/usr/share/info/dir{,.gz,.bz2} || die "rm failed!"
16 }
17
18 +postinst_qa_check() {
19 + local d f paths qa_checks=()
20 + if ! ___eapi_has_prefix_variables; then
21 + local EPREFIX= EROOT=${ROOT}
22 + fi
23 +
24 + cd "${EROOT}" || die "cd failed"
25 +
26 + # Collect the paths for QA checks, highest prio first.
27 + paths=(
28 + # sysadmin overrides
29 + "${PORTAGE_OVERRIDE_EPREFIX}"/usr/local/lib/postinst-qa-check.d
30 + # system-wide package installs
31 + "${PORTAGE_OVERRIDE_EPREFIX}"/usr/lib/postinst-qa-check.d
32 + )
33 +
34 + # Now repo-specific checks.
35 + # (yes, PORTAGE_ECLASS_LOCATIONS contains repo paths...)
36 + for d in "${PORTAGE_ECLASS_LOCATIONS[@]}"; do
37 + paths+=(
38 + "${d}"/metadata/postinst-qa-check.d
39 + )
40 + done
41 +
42 + paths+=(
43 + # Portage built-in checks
44 + "${PORTAGE_OVERRIDE_EPREFIX}"/usr/lib/portage/postinst-qa-check.d
45 + "${PORTAGE_BIN_PATH}"/postinst-qa-check.d
46 + )
47 +
48 + # Collect file names of QA checks. We need them early to support
49 + # overrides properly.
50 + for d in "${paths[@]}"; do
51 + for f in "${d}"/*; do
52 + [[ -f ${f} ]] && qa_checks+=( "${f##*/}" )
53 + done
54 + done
55 +
56 + # Now we need to sort the filenames lexically, and process
57 + # them in order.
58 + while read -r -d '' f; do
59 + # Find highest priority file matching the basename.
60 + for d in "${paths[@]}"; do
61 + [[ -f ${d}/${f} ]] && break
62 + done
63 +
64 + # Run in a subshell to treat it like external script,
65 + # but use 'source' to pass all variables through.
66 + (
67 + # Allow inheriting eclasses.
68 + # XXX: we want this only in repository-wide checks.
69 + _IN_INSTALL_QA_CHECK=1
70 + source "${d}/${f}" || eerror "Post-postinst QA check ${f} failed to run"
71 + )
72 + done < <(printf "%s\0" "${qa_checks[@]}" | LC_ALL=C sort -u -z)
73 +}
74 +
75 install_mask() {
76 local root="$1"
77 shift
78 diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
79 index 14d96f57c..ac697a763 100644
80 --- a/pym/portage/package/ebuild/doebuild.py
81 +++ b/pym/portage/package/ebuild/doebuild.py
82 @@ -1738,7 +1738,10 @@ _post_phase_cmds = {
83 "preinst_sfperms",
84 "preinst_selinux_labels",
85 "preinst_suid_scan",
86 - ]
87 + ],
88 +
89 + "postinst" : [
90 + "postinst_qa_check"],
91 }
92
93 def _post_phase_userpriv_perms(mysettings):
94 --
95 2.14.1

Replies