]> git.ipfire.org Git - people/stevee/pakfire.git/blob - src/quality-agent/qa-include
Use autotools.
[people/stevee/pakfire.git] / src / quality-agent / qa-include
1 #!/bin/bash
2
3 # Include additional functions
4 . /usr/lib/pakfire/functions-common
5
6 function debug() {
7 [ "${NAOKI_DEBUG}" = "1" ] || [ "${DEBUG}" = "1" ]
8 }
9
10 #function log() {
11 # local facility=${1}
12 # shift
13 #
14 # printf " %-7s %s\n" "${facility}" "$@"
15 #}
16
17 function log_debug() {
18 debug && log DEBUG "$@"
19 }
20
21 function log_error() {
22 log "ERROR" "$@"
23 }
24
25 function log_info() {
26 log "INFO" "$@"
27 }
28
29 function log_warning() {
30 log "WARNING" "$@"
31 }
32
33 if [ -z "${BUILDROOT}" ]; then
34 echo "${0##*/}: ERROR: BUILDROOT is not set." >&2
35 exit 1
36 fi
37
38 function filtered() {
39 [ -z "${FILTER}" ] && return 1
40 grep -qE ${FILTER} <<<$@
41 }
42
43 function print_description() {
44 # Remove all whitespaces
45 local desc=$(echo ${DESC})
46
47 log_info "Check: $(basename ${0})"
48 IFS='
49 '
50 for line in $(fold -s -w 60 <<<${desc}); do
51 log_info " ${line}"
52 done
53 log_info # Empty line
54
55 unset IFS
56 }
57
58 function qa_find() {
59 local filetype=${1}
60 local command=${2}
61
62 log_debug "Running qa_find with command ${command} in ${filetype}"
63
64 local file
65 for file in $(find_elf_files --prefix=${BUILDROOT} ${!filetype}); do
66 ${command} ${file}
67 done
68 }
69
70 function check() {
71 log_error "REPLACE THIS FUNCTION BY A CUSTOM CHECK"
72 return 1
73 }
74
75 function run() {
76 local error_message
77 local ret
78
79 error_message=$(check)
80 ret=$?
81
82 [ -z "${error_message}" ] && \
83 [ "${ret}" = "0" ] && return 0
84
85 print_description
86
87 echo "${error_message}"
88 return ${ret}
89 }
90