Skip to content

Commit

Permalink
test-runner.py: support opkg in get_packages()
Browse files Browse the repository at this point in the history
Yocto can use rpm, deb or opkg as binary packaging tool.
If distribution is not guessed correctly from /etc/os-release, or
if it doesn't match debian, fedora or ubuntu, then try the different
packaging tools to populate package list. This will work if tools
are on the rootfs also on custom distributions like the ones from
yocto build.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
  • Loading branch information
mikkorapeli-linaro committed Jan 2, 2023
1 parent 0233707 commit b1011ae
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion automated/utils/test-runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ def get_packages(linux_distribution, target=None, target_port=None):
linux_distribution is a string that may be 'debian',
'ubuntu', 'centos', or 'fedora'.
If linux_distribution is not provided, then rpm, dpkg and opkg
tools will be tried to get the package list.
For example (ubuntu):
'packages': ['acl-2.2.52-2',
'adduser-3.113+nmu3',
Expand All @@ -643,6 +646,11 @@ def get_packages(linux_distribution, target=None, target_port=None):
"zlib-1.2.7-17.el7",
"zlib-devel-1.2.7-17.el7"
]
(yocto/opkg):
"packages": ["alsa-conf - 1.2.6.1-r0.3",
"alsa-state - 0.2.0-r5.3",
...
]
"""

logger = logging.getLogger("RUNNER.get_packages")
Expand All @@ -660,10 +668,31 @@ def get_packages(linux_distribution, target=None, target_port=None):
).splitlines()
else:
logger.warning(
"Unknown linux distribution '{}'; package list not populated.".format(
"Unknown linux distribution '{}'; trying to populate package list.".format(
linux_distribution
)
)
try:
packages = run_command(
"which rpm > /dev/null && rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE}\n'", target, target_port
).splitlines()
except subprocess.CalledProcessError:
pass
logger.debug("packages = %s" % packages)
try:
packages += run_command(
"which dpkg > /dev/null && dpkg-query -W -f '${package}-${version}\n'", target, target_port
).splitlines()
except subprocess.CalledProcessError:
pass
logger.debug("packages = %s" % packages)
try:
packages += run_command(
"which opkg > /dev/null && opkg list-installed", target, target_port
).splitlines()
except subprocess.CalledProcessError:
pass
logger.debug("packages = %s" % packages)

packages.sort()
return packages
Expand Down

0 comments on commit b1011ae

Please sign in to comment.