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