From nobody Thu Oct 31 23:48:44 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=1601983645; cv=none; d=zohomail.com; s=zohoarc; b=YiJVn6IvYPXqsFjEdDoaD1L9bsuiM+q6fMsw0IB6tVwhqZFPQzQ4UkbQQuuYZvjvyvzBmjDsOwEQuOetrRE6MeA6oaq2lSnmP+fndoVUYCEL4dWfhxM8UEa/rjEia0lL/u/75SRBJmSsptfsbxlVFjcs3sx8QR4XKEiWEBy9Cjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601983645; 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=IVrvxOUsYiShuvVwfOqOW7Y32dz8mgeWzYfDdIYjZq4=; b=UIg5SaSNuRGs34y7kzRpCWl86Aq/cCuLU+XB60xN/6l8qHp0ofX2VMj+z7Vf2c1XT+gaaFAH2EdPT6S/2FTKOf0PxmaOFcuwrPz29P7Vftz56I323LdPNrOVHF+XKLu6jrNc1LGFBhf5xp0WNlDW1xsjLd5XEwOb3AZQEbmX8uU= 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 1601983645532751.198836555903; Tue, 6 Oct 2020 04:27:25 -0700 (PDT) Received: from localhost ([::1]:42482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPl7s-0002QU-CM for importer@patchew.org; Tue, 06 Oct 2020 07:27:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPl2d-0005CQ-L4; Tue, 06 Oct 2020 07:21:59 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:36841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kPl2b-0006TG-C7; Tue, 06 Oct 2020 07:21:59 -0400 Received: by mail-pl1-x62e.google.com with SMTP id s19so1061949plp.3; Tue, 06 Oct 2020 04:21:56 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id x3sm2941386pgg.54.2020.10.06.04.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Oct 2020 04:21:54 -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=IVrvxOUsYiShuvVwfOqOW7Y32dz8mgeWzYfDdIYjZq4=; b=kmGxAOHvW3lkdEe5GatiS1wOBBP7Mg0YbBl8vbCwjjxpPUYjEGvPFuKxFywFHYamYO quVhymddOnJQiH3fLQbQbRteoB49qWx3aXG9qIvOoRrEG/t5VQgC9A4q2mnVlrOeXZ2V XOvq3WV8Vkiz9tAJV2QHNI/Rxp2p8oqO4GiIcb1IhCg3AyvKk2gJK7BmAkKJ44iq85gU QSK461GkPwpf8xdUpURcE4BuhpPElMbev8KOcJ/nqikzZ3XwTd5/83i64/WkOu7EOQyD P0q1sD98E9gx11h2XYj/pLrmyieb03pSfZB7OkYzfh3TronbU6Q8qZ95TgTuUdSp4lrC 5mdw== 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=IVrvxOUsYiShuvVwfOqOW7Y32dz8mgeWzYfDdIYjZq4=; b=aeNFazSHenBvXIvAOrTtxextS8FBaB34EVibeGdMGa5K8ibXk40gd4PAiZ6ykwIb9d x4ydSjK5jeM8r+sjPI4qhyDIarLQmguvUh/v8NUPnXajxchHy9g7NxUSFOpXhfkZIuhW iVrr/lJzXkeY7uxVhXv/TVyV+Td3wil9BSLhnvZL8UxlKeUZCi0i35hOM225+U6+7/va rPUxhTrK0lM45tpumrhi5YS7ol8JRs4jivT1+NhdttNfQpm/kOjMsuy9v6unhksaPo1B yf4YTXOzhWo+ni1PFX/6PCUbsArQ5Xdgeya0hF/ySNtW5a6TYnIUj24QGVvep5csklJX 9PXQ== X-Gm-Message-State: AOAM530LUetE84RKXeaIr57uFn2Ph5ti8MB5DbfOYFWA8AFoQyFakCfn kwzqWJLdZT0UQzvmZ7FUTUXe6mELxMqxyQ== X-Google-Smtp-Source: ABdhPJyQK737y3aJY3hIYbB0NQfhrTDNoMRVyK229Faidi+31li38fTPgdQZ/AWX4xWc2fFSvVoPuQ== X-Received: by 2002:a17:90a:128d:: with SMTP id g13mr3779868pja.35.1601983314940; Tue, 06 Oct 2020 04:21:54 -0700 (PDT) From: Yonggang Luo To: qemu-devel@nongnu.org Subject: [PATCH v5] scripts: Convert qemu-version.sh to qemu-version.py Date: Tue, 6 Oct 2020 19:21:39 +0800 Message-Id: <20201006112139.700-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::62e; envelope-from=luoyonggang@gmail.com; helo=mail-pl1-x62e.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=E8=8C=85?= , 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/ Testing args length and if not enough, setting pkgversion and version to '' Signed-off-by: Yonggang Luo --- meson.build | 2 +- scripts/qemu-version.py | 31 +++++++++++++++++++++++++++++++ scripts/qemu-version.sh | 25 ------------------------- 3 files changed, 32 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 95a532bd29..20f653b6eb 100644 --- a/meson.build +++ b/meson.build @@ -1072,7 +1072,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..e6eb548220 --- /dev/null +++ b/scripts/qemu-version.py @@ -0,0 +1,31 @@ +#!/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 + +def main(_program, dir, pkgversion, version, *unused): + if len(pkgversion) =3D=3D 0: + pc =3D subprocess.run(['git', 'describe', '--match', "'v*'", '--di= rty', '--always'], + stdout=3Dsubprocess.PIPE, stderr=3Dsubprocess.= DEVNULL, cwd=3Ddir) + if pc.returncode =3D=3D 0: + pkgversion =3D pc.stdout.decode('utf8').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 <