[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/3] tests/vm: Introduce get_qemu_packages_from_lcitool_vars(
From: |
Erik Skultety |
Subject: |
Re: [PATCH 2/3] tests/vm: Introduce get_qemu_packages_from_lcitool_vars() helper |
Date: |
Thu, 1 Jun 2023 09:36:27 +0200 |
On Wed, May 31, 2023 at 10:09:05PM +0200, Philippe Mathieu-Daudé wrote:
> The 'lcitool variables $OS qemu' command produces a file containing
> consistent environment variables helpful to build QEMU on $OS.
> In particular the $PKGS variable contains the packages required to
> build QEMU.
>
> Since some of these files are committed in the repository (see
> 0e103a65ba "gitlab: support for FreeBSD 12, 13 and macOS 11 via
> cirrus-run"), we can parse these files to get the package list
> required to build a VM.
>
> Add the get_qemu_packages_from_lcitool_vars() helper which return
> such package list from a lcitool env var file.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> tests/vm/basevm.py | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 8ec021ddcf..2632c3d41a 100644
> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -522,6 +522,12 @@ def get_qemu_version(qemu_path):
> version_num = re.split(' |\(', version_line)[3].split('.')[0]
> return int(version_num)
>
> +def get_qemu_packages_from_lcitool_vars(vars_path):
> + """Parse a lcitool variables file and return the PKGS list."""
> + with open(vars_path, 'r') as fd:
> + line = list(filter(lambda y: y.startswith('PKGS'),
> fd.readlines()))[0]
> + return line.split("'")[1].split()
Nothing wrong with this one, it's also less lines of code, but just an FYI in
case you wanted a slightly more readable (yet a tiny bit less performant piece
of code) you could make use of the JSON format with 'variables --format json'.
Regards,
Erik
- Re: [PATCH 2/3] tests/vm: Introduce get_qemu_packages_from_lcitool_vars() helper,
Erik Skultety <=