[pacman-dev] [PATCH 3/3] libmakepkg: make package checking functions extendable
Allan McRae
allan at archlinux.org
Sun Feb 1 12:34:29 UTC 2015
To add a new package check, drop a file in libmakepkg/lint and add the
function to the "lint_functions" array.
Signed-off-by: Allan McRae <allan at archlinux.org>
---
scripts/libmakepkg/lint.sh.in | 11 +++++++++--
scripts/libmakepkg/lint/build_references.sh.in | 2 ++
scripts/libmakepkg/lint/missing_backup.sh.in | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/scripts/libmakepkg/lint.sh.in b/scripts/libmakepkg/lint.sh.in
index 2e3c7f6..9c9535e 100644
--- a/scripts/libmakepkg/lint.sh.in
+++ b/scripts/libmakepkg/lint.sh.in
@@ -25,14 +25,21 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
+
+declare -a lint_functions
+
for lib in "$LIBRARY/lint/"*.sh; do
source "$lib"
done
+readonly -a lint_functions
+
+
lint_package() {
cd_safe "$pkgdir"
msg "$(gettext "Checking for packaging issue...")"
- warn_missing_backup
- warn_build_references
+ for func in lint_functions; do
+ $func
+ done
}
diff --git a/scripts/libmakepkg/lint/build_references.sh.in b/scripts/libmakepkg/lint/build_references.sh.in
index 9cf7b7a..9fd71ee 100644
--- a/scripts/libmakepkg/lint/build_references.sh.in
+++ b/scripts/libmakepkg/lint/build_references.sh.in
@@ -26,6 +26,8 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
+lint_functions+=('warn_build_references')
+
warn_build_references() {
if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
warning "$(gettext "Package contains reference to %s")" "\$srcdir"
diff --git a/scripts/libmakepkg/lint/missing_backup.sh.in b/scripts/libmakepkg/lint/missing_backup.sh.in
index b54f2ab..85725c7 100644
--- a/scripts/libmakepkg/lint/missing_backup.sh.in
+++ b/scripts/libmakepkg/lint/missing_backup.sh.in
@@ -26,6 +26,8 @@ LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
source "$LIBRARY/util/message.sh"
+lint_functions+=('warn_missing_backup')
+
warn_missing_backup() {
local file
for file in "${backup[@]}"; do
--
2.2.2
More information about the pacman-dev
mailing list