public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs
@ 2014-11-02 19:18 Michał Górny
  2014-11-02 19:18 ` [gentoo-portage-dev] [PATCH 2/3] Update the QA checks to new eqatag API Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michał Górny @ 2014-11-02 19:18 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

The eqatag command syntax conforms to pre-GLEP describing
install-qa-check.d. The qa.log file format strictly conforms to YAML for
easy machine parsing.
---
 bin/isolated-functions.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++
 bin/misc-functions.sh     |  4 +++
 bin/save-ebuild-env.sh    |  2 +-
 3 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 4992d77..f03503b 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -505,4 +505,72 @@ __repo_attr() {
 	return ${exit_status}
 }
 
+# eqaquote <string>
+#
+# outputs parameter escaped for quoting
+__eqaquote() {
+	local v=${1} esc=''
+
+	# quote backslashes
+	v=${v//\\/\\\\}
+	# quote the quotes
+	v=${v//\"/\\\"}
+	# quote newlines
+	while read -r; do
+		echo -n "${esc}${REPLY}"
+		esc='\n'
+	done <<<"${v}"
+}
+
+# eqatag <tag> [-v] [<key>=<value>...] [/<relative-path>...]
+#
+# output (to qa.log):
+# - tag: <tag>
+#   data:
+#     <key1>: "<value1>"
+#     <key2>: "<value2>"
+#   files:
+#     - "<path1>"
+#     - "<path2>"
+__eqatag() {
+	local tag i filenames=() data=() verbose=
+
+	if [[ ${1} == -v ]]; then
+		verbose=1
+		shift
+	fi
+
+	tag=${1}
+	shift
+	[[ -n ${tag} ]] || die "${FUNCNAME}: no tag specified"
+
+	# collect data & filenames
+	for i; do
+		if [[ ${i} == /* ]]; then
+			filenames+=( "${i}" )
+			[[ -n ${verbose} ]] && eqawarn "  ${i}"
+		elif [[ ${i} == *=* ]]; then
+			data+=( "${i}" )
+		else
+			die "${FUNCNAME}: invalid parameter: ${i}"
+		fi
+	done
+
+	(
+		echo "- tag: ${tag}"
+		if [[ ${data[@]} ]]; then
+			echo "  data:"
+			for i in "${data[@]}"; do
+				echo "    ${i%%=*}: \"$(__eqaquote "${i#*=}")\""
+			done
+		fi
+		if [[ ${filenames[@]} ]]; then
+			echo "  files:"
+			for i in "${filenames[@]}"; do
+				echo "    - \"$(__eqaquote "${i}")\""
+			done
+		fi
+	) >> "${T}"/qa.log
+}
+
 true
diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
index cc652a9..6e6fcb4 100755
--- a/bin/misc-functions.sh
+++ b/bin/misc-functions.sh
@@ -551,6 +551,10 @@ install_hooks() {
 	return $ret
 }
 
+eqatag() {
+	__eqatag "${@}"
+}
+
 if [ -n "${MISC_FUNCTIONS_ARGS}" ]; then
 	__source_all_bashrcs
 	[ "$PORTAGE_DEBUG" == "1" ] && set -x
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index dd233a9..eb83dca 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -76,7 +76,7 @@ __save_ebuild_env() {
 		__ebuild_arg_to_phase __ebuild_phase_funcs default \
 		__unpack_tar __unset_colors \
 		__source_env_files __try_source \
-		__eqalog __eqawarnlog \
+		__eqalog __eqawarnlog __eqatag \
 		${QA_INTERCEPTORS}
 
 	___eapi_has_usex && unset -f usex
-- 
2.1.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-portage-dev] [PATCH 2/3] Update the QA checks to new eqatag API
  2014-11-02 19:18 [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs Michał Górny
@ 2014-11-02 19:18 ` Michał Górny
  2014-11-02 19:18 ` [gentoo-portage-dev] [PATCH 3/3] Remove __eqalog & __eqawarnlog Michał Górny
  2014-11-03  0:05 ` [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs Zac Medico
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2014-11-02 19:18 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

---
 bin/install-qa-check.d/05double-D       | 8 ++++----
 bin/install-qa-check.d/90world-writable | 4 +---
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/bin/install-qa-check.d/05double-D b/bin/install-qa-check.d/05double-D
index 7d958f1..4b7737c 100644
--- a/bin/install-qa-check.d/05double-D
+++ b/bin/install-qa-check.d/05double-D
@@ -3,12 +3,12 @@
 DD_check() {
 	if [[ -d ${D%/}${D} ]] ; then
 		eqawarn "QA Notice: files installed in \${D}/\${D}:"
-		local -i INSTALLTOD=0
+		local files=()
 		while read -r -d $'\0' i ; do
-			__eqawarnlog double-d "/${i##${D%/}${D}}"
-			((INSTALLTOD++))
+			files+=( "${i#${D%/}${D}}" )
 		done < <(find "${D%/}${D}" -print0)
-		die "Aborting due to QA concerns: ${INSTALLTOD} files installed in ${D%/}${D}"
+		eqatag -v double-D "${files[@]/#//}"
+		die "Aborting due to QA concerns: ${#files[@]} files installed in ${D%/}${D}"
 	fi
 }
 
diff --git a/bin/install-qa-check.d/90world-writable b/bin/install-qa-check.d/90world-writable
index 490aaee..2b435ac 100644
--- a/bin/install-qa-check.d/90world-writable
+++ b/bin/install-qa-check.d/90world-writable
@@ -12,9 +12,7 @@ world_writable_check() {
 	if [[ -n ${unsafe_files} ]] ; then
 		eqawarn "QA Security Notice: world writable file(s):"
 
-		for x in $unsafe_files ; do
-			__eqawarnlog world-writable "$x"
-		done
+		eqatag -v world-writable $unsafe_files
 
 		eqawarn "This may or may not be a security problem, most of the time it is one."
 		eqawarn "Please double check that $PF really needs a world writeable bit and file bugs accordingly."
-- 
2.1.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-portage-dev] [PATCH 3/3] Remove __eqalog & __eqawarnlog
  2014-11-02 19:18 [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs Michał Górny
  2014-11-02 19:18 ` [gentoo-portage-dev] [PATCH 2/3] Update the QA checks to new eqatag API Michał Górny
@ 2014-11-02 19:18 ` Michał Górny
  2014-11-03  0:05 ` [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs Zac Medico
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2014-11-02 19:18 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

Replaced by eqatag.
---
 bin/isolated-functions.sh | 23 -----------------------
 bin/save-ebuild-env.sh    |  2 +-
 2 files changed, 1 insertion(+), 24 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index f03503b..42bf05d 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -256,29 +256,6 @@ __elog_base() {
 	return 0
 }
 
-__eqalog() {
-	local tag=$1 x
-	shift
-	for x in "$@" ; do
-		echo "${tag}" "${x}"| (
-			escape=""
-			while read -r ; do
-				echo -n "${escape}${REPLY}"
-				escape="\\n"
-			done
-			echo
-		) >> "${T}"/qa.log
-	done
-}
-
-__eqawarnlog() {
-	__eqalog "$@"
-	shift
-	for x in "$@" ; do
-		eqawarn "  ${x}"
-	done
-}
-
 eqawarn() {
 	__elog_base QA "$*"
 	[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh
index eb83dca..13c9fc0 100644
--- a/bin/save-ebuild-env.sh
+++ b/bin/save-ebuild-env.sh
@@ -76,7 +76,7 @@ __save_ebuild_env() {
 		__ebuild_arg_to_phase __ebuild_phase_funcs default \
 		__unpack_tar __unset_colors \
 		__source_env_files __try_source \
-		__eqalog __eqawarnlog __eqatag \
+		__eqatag \
 		${QA_INTERCEPTORS}
 
 	___eapi_has_usex && unset -f usex
-- 
2.1.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs
  2014-11-02 19:18 [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs Michał Górny
  2014-11-02 19:18 ` [gentoo-portage-dev] [PATCH 2/3] Update the QA checks to new eqatag API Michał Górny
  2014-11-02 19:18 ` [gentoo-portage-dev] [PATCH 3/3] Remove __eqalog & __eqawarnlog Michał Górny
@ 2014-11-03  0:05 ` Zac Medico
  2 siblings, 0 replies; 4+ messages in thread
From: Zac Medico @ 2014-11-03  0:05 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Michał Górny

On 11/02/2014 11:18 AM, Michał Górny wrote:
> The eqatag command syntax conforms to pre-GLEP describing
> install-qa-check.d. The qa.log file format strictly conforms to YAML for
> easy machine parsing.

The whole series looks good to me.
-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-03  0:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-02 19:18 [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs Michał Górny
2014-11-02 19:18 ` [gentoo-portage-dev] [PATCH 2/3] Update the QA checks to new eqatag API Michał Górny
2014-11-02 19:18 ` [gentoo-portage-dev] [PATCH 3/3] Remove __eqalog & __eqawarnlog Michał Górny
2014-11-03  0:05 ` [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox