1 |
The eqatag command syntax conforms to pre-GLEP describing |
2 |
install-qa-check.d. The qa.log file format strictly conforms to YAML for |
3 |
easy machine parsing. |
4 |
--- |
5 |
bin/isolated-functions.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++ |
6 |
bin/misc-functions.sh | 4 +++ |
7 |
bin/save-ebuild-env.sh | 2 +- |
8 |
3 files changed, 73 insertions(+), 1 deletion(-) |
9 |
|
10 |
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh |
11 |
index 4992d77..f03503b 100644 |
12 |
--- a/bin/isolated-functions.sh |
13 |
+++ b/bin/isolated-functions.sh |
14 |
@@ -505,4 +505,72 @@ __repo_attr() { |
15 |
return ${exit_status} |
16 |
} |
17 |
|
18 |
+# eqaquote <string> |
19 |
+# |
20 |
+# outputs parameter escaped for quoting |
21 |
+__eqaquote() { |
22 |
+ local v=${1} esc='' |
23 |
+ |
24 |
+ # quote backslashes |
25 |
+ v=${v//\\/\\\\} |
26 |
+ # quote the quotes |
27 |
+ v=${v//\"/\\\"} |
28 |
+ # quote newlines |
29 |
+ while read -r; do |
30 |
+ echo -n "${esc}${REPLY}" |
31 |
+ esc='\n' |
32 |
+ done <<<"${v}" |
33 |
+} |
34 |
+ |
35 |
+# eqatag <tag> [-v] [<key>=<value>...] [/<relative-path>...] |
36 |
+# |
37 |
+# output (to qa.log): |
38 |
+# - tag: <tag> |
39 |
+# data: |
40 |
+# <key1>: "<value1>" |
41 |
+# <key2>: "<value2>" |
42 |
+# files: |
43 |
+# - "<path1>" |
44 |
+# - "<path2>" |
45 |
+__eqatag() { |
46 |
+ local tag i filenames=() data=() verbose= |
47 |
+ |
48 |
+ if [[ ${1} == -v ]]; then |
49 |
+ verbose=1 |
50 |
+ shift |
51 |
+ fi |
52 |
+ |
53 |
+ tag=${1} |
54 |
+ shift |
55 |
+ [[ -n ${tag} ]] || die "${FUNCNAME}: no tag specified" |
56 |
+ |
57 |
+ # collect data & filenames |
58 |
+ for i; do |
59 |
+ if [[ ${i} == /* ]]; then |
60 |
+ filenames+=( "${i}" ) |
61 |
+ [[ -n ${verbose} ]] && eqawarn " ${i}" |
62 |
+ elif [[ ${i} == *=* ]]; then |
63 |
+ data+=( "${i}" ) |
64 |
+ else |
65 |
+ die "${FUNCNAME}: invalid parameter: ${i}" |
66 |
+ fi |
67 |
+ done |
68 |
+ |
69 |
+ ( |
70 |
+ echo "- tag: ${tag}" |
71 |
+ if [[ ${data[@]} ]]; then |
72 |
+ echo " data:" |
73 |
+ for i in "${data[@]}"; do |
74 |
+ echo " ${i%%=*}: \"$(__eqaquote "${i#*=}")\"" |
75 |
+ done |
76 |
+ fi |
77 |
+ if [[ ${filenames[@]} ]]; then |
78 |
+ echo " files:" |
79 |
+ for i in "${filenames[@]}"; do |
80 |
+ echo " - \"$(__eqaquote "${i}")\"" |
81 |
+ done |
82 |
+ fi |
83 |
+ ) >> "${T}"/qa.log |
84 |
+} |
85 |
+ |
86 |
true |
87 |
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh |
88 |
index cc652a9..6e6fcb4 100755 |
89 |
--- a/bin/misc-functions.sh |
90 |
+++ b/bin/misc-functions.sh |
91 |
@@ -551,6 +551,10 @@ install_hooks() { |
92 |
return $ret |
93 |
} |
94 |
|
95 |
+eqatag() { |
96 |
+ __eqatag "${@}" |
97 |
+} |
98 |
+ |
99 |
if [ -n "${MISC_FUNCTIONS_ARGS}" ]; then |
100 |
__source_all_bashrcs |
101 |
[ "$PORTAGE_DEBUG" == "1" ] && set -x |
102 |
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh |
103 |
index dd233a9..eb83dca 100644 |
104 |
--- a/bin/save-ebuild-env.sh |
105 |
+++ b/bin/save-ebuild-env.sh |
106 |
@@ -76,7 +76,7 @@ __save_ebuild_env() { |
107 |
__ebuild_arg_to_phase __ebuild_phase_funcs default \ |
108 |
__unpack_tar __unset_colors \ |
109 |
__source_env_files __try_source \ |
110 |
- __eqalog __eqawarnlog \ |
111 |
+ __eqalog __eqawarnlog __eqatag \ |
112 |
${QA_INTERCEPTORS} |
113 |
|
114 |
___eapi_has_usex && unset -f usex |
115 |
-- |
116 |
2.1.3 |