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 90AE4138BA7 for ; Sun, 2 Nov 2014 19:18:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BE992E08A8; Sun, 2 Nov 2014 19:18:28 +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 465E7E0897 for ; Sun, 2 Nov 2014 19:18:28 +0000 (UTC) Received: from pomiot.lan (mgorny-1-pt.tunnel.tserv28.waw1.ipv6.he.net [IPv6:2001:470:70:353::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 8A5C634048A; Sun, 2 Nov 2014 19:18:24 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-portage-dev] [PATCH 1/3] Introduce eqatag to output proper machine-readable QA logs Date: Sun, 2 Nov 2014 20:18:18 +0100 Message-Id: <1414955900-32567-1-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 2.1.3 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 94fda6dc-5d60-4819-8ede-5b8cddacdfa0 X-Archives-Hash: 0b6add379947eace79c371a30dd51d36 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..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