From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 29AC5138AD0 for ; Wed, 19 Nov 2014 23:26:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B4FE3E0922; Wed, 19 Nov 2014 23:26:47 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 369F3E0922 for ; Wed, 19 Nov 2014 23:26:47 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2EA573404E6 for ; Wed, 19 Nov 2014 23:26:46 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C8C15A7DE for ; Wed, 19 Nov 2014 23:26:44 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1416439594.ad57b64a366f2d182f442035e0ba3f6f667c40bc.mgorny@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/isolated-functions.sh bin/misc-functions.sh bin/save-ebuild-env.sh X-VCS-Directories: bin/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: ad57b64a366f2d182f442035e0ba3f6f667c40bc X-VCS-Branch: master Date: Wed, 19 Nov 2014 23:26:44 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: c1e11590-28ee-4a5f-b113-92af846f8740 X-Archives-Hash: de63e70c796435035635a01f10f4cd92 commit: ad57b64a366f2d182f442035e0ba3f6f667c40bc Author: Michał Górny gentoo org> AuthorDate: Sun Nov 2 18:49:40 2014 +0000 Commit: Michał Górny gentoo org> CommitDate: Wed Nov 19 23:26:34 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ad57b64a Introduce eqatag to output proper machine-readable QA logs 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 +# +# 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 [-v] [=...] [/...] +# +# output (to qa.log): +# - tag: +# data: +# : "" +# : "" +# files: +# - "" +# - "" +__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..b483d40 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 __eqaquote __eqatag \ ${QA_INTERCEPTORS} ___eapi_has_usex && unset -f usex