scripts: Convert qemu-version.sh to qemu-version.py
PATCH v10 1/1 scripts: Convert qemu-version.sh to qemu-version.py
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/[email protected]/
Using v\\* on Windows and v* on other platform for matching version. Tested under Ubuntu/msys2/mingw.
Message-Id: <[email protected]>
--- meson.build | 2 +- scripts/qemu-version.py | 37 +++++++++++++++++++++++++++++++++++++ scripts/qemu-version.sh | 25 ------------------------- 3 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 scripts/qemu-version.py delete mode 100755 scripts/qemu-version.sh
meson.build +1 -1
@@ -1132,7 +1132,7 @@ tracetool = [ '--backend=' + config_host['TRACE_BACKENDS'] ] -qemu_version_cmd = [find_program('scripts/qemu-version.sh'), +qemu_version_cmd = [find_program('scripts/qemu-version.py'), meson.current_source_dir(), config_host['PKGVERSION'], meson.project_version()] qemu_version = custom_target('qemu-version.h',
scripts/qemu-version.py new file +37 -0
@@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +# +# Script for retrieve qemu git version information +# +# Authors: +# Yonggang Luo <[email protected]> +# +# 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 +import platform + +def main(_program, dir, pkgversion, version, *unused): + os.chdir(dir) + if not pkgversion and os.path.exists('.git'): + match_expression = 'v\\*' if platform.system() == 'Windows' else 'v*' + pc = subprocess.run(['git', 'describe', '--match', match_expression, + '--dirty', '--always'], + stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, + encoding='utf8', shell=False) + if pc.returncode == 0: + pkgversion = pc.stdout.strip() + + fullversion = version + if pkgversion: + fullversion = "{} ({})".format(version, pkgversion) + + print('#define QEMU_PKGVERSION "%s"' % pkgversion) + print('#define QEMU_FULL_VERSION "%s"' % fullversion) + +if __name__ == "__main__": + main(*sys.argv)
scripts/qemu-version.sh deleted +0 -25
@@ -1,25 +0,0 @@ -#!/bin/sh - -set -eu - -dir="$1" -pkgversion="$2" -version="$3" - -if [ -z "$pkgversion" ]; then - cd "$dir" - if [ -e .git ]; then - pkgversion=$(git describe --match 'v*' --dirty | echo "") - fi -fi - -if [ -n "$pkgversion" ]; then - fullversion="$version ($pkgversion)" -else - fullversion="$version" -fi - -cat <<EOF -#define QEMU_PKGVERSION "$pkgversion" -#define QEMU_FULL_VERSION "$fullversion" -EOF
Signature · 1 line
2.28.0.windows.1
You won't hear no for an answer, right?...
Paolo
Il mer 7 ott 2020, 22:00 Yonggang Luo <[email protected]> ha scritto:
Quoted 114 lines
The sh script are harder to maintain for compatible different xsh environment so convert it to python script
Also incorporate the fixes inhttps://patchew.org/QEMU/[email protected]/
Using v\\* on Windows and v* on other platform for matching version. Tested under Ubuntu/msys2/mingw.
Signed-off-by Yonggang Luo <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>--- meson.build | 2 +- scripts/qemu-version.py | 37 +++++++++++++++++++++++++++++++++++++ scripts/qemu-version.sh | 25 ------------------------- 3 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 scripts/qemu-version.py delete mode 100755 scripts/qemu-version.shmeson.build +1
-1@@ -1132,7 +1132,7 @@ tracetool = [ '--backend=' + config_host['TRACE_BACKENDS'] ] -qemu_version_cmd = [find_program('scripts/qemu-version.sh'), +qemu_version_cmd = [find_program('scripts/qemu-version.py'), meson.current_source_dir(), config_host['PKGVERSION'], meson.project_version()] qemu_version = custom_target('qemu-version.h',scripts/qemu-version.py new file +21
-0@@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +# +# Script for retrieve qemu git version information +# +# Authors: +# Yonggang Luo <[email protected]> +# +# 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 +import platform + +def main(_program, dir, pkgversion, version, *unused): + os.chdir(dir) + if not pkgversion and os.path.exists('.git'): + match_expression = 'v\\*' if platform.system() == 'Windows' else'v*'
+ pc = subprocess.run(['git', 'describe', '--match',match_expression,scripts/qemu-version.py new file +2
-0+ '--dirty', '--always'], + stdout=subprocess.PIPE,stderr=subprocess.DEVNULL,
scripts/qemu-version.py new file +13
-0+ encoding='utf8', shell=False) + if pc.returncode == 0: + pkgversion = pc.stdout.strip() + + fullversion = version + if pkgversion: + fullversion = "{} ({})".format(version, pkgversion) + + print('#define QEMU_PKGVERSION "%s"' % pkgversion) + print('#define QEMU_FULL_VERSION "%s"' % fullversion) + +if __name__ == "__main__": + main(*sys.argv)scripts/qemu-version.sh deleted +0
-26@@ -1,25 +0,0 @@ -#!/bin/sh - -set -eu - -dir="$1" -pkgversion="$2" -version="$3" - -if [ -z "$pkgversion" ]; then - cd "$dir" - if [ -e .git ]; then - pkgversion=$(git describe --match 'v*' --dirty | echo "") - fi -fi - -if [ -n "$pkgversion" ]; then - fullversion="$version ($pkgversion)" -else - fullversion="$version" -fi - -cat <<EOF -#define QEMU_PKGVERSION "$pkgversion" -#define QEMU_FULL_VERSION "$fullversion" -EOF --2.28.0.windows.1
Quoted 2 lines · Paolo Bonzini
You won't hear no for an answer, right?...
I am trying to figure out the real issue, it's the issue of git,
https://github.com/msys2/MSYS2-packages/issues/2176
The windows wildcard can be disabled and git disabled it, didn't know what's happened to
the msys's git, but git-for-windows are works fine.
Quoted 10 lines
Paolo
Il mer 7 ott 2020, 22:00 Yonggang Luo <[email protected]> ha scritto:
Quoted 5 lines
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/[email protected]/
Quoted 47 lines
Quoted 47 lines
Using v\\* on Windows and v* on other platform for matching version. Tested under Ubuntu/msys2/mingw.
Signed-off-by Yonggang Luo <[email protected]>Message-Id: <[email protected]>
Signed-off-by Paolo Bonzini <[email protected]>--- meson.build | 2 +- scripts/qemu-version.py | 37 +++++++++++++++++++++++++++++++++++++ scripts/qemu-version.sh | 25 ------------------------- 3 files changed, 38 insertions(+), 26 deletions(-) create mode 100644 scripts/qemu-version.py delete mode 100755 scripts/qemu-version.shmeson.build +1
-1@@ -1132,7 +1132,7 @@ tracetool = [ '--backend=' + config_host['TRACE_BACKENDS'] ] -qemu_version_cmd = [find_program('scripts/qemu-version.sh'), +qemu_version_cmd = [find_program('scripts/qemu-version.py'), meson.current_source_dir(), config_host['PKGVERSION'], meson.project_version()] qemu_version = custom_target('qemu-version.h',scripts/qemu-version.py new file +13
-0@@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +# +# Script for retrieve qemu git version information +# +# Authors: +# Yonggang Luo <[email protected]> +# +# 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
Quoted 8 lines
scripts/qemu-version.py
Quoted 8 lines
scripts/qemu-version.py new file +8
-0+import subprocess +import os, os.path +import platform + +def main(_program, dir, pkgversion, version, *unused): + os.chdir(dir) + if not pkgversion and os.path.exists('.git'): + match_expression = 'v\\*' if platform.system() == 'Windows'
else 'v*'
Quoted 1 line
scripts/qemu-version.py line 22
Quoted 1 line
scripts/qemu-version.py new file +1
-0+ pc = subprocess.run(['git', 'describe', '--match',
match_expression,
Quoted 2 lines
scripts/qemu-version.py line 24
Quoted 2 lines
scripts/qemu-version.py new file +2
-0+ '--dirty', '--always'], + stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
Quoted 39 lines
Quoted 39 lines
scripts/qemu-version.py new file +13
-0+ encoding='utf8', shell=False) + if pc.returncode == 0: + pkgversion = pc.stdout.strip() + + fullversion = version + if pkgversion: + fullversion = "{} ({})".format(version, pkgversion) + + print('#define QEMU_PKGVERSION "%s"' % pkgversion) + print('#define QEMU_FULL_VERSION "%s"' % fullversion) + +if __name__ == "__main__": + main(*sys.argv)scripts/qemu-version.sh deleted +0
-20@@ -1,25 +0,0 @@ -#!/bin/sh - -set -eu - -dir="$1" -pkgversion="$2" -version="$3" - -if [ -z "$pkgversion" ]; then - cd "$dir" - if [ -e .git ]; then - pkgversion=$(git describe --match 'v*' --dirty | echo "") - fi -fi - -if [ -n "$pkgversion" ]; then - fullversion="$version ($pkgversion)" -else - fullversion="$version" -fi
Quoted 8 lines
Quoted 8 lines
scripts/qemu-version.sh deleted +0
-6- -cat <<EOF -#define QEMU_PKGVERSION "$pkgversion" -#define QEMU_FULL_VERSION "$fullversion" -EOF --2.28.0.windows.1
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
Quoted 7 lines · 罗勇刚(Yonggang Luo)
Quoted 2 lines · On Thu, Oct 8, 2020 at 4:31 AM Paolo Bonzini <[email protected]…
You won't hear no for an answer, right?...
I am trying to figure out the real issue, it's the issue of git,
https://github.com/msys2/MSYS2-packages/issues/2176
Can you at least please stop crap-flooding the QEMU mailing list with multiple versions of your patches each day? We are all busy, so nobody is going to review 5 or more iterations of your patches each day. Work on your patches first, make sure that they are working, and only if you think that they are really, really good, then send them to the list. Thanks.
Thomas