From patchwork Tue May 3 05:48:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongqin Liu X-Patchwork-Id: 67057 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp412794qge; Mon, 2 May 2016 22:50:54 -0700 (PDT) X-Received: by 10.98.20.197 with SMTP id 188mr824070pfu.144.1462254654775; Mon, 02 May 2016 22:50:54 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bp3si2523320pab.59.2016.05.02.22.50.54; Mon, 02 May 2016 22:50:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932415AbcECFup (ORCPT + 1 other); Tue, 3 May 2016 01:50:45 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:33461 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932344AbcECFua (ORCPT ); Tue, 3 May 2016 01:50:30 -0400 Received: by mail-pa0-f52.google.com with SMTP id xk12so5237447pac.0 for ; Mon, 02 May 2016 22:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=12sgaESnv8y9mqQURweYW4nUma02bb59c3xDKYke8Ks=; b=A9GFtDKqg2uCEnUoUozAa2XDFLWj7VYP1Asp4evPlKr1YmtpbHIjrn1a2R3jLHebF7 FvVQDIN/kEzlk82wf1W06JRcb3eJCgDJmp9b0lI11nPsH1iZLBZAFcxb7ZLHqFAKLbLa kMwImS28fv+8FYEBYF7OxtEMA6GykZpsJg7kk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=12sgaESnv8y9mqQURweYW4nUma02bb59c3xDKYke8Ks=; b=ajdlXNTKpsVf6ErAK9G/McdSkI1un3K95dLAxCcPkDswfje5Gk2mbC4V6mrBqHaov8 d/vPE1mnaKYDtNTcTY08hLy9GdAUFcLz2zu1aHuij/HMIkA7DyRwOjbho/ILPv39gdO4 pIsneicYVa6u+z6Kp5EeWH+MT3UmwCS1LGu9IoE1Hujou0kZCRuxZhGSZZMEOK8oqinF CXIt+MB5s2DDX7hxVh8eyGRZkHab6ZdP7pD1WKjUejcfXlxihlHSUMI6KgW6jJ6klkZO UiJ5U2RKWNmSaFPht6MnEl20BhqNMANv2Cmemdd1yNS0KWigB+aJ2ScErDsOOYFvsVIE e96Q== X-Gm-Message-State: AOPr4FV3eJAzqhu+l/R38wQJ3/yscsbR3Fyw1mIpdFfVGViSoiYI88gj2dHctnaljxGVafC3 X-Received: by 10.66.63.104 with SMTP id f8mr749885pas.109.1462254629953; Mon, 02 May 2016 22:50:29 -0700 (PDT) Received: from localhost.localdomain ([104.237.91.97]) by smtp.gmail.com with ESMTPSA id lg8sm2219082pab.48.2016.05.02.22.50.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 May 2016 22:50:28 -0700 (PDT) From: Yongqin Liu To: linux-wireless@vger.kernel.org Cc: johannes.berg@intel.com, filbranden@google.com, Yongqin Liu Subject: [PATCH 1/1] version.sh: update to get version with git correctly Date: Tue, 3 May 2016 13:48:48 +0800 Message-Id: <1462254528-15911-1-git-send-email-yongqin.liu@linaro.org> X-Mailer: git-send-email 2.1.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org update to get the version information from the git repository where this file is located instead of the the current directory where it is executed, otherwise if there is .git directory in the current directory, it will get the wrong version information. And improved the version check since the tag information may not be mirrored like what AOSP does now. Change-Id: I321113b74bf2a955c202f47dca68c1183ca55318 Signed-off-by: Yongqin Liu --- version.sh | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/version.sh b/version.sh index 7ccd419..c8111a6 100755 --- a/version.sh +++ b/version.sh @@ -3,20 +3,38 @@ VERSION="4.3" OUT="$1" -if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then - git update-index --refresh --unmerged > /dev/null - descr=$(git describe --match=v*) +# get the absolute path for the OUT file +OUT_NAME=$(basename ${OUT}) +OUT_DIR=$(cd $(dirname ${OUT}); pwd) +OUT="${OUT_DIR}/${OUT_NAME}" + +# the version check should be under the source directory +# where this script is located, instead of the currect directory +# where this script is excuted. +SRC_DIR=$(dirname $0) +SRC_DIR=$(cd ${SRC_DIR}; pwd) +cd "${SRC_DIR}" - # on git builds check that the version number above - # is correct... - [ "${descr%%-*}" = "v$VERSION" ] || exit 2 +v="" +if [ -d .git ] && head=`git rev-parse --verify HEAD 2>/dev/null`; then + git update-index --refresh --unmerged > /dev/null + descr=$(git describe --match=v* 2>/dev/null) + if [ $? -eq 0 ]; then + # on git builds check that the version number above + # is correct... + if [ "${descr%%-*}" = "v$VERSION" ]; then + v="${descr#v}" + if git diff-index --name-only HEAD | read dummy ; then + v="$v"-dirty + fi + fi + fi +fi - v="${descr#v}" - if git diff-index --name-only HEAD | read dummy ; then - v="$v"-dirty - fi -else - v="$VERSION" +# set to the default version when failed to get the version +# information with git +if [ -z "${v}" ]; then + v="$VERSION" fi echo '#include "iw.h"' > "$OUT"