From: Erik Skultety <eskultet@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 2/3] tests/vm: Introduce get_qemu_packages_from_lcitool_vars() helper
Date: Thu, 1 Jun 2023 09:36:27 +0200 [thread overview]
Message-ID: <ZHhKe3fzmau7qsMn@ridgehead.home.lan> (raw)
In-Reply-To: <20230531200906.17790-3-philmd@linaro.org>
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
next parent reply other threads:[~2023-06-01 7:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230531200906.17790-1-philmd@linaro.org>
[not found] ` <20230531200906.17790-3-philmd@linaro.org>
2023-06-01 7:36 ` Erik Skultety [this message]
2023-06-01 9:57 ` [PATCH 2/3] tests/vm: Introduce get_qemu_packages_from_lcitool_vars() helper Daniel P. Berrangé
2023-06-01 8:05 ` [PATCH 0/3] tests/vm/freebsd: Get up-to-date package list from lcitool Erik Skultety
[not found] ` <20230531200906.17790-4-philmd@linaro.org>
2023-06-01 9:55 ` [PATCH 3/3] tests/vm/freebsd: Get up-to-date package list from lcitool vars file Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZHhKe3fzmau7qsMn@ridgehead.home.lan \
--to=eskultet@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).