From nobody Sat May 18 03:46:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1602089004; cv=none; d=zohomail.com; s=zohoarc; b=G+vf8+8059XsJrFqB+1FLAapGhx7uOTCY2S6U3uoiVQ8a1n1qse+v+2DSn64YhWFpPNIdwksCirQcItu9TkBUak3D1oSu+44qaeRGMjDRRrL92Go/LHBF01LG201xD7Zca4u+eE7o804MP0r1F5OWB9NPIoKrj4DQwFbnIBRGSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602089004; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=zSsDnCu2xfO7roPjdDMghbRXhd6/t/v6INO/sWdZhMs=; b=JmjF6Ph9zB9xrF3zDn7CKko0JhyVL+YdCLoaO3nIkdTT85a0ZgjOv7shGo7O2Rh3L87JXnF/6nCyfTJ5FdWdcZ0NBBEMe+bKjunz35vxyzEvJ0LHUz0Q9wQ2KQmG47mtTLliDcAWGhZ6dyCNwzMIMmg1AWsW1BK7dHrkPMtYbug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1602089004184210.92936084678445; Wed, 7 Oct 2020 09:43:24 -0700 (PDT) Received: from localhost ([::1]:38032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQCXC-0000UI-TU for importer@patchew.org; Wed, 07 Oct 2020 12:43:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kQCCZ-0002B2-Ud; Wed, 07 Oct 2020 12:22:03 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:32912) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kQCCX-0005WQ-De; Wed, 07 Oct 2020 12:22:03 -0400 Received: by mail-pg1-x52e.google.com with SMTP id o25so1703494pgm.0; Wed, 07 Oct 2020 09:21:59 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id v10sm2974021pjf.34.2020.10.07.09.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Oct 2020 09:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zSsDnCu2xfO7roPjdDMghbRXhd6/t/v6INO/sWdZhMs=; b=Q5grEhYmho5ZZoCZ2KWdZGDsHc79ZJ+GHZSlkfL9Y8+wQ9ckBJKNZHc9BDdhofXAtp Eu4krlgI7yvuM2Y99hvBMaKlavwhbBb6s+6NTeHtcq3ey9RCpu2QnBolAXc+ky3IbB/1 XYJnElM3YMkxjCVvi5KHOJ7gMY0Az/6ZPGjtfHJzNIFADZqXTTNVPmy9cdl3Ai3J9tcN OxBHaydqHyF8RDEuy9KN5aixOjkocGmP/ViZg0lG56vLRB6lo56V6pxbg1o7B9AjMI9m UhXPHzyCWvkYJOI2m4G+M67Nw8gJxDJsTqsvCWEhHEBmWmqiEpWmkRIAiBR3rO662Frn A/NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=zSsDnCu2xfO7roPjdDMghbRXhd6/t/v6INO/sWdZhMs=; b=n3IDbFOWYs5ccuzXv/IvKwt9isG7/BIqRh9ccp0gTGPqqgARSC3Q/wY0Yo5gUqaExZ Rzz/lXO5YMRhSS4EvwJL6JlCaVu8iyd9TJHcZuYC3fEr73no68saPjTGqB9gx6iiAhog akHjVahmMd3tcw4GtYn0B/2vQhMjOe4MGajAoz8J79VGQXt7s+EpAPJfHcyzQlOfJQ6e VdERftsNEJPZGNk8W12wm0H0zYCmR+z82I1j2HrvYlj1RowPH6fw+fhan40t22mumJCO kZxrRJBk2S192xtJMm+YczCv1kxe6rN1lr1sytz1eBpyFN0nMz4e/6vM1SsPPKHWuwBF mf4A== X-Gm-Message-State: AOAM532z7kjtuQ7JKheTqs4If7stVYxcqE0ezSMmyzwsrzWsx0Bv8JZ4 537bCQYwuhvuHasQ1sFeSnK7vagsohclBg== X-Google-Smtp-Source: ABdhPJzkq89oSb5m9tDu2iBDhB4My26rW5lAFMTI+k0hY/xxhbiInyXmHtdj01aAxe6YT91wQqv5Vw== X-Received: by 2002:aa7:9712:0:b029:152:69ab:b507 with SMTP id a18-20020aa797120000b029015269abb507mr3731651pfg.30.1602087718039; Wed, 07 Oct 2020 09:21:58 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v6] scripts: Convert qemu-version.sh to qemu-version.py Date: Thu, 8 Oct 2020 00:21:38 +0800 Message-Id: <20201007162138.425-1-luoyonggang@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=luoyonggang@gmail.com; helo=mail-pg1-x52e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , QEMU Trivial , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Yonggang Luo , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The sh script are harder to maintain for compatible different xsh environment so convert it to python script Also incorporate the fixes in https://patchew.org/QEMU/20200929143654.518157-1-marcandre.lureau@redhat.co= m/ The quote of v* should preserve, otherwise git command would fail Signed-off-by: Yonggang Luo Message-Id: <20201006112139.700-1-luoyonggang@gmail.com> Signed-off-by: Paolo Bonzini --- meson.build | 2 +- scripts/qemu-version.py | 34 ++++++++++++++++++++++++++++++++++ scripts/qemu-version.sh | 25 ------------------------- 3 files changed, 35 insertions(+), 26 deletions(-) create mode 100644 scripts/qemu-version.py delete mode 100755 scripts/qemu-version.sh diff --git a/meson.build b/meson.build index 26230614ba..1d3bb25bc6 100644 --- a/meson.build +++ b/meson.build @@ -1132,7 +1132,7 @@ tracetool =3D [ '--backend=3D' + config_host['TRACE_BACKENDS'] ] =20 -qemu_version_cmd =3D [find_program('scripts/qemu-version.sh'), +qemu_version_cmd =3D [find_program('scripts/qemu-version.py'), meson.current_source_dir(), config_host['PKGVERSION'], meson.project_version()] qemu_version =3D custom_target('qemu-version.h', diff --git a/scripts/qemu-version.py b/scripts/qemu-version.py new file mode 100644 index 0000000000..019911b270 --- /dev/null +++ b/scripts/qemu-version.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + +# +# Script for retrieve qemu git version information +# +# Authors: +# Yonggang Luo +# +# This work is licensed under the terms of the GNU GPL, version 2 +# or, at your option, any later version. See the COPYING file in +# the top-level directory. + +import sys +import subprocess +import os, os.path + +def main(_program, dir, pkgversion, version, *unused): + os.chdir(dir) + if not pkgversion and os.path.exists('.git'): + # The quote of v* should preserve, otherwise git command would fail + pc =3D subprocess.run(['git', 'describe', '--match', "'v*'", '--di= rty', '--always'], + stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.= DEVNULL, encoding=3D'utf8') + if pc.returncode =3D=3D 0: + pkgversion =3D pc.stdout.strip() + + fullversion =3D version + if pkgversion: + fullversion =3D "{} ({})".format(version, pkgversion) + + print('#define QEMU_PKGVERSION "%s"' % pkgversion) + print('#define QEMU_FULL_VERSION "%s"' % fullversion) + +if __name__ =3D=3D "__main__": + main(*sys.argv) diff --git a/scripts/qemu-version.sh b/scripts/qemu-version.sh deleted file mode 100755 index 03128c56a2..0000000000 --- a/scripts/qemu-version.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -set -eu - -dir=3D"$1" -pkgversion=3D"$2" -version=3D"$3" - -if [ -z "$pkgversion" ]; then - cd "$dir" - if [ -e .git ]; then - pkgversion=3D$(git describe --match 'v*' --dirty | echo "") - fi -fi - -if [ -n "$pkgversion" ]; then - fullversion=3D"$version ($pkgversion)" -else - fullversion=3D"$version" -fi - -cat <