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