Message ID | 20230531200906.17790-3-philmd@linaro.org |
---|---|
State | New |
Headers | show |
Series | tests/vm/freebsd: Get up-to-date package list from lcitool | expand |
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
On Thu, Jun 01, 2023 at 09:36:27AM +0200, Erik Skultety wrote: > 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'. Specifically we could do with open(vars_path, 'r') as fh: return json.load(fh)['pkgs'] With regards, Daniel
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() + def parse_config(config, args): """ Parse yaml config and populate our config structure. The yaml config allows the user to override the
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(+)