1 |
commit: 67ffc42815419f5b33698f5739de321f6a6edd4a |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 6 08:30:50 2018 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 6 08:35:33 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=67ffc428 |
7 |
|
8 |
install-qa-check.d: Move 08gentoo-paths check outta Portage |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
Bug: https://bugs.gentoo.org/show_bug.cgi?id=667604 |
12 |
|
13 |
metadata/install-qa-check.d/08gentoo-paths | 77 ++++++++++++++++++++++++++++++ |
14 |
1 file changed, 77 insertions(+) |
15 |
|
16 |
diff --git a/metadata/install-qa-check.d/08gentoo-paths b/metadata/install-qa-check.d/08gentoo-paths |
17 |
new file mode 100644 |
18 |
index 00000000000..3ee887df08f |
19 |
--- /dev/null |
20 |
+++ b/metadata/install-qa-check.d/08gentoo-paths |
21 |
@@ -0,0 +1,77 @@ |
22 |
+# Check whether ebuilds are not installing new, non-Gentoo-ey paths. |
23 |
+ |
24 |
+gentoo_path_check() { |
25 |
+ # allowed path definitions |
26 |
+ # ------------------------ |
27 |
+ |
28 |
+ # directories common to / and /usr |
29 |
+ local allowed_common_dirs=( |
30 |
+ bin lib lib32 lib64 libx32 sbin |
31 |
+ ) |
32 |
+ |
33 |
+ # toplevel directories which can be installed to by ebuilds |
34 |
+ # /home is not included as no ebuilds should install files there |
35 |
+ local allowed_paths_toplevel=( |
36 |
+ "${allowed_common_dirs[@]}" |
37 |
+ boot dev etc opt srv usr var |
38 |
+ ) |
39 |
+ |
40 |
+ # directories in /usr which can be installed to by ebuilds |
41 |
+ # /usr/games is not included as it is banned nowadays |
42 |
+ local allowed_paths_usr=( |
43 |
+ "${allowed_common_dirs[@]}" |
44 |
+ include libexec share src |
45 |
+ # toolchain stuff |
46 |
+ "${CHOST}" "${CTARGET}" |
47 |
+ ) |
48 |
+ |
49 |
+ |
50 |
+ # the logic |
51 |
+ # --------- |
52 |
+ local bad_paths=() |
53 |
+ local x |
54 |
+ |
55 |
+ local shopt_save=$(shopt -p nullglob) |
56 |
+ shopt -s nullglob |
57 |
+ |
58 |
+ # 1. check for unexpected top-level directories |
59 |
+ local toplevel_dirs=( "${ED%/}"/* ) |
60 |
+ for x in "${toplevel_dirs[@]##*/}"; do |
61 |
+ if ! has "${x}" "${allowed_paths_toplevel[@]}"; then |
62 |
+ bad_paths+=( "/${x}" ) |
63 |
+ fi |
64 |
+ done |
65 |
+ |
66 |
+ # 2. check for unexpected /usr subdirectories |
67 |
+ local usr_dirs=( "${ED%/}"/usr/* ) |
68 |
+ for x in "${usr_dirs[@]##*/}"; do |
69 |
+ if ! has "${x}" "${allowed_paths_usr[@]}"; then |
70 |
+ bad_paths+=( "/usr/${x}" ) |
71 |
+ fi |
72 |
+ done |
73 |
+ |
74 |
+ # 3. check for unexpected /usr/share/doc subdirectories |
75 |
+ local doc_dirs=( "${ED%/}"/usr/share/doc/* ) |
76 |
+ for x in "${doc_dirs[@]##*/}"; do |
77 |
+ if [[ ${x} != ${PF} ]]; then |
78 |
+ bad_paths+=( "/usr/share/doc/${x}" ) |
79 |
+ fi |
80 |
+ done |
81 |
+ |
82 |
+ ${shopt_save} |
83 |
+ |
84 |
+ # report |
85 |
+ # ------ |
86 |
+ if [[ -n ${bad_paths[@]} ]]; then |
87 |
+ eqawarn "The ebuild is installing to one or more unexpected paths:" |
88 |
+ eqawarn |
89 |
+ eqatag -v non-gentoo-paths "${bad_paths[@]}" |
90 |
+ eqawarn |
91 |
+ eqawarn "Please fix the ebuild to use correct FHS/Gentoo policy paths." |
92 |
+ fi |
93 |
+} |
94 |
+ |
95 |
+gentoo_path_check |
96 |
+: # guarantee successful exit |
97 |
+ |
98 |
+# vim:ft=sh |