From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wj0-f177.google.com (mail-wj0-f177.google.com [209.85.210.177]) by dpdk.org (Postfix) with ESMTP id 03E932A5D for ; Thu, 15 Dec 2016 00:05:35 +0100 (CET) Received: by mail-wj0-f177.google.com with SMTP id tg4so51280782wjb.1 for ; Wed, 14 Dec 2016 15:05:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=T38a3v9V4LeRtv5Isnp9G4bhQ4uElZoLShOLsy2Q7tY=; b=Y3BYhq9SUIgMfZcWSHh+HP32a5sdJWW6uSKYRXb8AKTl/0pxy2Tp9nLex+7KxHvfwr BMcGrMZdRAbvHlpgX5hd6Kdxyusi0uuCDzxuo1z/9OLVWG2jMt+85kvhEgliWjC6oCbD ByL39KUKetCNiAeLUXr7JSeCHXWkm23gLacJEfSo/MDvbJ5DCvN0W58A5XsbJUNzqji2 /2KX4aPsEALWEj2q2slUe+ipfTGBWRBvCD99pRlraGdOlGcw1Q/+Vtx0N8jWMa6gxGBM JClTrkRp867xYdASOQ7Lz4TfIU+8H8yTkOMqmwCR56tg9sAo1mMbUriZ0hAZI0ZNHkss LgHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=T38a3v9V4LeRtv5Isnp9G4bhQ4uElZoLShOLsy2Q7tY=; b=fwH8u7yhVNLg1Y1K8OsJhDrvl7QacMp0gRslRhDjW+UWQP6qsQVsw6ow3G7FIBU6To KiUqVPyqwPFINl0x+GhcFvrf0HxACO6EJWtVOj3q4opZ9KKsqLEu7UkH1YmhS58PBolW kb075Y1MtrVGC+/gdBNQOopDM7WUH/ZsJSo0LIEapdZpvYBCevSVF8h2qH/F0BiQ8g30 UOUpo6GEbndaWLkqQj4DRv308sVCcCdTksJWci+ftBAcaX3iBvruqESrVberdmEgshgH 3qQIMrof/WTSyYEW7DGa1F0qe3L96ZqLF5T+/TwMIxAmabOZqwSF5upZJ/ubiWoUiHb3 U4+Q== X-Gm-Message-State: AKaTC01GOvjEZEKcJ9z8hmYqc12fP4yd8mdqEKT7nwNzeDgmTNCtgds3WfAwEO2yRF8OkGgl X-Received: by 10.194.96.110 with SMTP id dr14mr74682366wjb.209.1481756734489; Wed, 14 Dec 2016 15:05:34 -0800 (PST) Received: from XPS13.localdomain (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id v2sm69378887wja.41.2016.12.14.15.05.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Dec 2016 15:05:33 -0800 (PST) From: Thomas Monjalon To: ci@dpdk.org Date: Thu, 15 Dec 2016 00:05:20 +0100 Message-Id: <1481756723-4868-7-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1481756723-4868-1-git-send-email-thomas.monjalon@6wind.com> References: <1480944373-10233-1-git-send-email-thomas.monjalon@6wind.com> <1481756723-4868-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-ci] [PATCH v5 6/9] tools: add patch mail download X-BeenThere: ci@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK CI discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Dec 2016 23:05:35 -0000 This script downloads a patch from patchwork with some email headers. Signed-off-by: Thomas Monjalon --- tools/{parse-email.sh => download-patch.sh} | 43 +++++++++++++---------------- tools/parse-email.sh | 2 ++ 2 files changed, 21 insertions(+), 24 deletions(-) copy tools/{parse-email.sh => download-patch.sh} (73%) diff --git a/tools/parse-email.sh b/tools/download-patch.sh similarity index 73% copy from tools/parse-email.sh copy to tools/download-patch.sh index d92c246..86d08c2 100755 --- a/tools/parse-email.sh +++ b/tools/download-patch.sh @@ -32,41 +32,36 @@ print_usage () { cat <<- END_OF_HELP - usage: $(basename $0) + usage: $(basename $0) [-g] - Parse basic headers of the email - and print them as shell variable assignments to evaluate. + Download a patch from patchwork through pwclient XML-RPC (default) + or curl HTTP GET (option -g). END_OF_HELP } -while getopts h arg ; do +. $(dirname $(readlink -e $0))/load-ci-config.sh +pwclient=${DPDK_CI_PWCLIENT:-$(dirname $(readlink -m $0))/pwclient} + +http_get=false +while getopts gh arg ; do case $arg in + g ) http_get=true ;; h ) print_usage ; exit 0 ;; ? ) print_usage >&2 ; exit 1 ;; esac done shift $(($OPTIND - 1)) -if [ -z "$1" ] ; then - printf 'file argument is missing\n\n' >&2 +pwid=$1 +if [ -z "$pwid" ] ; then + printf 'missing argument\n\n' >&2 print_usage >&2 exit 1 fi -getheader () # -{ - sed "/^$1: */!d;s///;N;s,\n[[:space:]]\+, ,;s,\n.*,,;q" "$2" | - sed 's,",\\",g' -} - -subject=$(getheader Subject "$1") -from=$(getheader From "$1") -msgid=$(getheader Message-Id "$1") -[ -n "$msgid" ] || msgid=$(getheader Message-ID "$1") -listid=$(getheader List-Id "$1") - -cat <<- END_OF_HEADERS - subject="$subject" - from="$from" - msgid="$msgid" - listid="$listid" -END_OF_HEADERS +if $http_get ; then + url="http://dpdk.org/dev/patchwork/patch/$pwid/mbox/" + curl -sf $url +else + $pwclient view $pwid +fi | +sed '/^Subject:/{s/\(\[[^],]*\)/\1] [PATCH/;s/,/ /g}' diff --git a/tools/parse-email.sh b/tools/parse-email.sh index d92c246..d997f5e 100755 --- a/tools/parse-email.sh +++ b/tools/parse-email.sh @@ -62,11 +62,13 @@ subject=$(getheader Subject "$1") from=$(getheader From "$1") msgid=$(getheader Message-Id "$1") [ -n "$msgid" ] || msgid=$(getheader Message-ID "$1") +pwid=$(getheader X-Patchwork-Id "$1") listid=$(getheader List-Id "$1") cat <<- END_OF_HEADERS subject="$subject" from="$from" msgid="$msgid" + pwid="$pwid" listid="$listid" END_OF_HEADERS -- 2.7.0