[Lunar-commits] <lunar> New global plugin: Sanity checks.
Auke Kok
sofar at foo-projects.org
Mon Jul 2 06:09:13 CEST 2012
commit 433be9355444ed77d94e1ad0ff5f5c8e5a3b81bd
Author: Auke Kok <sofar at foo-projects.org>
Date: Sun Jul 1 21:09:13 2012 -0700
New global plugin: Sanity checks.
This plugin contains a few very, very basic checks that all
packages should pass. There are 2 levels of checks:
'W' checks - may fail but need acknowledgement from the SA
'E' checks - cause a build failure
The logic behind this patch is to force developers to fix really,
really bad packages and stop violating package rules, which we
continuously see happening (/opt being the worst).
Auke
---
plugins/postbuild-sanity.plugin | 66 +++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
diff --git a/plugins/postbuild-sanity.plugin b/plugins/postbuild-sanity.plugin
new file mode 100644
index 0000000..d66256d
--- /dev/null
+++ b/plugins/postbuild-sanity.plugin
@@ -0,0 +1,66 @@
+#!/bin/bash
+#############################################################
+# #
+# postbuild-sanity.plugin - postbuild running of sanity #
+# checks on installed files #
+# #
+#############################################################
+# #
+# Copyright 2012 by Auke Kok under GPLv2 #
+# #
+#############################################################
+
+
+plugin_sanity_post_build()
+{
+ (
+ local TESTS PATTERN SEVERITY REASON
+
+ IFS=$'\n'
+
+ TESTS=(
+ "^/opt/:E:Installs files in /opt"
+ "^/bin:W:Installs files in /bin"
+ "^/sbin:W:Installs files in /sbin"
+ "^/lib:W:Installs files in /lib"
+ "^/share:E:Installs files in /share"
+ "^/include:E:Installs files in /include"
+ "^/usr/etc:E:Installs files in /usr/etc"
+ "^/usr/local:E:Installs files in /usr/local"
+ "^/usr/var:E:Installs files in /usr/var"
+ "^/home:E:Installs files in /home"
+ "^/root:E:Installs files in /root"
+ )
+
+ for TEST in ${TESTS[@]} ; do
+ PATTERN=$(echo $TEST | cut -d: -f1)
+
+ parse_iw | grep -q $PATTERN
+ if [ $? == 0 ]; then
+ SEVERITY=$(echo $TEST | cut -d: -f2)
+ REASON=$(echo $TEST | cut -d: -f3)
+
+ if [ $SEVERITY == "W" ]; then
+ message "${PROBLEM_COLOR}WARNING:${DEFAULT_COLOR}${MESSAGE_COLOR} Package installs files in incorrect locations!${DEFAULT_COLOR}"
+ parse_iw | sort | uniq | grep $PATTERN
+ export SILENT=""
+ query "Ignore this warning" "y"
+ if [ $? != 0 ]; then
+ return 1
+ fi
+ continue
+ else
+ message "${PROBLEM_COLOR}ERROR:${DEFAULT_COLOR}${MESSAGE_COLOR} Package installs files in incorrect locations!${DEFAULT_COLOR}"
+ parse_iw | sort | uniq | grep $PATTERN
+ return 1
+ fi
+ fi
+ done
+
+ # return 2, on success for other plugins
+ return 2
+ )
+}
+
+
+plugin_register BUILD_POST_BUILD plugin_sanity_post_build
More information about the Lunar-commits
mailing list