Gentoo Archives: gentoo-portage-dev

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