summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2018-10-06 10:30:50 +0200
committerMichał Górny <mgorny@gentoo.org>2018-10-06 10:35:33 +0200
commit67ffc42815419f5b33698f5739de321f6a6edd4a (patch)
treef7581df318454d96d70531347073ff2bdeb8c96d /metadata
parentnet-libs/gnutls: revert explicit prefix added for cross-compile (diff)
downloadgentoo-67ffc42815419f5b33698f5739de321f6a6edd4a.tar.gz
gentoo-67ffc42815419f5b33698f5739de321f6a6edd4a.tar.bz2
gentoo-67ffc42815419f5b33698f5739de321f6a6edd4a.zip
install-qa-check.d: Move 08gentoo-paths check outta Portage
Signed-off-by: Michał Górny <mgorny@gentoo.org> Bug: https://bugs.gentoo.org/show_bug.cgi?id=667604
Diffstat (limited to 'metadata')
-rw-r--r--metadata/install-qa-check.d/08gentoo-paths77
1 files changed, 77 insertions, 0 deletions
diff --git a/metadata/install-qa-check.d/08gentoo-paths b/metadata/install-qa-check.d/08gentoo-paths
new file mode 100644
index 000000000000..3ee887df08f8
--- /dev/null
+++ b/metadata/install-qa-check.d/08gentoo-paths
@@ -0,0 +1,77 @@
+# Check whether ebuilds are not installing new, non-Gentoo-ey paths.
+
+gentoo_path_check() {
+ # allowed path definitions
+ # ------------------------
+
+ # directories common to / and /usr
+ local allowed_common_dirs=(
+ bin lib lib32 lib64 libx32 sbin
+ )
+
+ # toplevel directories which can be installed to by ebuilds
+ # /home is not included as no ebuilds should install files there
+ local allowed_paths_toplevel=(
+ "${allowed_common_dirs[@]}"
+ boot dev etc opt srv usr var
+ )
+
+ # directories in /usr which can be installed to by ebuilds
+ # /usr/games is not included as it is banned nowadays
+ local allowed_paths_usr=(
+ "${allowed_common_dirs[@]}"
+ include libexec share src
+ # toolchain stuff
+ "${CHOST}" "${CTARGET}"
+ )
+
+
+ # the logic
+ # ---------
+ local bad_paths=()
+ local x
+
+ local shopt_save=$(shopt -p nullglob)
+ shopt -s nullglob
+
+ # 1. check for unexpected top-level directories
+ local toplevel_dirs=( "${ED%/}"/* )
+ for x in "${toplevel_dirs[@]##*/}"; do
+ if ! has "${x}" "${allowed_paths_toplevel[@]}"; then
+ bad_paths+=( "/${x}" )
+ fi
+ done
+
+ # 2. check for unexpected /usr subdirectories
+ local usr_dirs=( "${ED%/}"/usr/* )
+ for x in "${usr_dirs[@]##*/}"; do
+ if ! has "${x}" "${allowed_paths_usr[@]}"; then
+ bad_paths+=( "/usr/${x}" )
+ fi
+ done
+
+ # 3. check for unexpected /usr/share/doc subdirectories
+ local doc_dirs=( "${ED%/}"/usr/share/doc/* )
+ for x in "${doc_dirs[@]##*/}"; do
+ if [[ ${x} != ${PF} ]]; then
+ bad_paths+=( "/usr/share/doc/${x}" )
+ fi
+ done
+
+ ${shopt_save}
+
+ # report
+ # ------
+ if [[ -n ${bad_paths[@]} ]]; then
+ eqawarn "The ebuild is installing to one or more unexpected paths:"
+ eqawarn
+ eqatag -v non-gentoo-paths "${bad_paths[@]}"
+ eqawarn
+ eqawarn "Please fix the ebuild to use correct FHS/Gentoo policy paths."
+ fi
+}
+
+gentoo_path_check
+: # guarantee successful exit
+
+# vim:ft=sh