From f165e102892eedf2225c34e66db0c38d4cda9ee7 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 28 Aug 2011 18:23:54 +0200 Subject: [PATCH] Move quality-agent to pakfire. --- MANIFEST.in | 1 + macros/constants.macro | 2 +- pakfire/constants.py | 4 +- po/pakfire.pot | 2 +- setup.py | 3 + tools/quality-agent/quality-agent | 12 +++ .../quality-agent.d/001-include-files | 16 ++++ .../quality-agent.d/001-remove-info-files | 17 ++++ .../quality-agent.d/001-remove-static-libs | 24 +++++ .../quality-agent.d/001-unsafe-files | 33 +++++++ .../quality-agent.d/002-bad-symlinks | 39 ++++++++ .../quality-agent.d/003-libs-location | 23 +++++ .../quality-agent/quality-agent.d/050-canary | 28 ++++++ .../quality-agent.d/050-execstacks | 22 +++++ .../quality-agent.d/050-invalid-interpreters | 44 +++++++++ .../quality-agent.d/050-libs-needed | 31 +++++++ .../quality-agent.d/050-libs-soname | 35 ++++++++ tools/quality-agent/quality-agent.d/050-nx | 25 ++++++ tools/quality-agent/quality-agent.d/050-relro | 35 ++++++++ .../quality-agent.d/050-root-links-to-usr | 31 +++++++ .../quality-agent/quality-agent.d/050-rpaths | 36 ++++++++ .../quality-agent.d/090-man-pages | 17 ++++ .../quality-agent.d/090-python-hardlinks | 20 +++++ .../quality-agent.d/090-remove-empty-dirs | 18 ++++ .../quality-agent.d/095-directory-layout | 28 ++++++ .../quality-agent/quality-agent.d/qa-include | 90 +++++++++++++++++++ 26 files changed, 631 insertions(+), 5 deletions(-) create mode 100755 tools/quality-agent/quality-agent create mode 100755 tools/quality-agent/quality-agent.d/001-include-files create mode 100755 tools/quality-agent/quality-agent.d/001-remove-info-files create mode 100755 tools/quality-agent/quality-agent.d/001-remove-static-libs create mode 100755 tools/quality-agent/quality-agent.d/001-unsafe-files create mode 100755 tools/quality-agent/quality-agent.d/002-bad-symlinks create mode 100755 tools/quality-agent/quality-agent.d/003-libs-location create mode 100755 tools/quality-agent/quality-agent.d/050-canary create mode 100755 tools/quality-agent/quality-agent.d/050-execstacks create mode 100755 tools/quality-agent/quality-agent.d/050-invalid-interpreters create mode 100755 tools/quality-agent/quality-agent.d/050-libs-needed create mode 100755 tools/quality-agent/quality-agent.d/050-libs-soname create mode 100755 tools/quality-agent/quality-agent.d/050-nx create mode 100755 tools/quality-agent/quality-agent.d/050-relro create mode 100755 tools/quality-agent/quality-agent.d/050-root-links-to-usr create mode 100755 tools/quality-agent/quality-agent.d/050-rpaths create mode 100755 tools/quality-agent/quality-agent.d/090-man-pages create mode 100755 tools/quality-agent/quality-agent.d/090-python-hardlinks create mode 100755 tools/quality-agent/quality-agent.d/090-remove-empty-dirs create mode 100755 tools/quality-agent/quality-agent.d/095-directory-layout create mode 100644 tools/quality-agent/quality-agent.d/qa-include diff --git a/MANIFEST.in b/MANIFEST.in index 37baa0135..9e01e902c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,3 +2,4 @@ include INSTALL Makefile recursive-include examples * recursive-include po * recursive-include src *.c *.h +recursive-include tools * diff --git a/macros/constants.macro b/macros/constants.macro index c54e3c518..f354cb629 100644 --- a/macros/constants.macro +++ b/macros/constants.macro @@ -30,7 +30,7 @@ MACRO_EXTRACT = tar xvaf # Macro to define and start the quality agent. # Long term goal is to improve the commited code. -MACRO_QUALITY_AGENT = quality-agent +MACRO_QUALITY_AGENT = /usr/lib/pakfire/quality-agent # Macro to strip debugging symbols. MACRO_STRIP = /usr/lib/buildsystem-tools/stripper %{BUILDROOT} diff --git a/pakfire/constants.py b/pakfire/constants.py index 06694036d..06c3f01b6 100644 --- a/pakfire/constants.py +++ b/pakfire/constants.py @@ -25,7 +25,7 @@ from errors import * from __version__ import PAKFIRE_VERSION -PAKFIRE_LEAST_COMPATIBLE_VERSION = "0.9.5" +PAKFIRE_LEAST_COMPATIBLE_VERSION = PAKFIRE_VERSION SYSCONFDIR = "/etc" @@ -68,10 +68,8 @@ PACKAGE_FILENAME_FMT = "%(name)s-%(version)s-%(release)s.%(arch)s.%(ext)s" BUILD_PACKAGES = [ "@Build", "/bin/bash", - "build-essentials>=2:1.0-1.ip3", "gcc", "glibc-devel", - "shadow-utils>=4.1.4.3", "pakfire-build>=%s" % PAKFIRE_LEAST_COMPATIBLE_VERSION, ] SHELL_PACKAGES = ["elinks", "less", "vim",] diff --git a/po/pakfire.pot b/po/pakfire.pot index 4ff0d1ec6..349ac7171 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-08-28 14:33+0200\n" +"POT-Creation-Date: 2011-08-28 18:13+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/setup.py b/setup.py index 252b75251..af1114ac5 100644 --- a/setup.py +++ b/setup.py @@ -35,6 +35,9 @@ setup( ], data_files = [ ("lib/pakfire/macros", [os.path.join("macros", f) for f in os.listdir("macros") if f.endswith(".macro")]), + ("lib/pakfire", ["tools/quality-agent/quality-agent",]), + ("lib/quality-agent", [os.path.join("tools/quality-agent/quality-agent.d", f) \ + for f in os.listdir("tools/quality-agent/quality-agent.d")]), ], ext_modules = [ Extension("pakfire._pakfire", _pakfire_module_files, diff --git a/tools/quality-agent/quality-agent b/tools/quality-agent/quality-agent new file mode 100755 index 000000000..a83a1a375 --- /dev/null +++ b/tools/quality-agent/quality-agent @@ -0,0 +1,12 @@ +#!/bin/bash + +DIR_QA=/usr/lib/quality-agent + +failed=0 +for file in ${DIR_QA}/*; do + [ -x "${file}" ] || continue + + ${file} || failed=1 +done + +exit ${failed} diff --git a/tools/quality-agent/quality-agent.d/001-include-files b/tools/quality-agent/quality-agent.d/001-include-files new file mode 100755 index 000000000..34257e690 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/001-include-files @@ -0,0 +1,16 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Include files have to belong to the root user. \ + This script will fix this automatically." + +check() { + if [ ! -d "${BUILDROOT}/usr/include" ]; then + return 0 + fi + + chown -R root:root ${BUILDROOT}/usr/include +} + +run diff --git a/tools/quality-agent/quality-agent.d/001-remove-info-files b/tools/quality-agent/quality-agent.d/001-remove-info-files new file mode 100755 index 000000000..e742dc977 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/001-remove-info-files @@ -0,0 +1,17 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Remove documentation files." + +function check() { + for dir in ${BUILDROOT}/usr/{,share}/{doc,gtk-doc,info}; do + if [ -d "${dir}" ]; then + log DEBUG " Removing: ${dir}" + rm -rf ${dir} || exit $? + fi + done +} + +run + diff --git a/tools/quality-agent/quality-agent.d/001-remove-static-libs b/tools/quality-agent/quality-agent.d/001-remove-static-libs new file mode 100755 index 000000000..e5c6e541f --- /dev/null +++ b/tools/quality-agent/quality-agent.d/001-remove-static-libs @@ -0,0 +1,24 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Removing unwanted files: *.a *.la" + +function check() { + for file in $(find ${BUILDROOT} -name "*.a" -or -name "*.la"); do + + # Don't remove libc_nonshared.a. It is used by gcc/ld. + [ "${file##*/}" = "libc_nonshared.a" ] && continue + [ "${file##*/}" = "libpthread_nonshared.a" ] && continue + [ "${file##*/}" = "libgcc.a" ] && continue + [ "${file##*/}" = "libgcc_eh.a" ] && continue + [ "${file##*/}" = "libfl_pic.a" ] && continue + [ "${file##*/}" = "libpython2.6.a" ] && continue + + log DEBUG " Removing: ${file}" + rm -f ${file} || exit $? + done +} + +run + diff --git a/tools/quality-agent/quality-agent.d/001-unsafe-files b/tools/quality-agent/quality-agent.d/001-unsafe-files new file mode 100755 index 000000000..93a5dc8d3 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/001-unsafe-files @@ -0,0 +1,33 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Searching for world-writeable files..." + +function check() { + local ret=0 + + local files=$(find ${BUILDROOT} -type f -perm -2 2>/dev/null) + if [ -n "${files}" ]; then + log ERROR " QA Security Notice:" + log ERROR " - The folloing files will be world writable." + log ERROR " - This may or may not be a security problem, most of the time it is one." + log ERROR " - Please double check that these files really need a world writeable bit and file bugs accordingly." + log ERROR + log ERROR "${files}" + ret=1 + fi + + files=$(find ${BUILDROOT} -type f '(' -perm -2002 -o -perm -4002 ')') + if [ -n "${files}" ]; then + log ERROR " QA Notice: Unsafe files detected (set*id and world writable)" + log ERROR + log ERROR "${files}" + ret=1 + fi + + return ${ret} +} + +run + diff --git a/tools/quality-agent/quality-agent.d/002-bad-symlinks b/tools/quality-agent/quality-agent.d/002-bad-symlinks new file mode 100755 index 000000000..27e85583c --- /dev/null +++ b/tools/quality-agent/quality-agent.d/002-bad-symlinks @@ -0,0 +1,39 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +# Check for absolute symlinks. +# We do not allow them because they may point to any bad location. + +log_debug "Search for absolute symlinks" + +function check() { + local failed=0 + local item + + for link in $(find ${BUILDROOT} -type l); do + if fgrep -q "/lib/udev/devices" <<<${link}; then + continue + fi + + if listmatch "${link:${#BUILDROOT}}" ${QUALITY_AGENT_WHITELIST_SYMLINK}; then + log INFO "Symlink ${link} is on the whitelist." + continue + fi + + destination=$(readlink ${link}) + if [ "${destination:0:1}" = "/" ]; then + log ERROR " Absolute symlink: ${link}" + failed=1 + fi + if [ ! -e "${link%/*}/${destination}" ]; then + log ERROR " Not existant destination: ${link} -> ${destination}" + failed=1 + fi + done + + return ${failed} +} + +run + diff --git a/tools/quality-agent/quality-agent.d/003-libs-location b/tools/quality-agent/quality-agent.d/003-libs-location new file mode 100755 index 000000000..185f44f06 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/003-libs-location @@ -0,0 +1,23 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Checking correct installation of libraries" + +function check() { + local failed=0 + for lib in $(find ${BUILDROOT}/lib -type f -name "lib*.so.*" 2>/dev/null); do + lib=${lib##*/} + lib=${lib%%.so*} + + if [ ! -e "${BUILDROOT}/usr/lib/${lib}.so" ]; then + log ERROR " /usr/lib/${lib}.so is missing" + failed=1 + fi + done + + return ${failed} +} + +run + diff --git a/tools/quality-agent/quality-agent.d/050-canary b/tools/quality-agent/quality-agent.d/050-canary new file mode 100755 index 000000000..67b25e531 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-canary @@ -0,0 +1,28 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Every binary file has to provide a canary." + +function check() { + local failed=0 + + local file + for file in $(find_elf_files --prefix=${BUILDROOT} ${BINARY_PATHS}); do + if filter_startfiles ${file}; then + continue + fi + + if ! file_has_canary ${file}; then + log_warning " Has no canary: ${file}" + failed=1 + fi + done + + # This is currently disabled and will only return a warning ! + failed=0 + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/050-execstacks b/tools/quality-agent/quality-agent.d/050-execstacks new file mode 100755 index 000000000..9540eee55 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-execstacks @@ -0,0 +1,22 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Files with executable stacks will not work properly (or at all!) \ + on some architectures/operating systems." + +check() { + local failed=0 + + local file + for file in $(find_elf_files --prefix=${BUILDROOT} ${BINARY_PATHS}); do + if file_has_execstack ${file}; then + log_error " File has execstack: ${file}" + failed=1 + fi + done + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/050-invalid-interpreters b/tools/quality-agent/quality-agent.d/050-invalid-interpreters new file mode 100755 index 000000000..09d0ba55e --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-invalid-interpreters @@ -0,0 +1,44 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Detect invalid interpreters." + +check() { + local failed=0 + + local file + local interpreter + for file in $(find ${BUILDROOT} -type f 2>/dev/null); do + # If a file is not executeable we don't need to check it + [ -x "${file}" ] || continue + + if file_is_script ${file}; then + interpreter=$(file_get_interpreter ${file}) + + if grep -q /usr/local <<<${interpreter}; then + failed=1 + log_error " Interpreter in /usr/local: ${file}" + fi + + # Search for bad /usr/bin/env + if [ "$(basename ${interpreter})" = "env" ]; then + # Autofix that crap + sed -i ${file} \ + -e "s,/usr/bin/env python.\..,/usr/bin/python," \ + -e "s,/usr/bin/env python,/usr/bin/python," \ + -e "s,/usr/bin/env perl,/usr/bin/perl," + + # If we could not fix it, raise an error + if [ "${interpreter}" = "$(file_get_interpreter ${file})" ]; then + failed=1 + log_error " Script uses forbidden \"env\" interpreter: ${file}" + fi + fi + fi + done + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/050-libs-needed b/tools/quality-agent/quality-agent.d/050-libs-needed new file mode 100755 index 000000000..93f600dc3 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-libs-needed @@ -0,0 +1,31 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Every shared object has to provide the NEEDED entry." + +check() { + local failed=0 + + local file + local needed + for file in $(find_elf_files --prefix=${BUILDROOT} ${LIBARY_PATHS}); do + if ! file_is_shared_object ${file}; then + continue + fi + + if ! file_has_interpreter ${file}; then + continue + fi + + needed=$(file_get_needed ${file}) + if [ -z "${needed}" ]; then + log_error " File lacks needed attribute: ${file}" + failed=1 + fi + done + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/050-libs-soname b/tools/quality-agent/quality-agent.d/050-libs-soname new file mode 100755 index 000000000..b6232b644 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-libs-soname @@ -0,0 +1,35 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Every shared object has to provide the SONAME entry." + +check() { + local failed=0 + + local file + local soname + for file in $(find_elf_files --prefix=${BUILDROOT} ${LIBARY_PATHS}); do + if ! grep -q "\.so" <<<${file}; then + continue + fi + + if ! file_is_shared_object ${file}; then + continue + fi + + if ! file_has_interpreter ${file}; then + continue + fi + + soname=$(file_get_soname ${file}) + if [ -z "${soname}" ]; then + log_error " File lacks soname attribute: ${file}" + failed=1 + fi + done + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/050-nx b/tools/quality-agent/quality-agent.d/050-nx new file mode 100755 index 000000000..c9c27338d --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-nx @@ -0,0 +1,25 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +function check() { + local failed=0 + + FILTER="${QUALITY_AGENT_WHITELIST_NX}" + + local file + for file in $(find_elf_files --prefix=${BUILDROOT} ${BINARY_PATHS}); do + if filtered ${file}; then + continue + fi + + if ! file_has_nx ${file}; then + log_error " No NX: ${file}" + failed=1 + fi + done + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/050-relro b/tools/quality-agent/quality-agent.d/050-relro new file mode 100755 index 000000000..e42e8ff9c --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-relro @@ -0,0 +1,35 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Text relocations force the dynamic linker to perform extra \ + work at startup, waste system resources, and may pose a security \ + risk. On some architectures, the code may not even function \ + properly, if at all." + +function check() { + local failed=0 + + local file + for file in $(find_elf_files --prefix=${BUILDROOT} ${BINARY_PATHS}); do + if filter_startfiles ${file}; then + continue + fi + + # Skip all files that are not a shared object. + file_is_shared_object ${file} || continue + + if ! file_is_relro_full ${file}; then + if [ "${QUALITY_AGENT_PERMIT_NOT_FULL_RELRO}" = "yes" ]; then + log_warning " Is not full relro: ${file}" + else + log_error " Is not relro: ${file}" + failed=1 + fi + fi + done + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/050-root-links-to-usr b/tools/quality-agent/quality-agent.d/050-root-links-to-usr new file mode 100755 index 000000000..98385c5b8 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-root-links-to-usr @@ -0,0 +1,31 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Check for binaries in /bin or /sbin that link to /usr/..." + +function check() { + local ret=0 + + for file in $(find ${BUILDROOT}/{bin,lib,sbin}/* 2>/dev/null); do + [ -f "${file}" ] || continue + log DEBUG " ${file}" + + interpreter=$(file_get_interpreter ${file}) + if [ ! -e "${interpreter}" ]; then + log WARN " SKIPPED because interpreter is not available" + continue + fi + + libs=$(ldd ${file}) + if grep -q /usr/lib <<<${libs}; then + log ERROR "${file} links to libs in /usr/lib..." + log ERROR " ${libs}" + ret=1 + fi + done + + return ${ret} +} + +run diff --git a/tools/quality-agent/quality-agent.d/050-rpaths b/tools/quality-agent/quality-agent.d/050-rpaths new file mode 100755 index 000000000..8250612bf --- /dev/null +++ b/tools/quality-agent/quality-agent.d/050-rpaths @@ -0,0 +1,36 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Searching for RPATHs. We don't want paths that point to the tree where \ + the package was built (older, broken libtools would do this). \ + Also check for null paths because the loader will search \$PWD when it \ + finds null paths." + +check() { + local failed=0 + + local file + local rpath + for file in $(find_elf_files --prefix=${BUILDROOT} ${BINARY_PATHS}); do + if filtered ${file}; then + continue + fi + + rpath=$(file_get_rpath ${file}) + if [ -n "${rpath}" ]; then + if [ "${QUALITY_AGENT_RPATH_ALLOW_ORIGIN}" = "yes" ]; then + [ "${rpath}" = '$ORIGIN' ] && continue + fi + if listmatch ${rpath} ${QUALITY_AGENT_WHITELIST_RPATH}; then + continue + fi + log_error " File has unallowed rpath: ${file} - ${rpath}" + failed=1 + fi + done + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/090-man-pages b/tools/quality-agent/quality-agent.d/090-man-pages new file mode 100755 index 000000000..0720d100e --- /dev/null +++ b/tools/quality-agent/quality-agent.d/090-man-pages @@ -0,0 +1,17 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Decompressing man-pages..." + +function check() { + for file in $(find ${BUILDROOT}/usr/share/man -type f 2>/dev/null); do + log DEBUG " Processing: ${file}" + if [[ ${file} =~ \.gz$ ]]; then + gzip -d ${file} + fi + done +} + +run + diff --git a/tools/quality-agent/quality-agent.d/090-python-hardlinks b/tools/quality-agent/quality-agent.d/090-python-hardlinks new file mode 100755 index 000000000..e2abf76a9 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/090-python-hardlinks @@ -0,0 +1,20 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Python byte-code files could be hardlinked if the optimized one is equal" +DESC="${DESC} to the other one." + +function check() { + for py in $(find ${BUILDROOT} -type f -name "*.py"); do + if [ -e "${py}c" ] && [ -e "${py}o" ]; then + if cmp -s "${py}c" "${py}o"; then + log DEBUG " ${py}c -> ${py}o" + ln -f "${py}c" "${py}o" + fi + fi + done +} + +run + diff --git a/tools/quality-agent/quality-agent.d/090-remove-empty-dirs b/tools/quality-agent/quality-agent.d/090-remove-empty-dirs new file mode 100755 index 000000000..d1d61a195 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/090-remove-empty-dirs @@ -0,0 +1,18 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="Remove unwanted files." + +function check() { + for dir in $(sort_by_length {,/usr}/{{,s}bin,lib{,exec}} /usr/share/man{,/man{0,1,2,3,4,5,6,7,8,9}}); do + dir="${BUILDROOT}/${dir}" + if [ -d "${dir}" ] && [ "$(ls -1A ${dir} | wc -l)" = "0" ]; then + log DEBUG " Removing ${dir}" + rm -rf ${dir} + fi + done +} + +run + diff --git a/tools/quality-agent/quality-agent.d/095-directory-layout b/tools/quality-agent/quality-agent.d/095-directory-layout new file mode 100755 index 000000000..3f946a186 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/095-directory-layout @@ -0,0 +1,28 @@ +#!/bin/bash + +. $(dirname ${0})/qa-include + +DESC="The filelayout should comply to the FHS." + +DIRS="/etc/init.d /etc/rc.d /lib/pkgconfig /usr/etc /usr/libexec /usr/local /usr/man /usr/usr /usr/var" + +function check() { + # Do nothing, if directory check was disabled. + if [ "${QUALITY_AGENT_NO_DIRECTORY_CHECK}" = "yes" ]; then + return 0 + fi + + local failed=0 + + local dir + for dir in ${DIRS}; do + if [ -d "${BUILDROOT}${dir}" ]; then + log_error "Bad directory: ${dir}" + failed=1 + fi + done + + return ${failed} +} + +run diff --git a/tools/quality-agent/quality-agent.d/qa-include b/tools/quality-agent/quality-agent.d/qa-include new file mode 100644 index 000000000..284673388 --- /dev/null +++ b/tools/quality-agent/quality-agent.d/qa-include @@ -0,0 +1,90 @@ +#!/bin/bash + +# Include additional functions +. /usr/lib/buildsystem-tools/common-functions + +function debug() { + [ "${NAOKI_DEBUG}" = "1" ] || [ "${DEBUG}" = "1" ] +} + +#function log() { +# local facility=${1} +# shift +# +# printf " %-7s %s\n" "${facility}" "$@" +#} + +function log_debug() { + debug && log DEBUG "$@" +} + +function log_error() { + log "ERROR" "$@" +} + +function log_info() { + log "INFO" "$@" +} + +function log_warning() { + log "WARNING" "$@" +} + +if [ -z "${BUILDROOT}" ]; then + echo "${0##*/}: ERROR: BUILDROOT is not set." >&2 + exit 1 +fi + +function filtered() { + [ -z "${FILTER}" ] && return 1 + grep -qE ${FILTER} <<<$@ +} + +function print_description() { + # Remove all whitespaces + local desc=$(echo ${DESC}) + + log_info "Check: $(basename ${0})" + IFS=' +' + for line in $(fold -s -w 60 <<<${desc}); do + log_info " ${line}" + done + log_info # Empty line + + unset IFS +} + +function qa_find() { + local filetype=${1} + local command=${2} + + log_debug "Running qa_find with command ${command} in ${filetype}" + + local file + for file in $(find_elf_files --prefix=${BUILDROOT} ${!filetype}); do + ${command} ${file} + done +} + +function check() { + log_error "REPLACE THIS FUNCTION BY A CUSTOM CHECK" + return 1 +} + +function run() { + local error_message + local ret + + error_message=$(check) + ret=$? + + [ -z "${error_message}" ] && \ + [ "${ret}" = "0" ] && return 0 + + print_description + + echo "${error_message}" + return ${ret} +} + -- 2.39.5