Gentoo Archives: gentoo-portage-dev

From: Michael Palimaka <kensington@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Michael Palimaka <kensington@g.o>
Subject: [gentoo-portage-dev] [PATCH 1/3] Introduce eqalog and eqawarnlog functions.
Date: Sun, 26 Oct 2014 15:12:52
Message-Id: 1414336328-15513-1-git-send-email-kensington@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 1/3] bin/misc-functions.sh: Introduce eqalog and eqawarnlog functions. by Michael Palimaka
1 These functions are to be used for creating a log of QA violations in a
2 machine-readable format.
3
4 Stored in ${T]/qa.log, the log consists of one entry per line in the
5 following format: violation-tag data
6
7 For example:
8 deprecated-directory /usr/man
9 deprecated-directory /usr/info
10 world-writable /var/db/foo/bar
11 ---
12 bin/isolated-functions.sh | 16 ++++++++++++++++
13 bin/save-ebuild-env.sh | 1 +
14 2 files changed, 17 insertions(+)
15
16 diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
17 index a22af57..ad44e2a 100644
18 --- a/bin/isolated-functions.sh
19 +++ b/bin/isolated-functions.sh
20 @@ -256,6 +256,22 @@ __elog_base() {
21 return 0
22 }
23
24 +__eqalog() {
25 + local tag=$1 x
26 + shift
27 + for x in "$@" ; do
28 + echo "${tag}" "${x}"| (escape="" ; while read -r ; do echo -n "${escape}${REPLY}" ; escape="\\n"; done ; echo ) >> "${T}"/qa.log
29 + done
30 +}
31 +
32 +__eqawarnlog() {
33 + __eqalog "$@"
34 + shift
35 + for x in "$@" ; do
36 + eqawarn " ${x}"
37 + done
38 +}
39 +
40 eqawarn() {
41 __elog_base QA "$*"
42 [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo
43 diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
44 index 775c02c..dd233a9 100644
45 --- a/bin/save-ebuild-env.sh
46 +++ b/bin/save-ebuild-env.sh
47 @@ -76,6 +76,7 @@ __save_ebuild_env() {
48 __ebuild_arg_to_phase __ebuild_phase_funcs default \
49 __unpack_tar __unset_colors \
50 __source_env_files __try_source \
51 + __eqalog __eqawarnlog \
52 ${QA_INTERCEPTORS}
53
54 ___eapi_has_usex && unset -f usex
55 --
56 2.0.4