1 |
commit: d5f97eaa464736a454c8ad410f4acd4fccdf2324 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Sep 4 06:54:23 2018 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Sep 4 21:15:55 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d5f97eaa |
7 |
|
8 |
install-qa-checks.d: Add a check for Gentoo path policies (FHS-y) |
9 |
|
10 |
Add a check that verifies whether ebuilds don't install to paths |
11 |
forbidden by the policy. This mostly aims to verbosely report bugs |
12 |
such as missing dependencies causing empty install paths, resulting |
13 |
in files ending up in / and bad upstreams. This should also help |
14 |
detect the relatively common mistake of using /usr/share/doc/${P} |
15 |
instead of ${PF}. |
16 |
|
17 |
The initial list of allowed paths was based on what ebuilds installed |
18 |
to my system. |
19 |
|
20 |
bin/install-qa-check.d/08gentoo-paths | 77 +++++++++++++++++++++++++++++++++++ |
21 |
1 file changed, 77 insertions(+) |
22 |
|
23 |
diff --git a/bin/install-qa-check.d/08gentoo-paths b/bin/install-qa-check.d/08gentoo-paths |
24 |
new file mode 100644 |
25 |
index 000000000..3ee887df0 |
26 |
--- /dev/null |
27 |
+++ b/bin/install-qa-check.d/08gentoo-paths |
28 |
@@ -0,0 +1,77 @@ |
29 |
+# Check whether ebuilds are not installing new, non-Gentoo-ey paths. |
30 |
+ |
31 |
+gentoo_path_check() { |
32 |
+ # allowed path definitions |
33 |
+ # ------------------------ |
34 |
+ |
35 |
+ # directories common to / and /usr |
36 |
+ local allowed_common_dirs=( |
37 |
+ bin lib lib32 lib64 libx32 sbin |
38 |
+ ) |
39 |
+ |
40 |
+ # toplevel directories which can be installed to by ebuilds |
41 |
+ # /home is not included as no ebuilds should install files there |
42 |
+ local allowed_paths_toplevel=( |
43 |
+ "${allowed_common_dirs[@]}" |
44 |
+ boot dev etc opt srv usr var |
45 |
+ ) |
46 |
+ |
47 |
+ # directories in /usr which can be installed to by ebuilds |
48 |
+ # /usr/games is not included as it is banned nowadays |
49 |
+ local allowed_paths_usr=( |
50 |
+ "${allowed_common_dirs[@]}" |
51 |
+ include libexec share src |
52 |
+ # toolchain stuff |
53 |
+ "${CHOST}" "${CTARGET}" |
54 |
+ ) |
55 |
+ |
56 |
+ |
57 |
+ # the logic |
58 |
+ # --------- |
59 |
+ local bad_paths=() |
60 |
+ local x |
61 |
+ |
62 |
+ local shopt_save=$(shopt -p nullglob) |
63 |
+ shopt -s nullglob |
64 |
+ |
65 |
+ # 1. check for unexpected top-level directories |
66 |
+ local toplevel_dirs=( "${ED%/}"/* ) |
67 |
+ for x in "${toplevel_dirs[@]##*/}"; do |
68 |
+ if ! has "${x}" "${allowed_paths_toplevel[@]}"; then |
69 |
+ bad_paths+=( "/${x}" ) |
70 |
+ fi |
71 |
+ done |
72 |
+ |
73 |
+ # 2. check for unexpected /usr subdirectories |
74 |
+ local usr_dirs=( "${ED%/}"/usr/* ) |
75 |
+ for x in "${usr_dirs[@]##*/}"; do |
76 |
+ if ! has "${x}" "${allowed_paths_usr[@]}"; then |
77 |
+ bad_paths+=( "/usr/${x}" ) |
78 |
+ fi |
79 |
+ done |
80 |
+ |
81 |
+ # 3. check for unexpected /usr/share/doc subdirectories |
82 |
+ local doc_dirs=( "${ED%/}"/usr/share/doc/* ) |
83 |
+ for x in "${doc_dirs[@]##*/}"; do |
84 |
+ if [[ ${x} != ${PF} ]]; then |
85 |
+ bad_paths+=( "/usr/share/doc/${x}" ) |
86 |
+ fi |
87 |
+ done |
88 |
+ |
89 |
+ ${shopt_save} |
90 |
+ |
91 |
+ # report |
92 |
+ # ------ |
93 |
+ if [[ -n ${bad_paths[@]} ]]; then |
94 |
+ eqawarn "The ebuild is installing to one or more unexpected paths:" |
95 |
+ eqawarn |
96 |
+ eqatag -v non-gentoo-paths "${bad_paths[@]}" |
97 |
+ eqawarn |
98 |
+ eqawarn "Please fix the ebuild to use correct FHS/Gentoo policy paths." |
99 |
+ fi |
100 |
+} |
101 |
+ |
102 |
+gentoo_path_check |
103 |
+: # guarantee successful exit |
104 |
+ |
105 |
+# vim:ft=sh |