Skip to content

Commit 39dca49

Browse files
test-runner.py: support opkg in get_packages()
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>
1 parent 0233707 commit 39dca49

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

automated/utils/test-runner.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,9 @@ def get_packages(linux_distribution, target=None, target_port=None):
629629
linux_distribution is a string that may be 'debian',
630630
'ubuntu', 'centos', or 'fedora'.
631631
632+
If linux_distribution is not provided, then rpm, dpkg and opkg
633+
tools will be tried to get the package list.
634+
632635
For example (ubuntu):
633636
'packages': ['acl-2.2.52-2',
634637
'adduser-3.113+nmu3',
@@ -643,6 +646,11 @@ def get_packages(linux_distribution, target=None, target_port=None):
643646
"zlib-1.2.7-17.el7",
644647
"zlib-devel-1.2.7-17.el7"
645648
]
649+
(yocto/opkg):
650+
"packages": ["alsa-conf - 1.2.6.1-r0.3",
651+
"alsa-state - 0.2.0-r5.3",
652+
...
653+
]
646654
"""
647655

648656
logger = logging.getLogger("RUNNER.get_packages")
@@ -660,12 +668,34 @@ def get_packages(linux_distribution, target=None, target_port=None):
660668
).splitlines()
661669
else:
662670
logger.warning(
663-
"Unknown linux distribution '{}'; package list not populated.".format(
671+
"Unknown linux distribution '{}'; trying to populate package list.".format(
664672
linux_distribution
665673
)
666674
)
675+
try:
676+
packages = run_command(
677+
"which rpm > /dev/null && rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE}\n'", target, target_port
678+
).splitlines()
679+
except subprocess.CalledProcessError:
680+
pass
681+
logger.debug("packages = %s" % packages)
682+
try:
683+
packages += run_command(
684+
"which dpkg > /dev/null && dpkg-query -W -f '${package}-${version}\n'", target, target_port
685+
).splitlines()
686+
except subprocess.CalledProcessError:
687+
pass
688+
logger.debug("packages = %s" % packages)
689+
try:
690+
packages += run_command(
691+
"which opkg > /dev/null && opkg list-installed", target, target_port
692+
).splitlines()
693+
except subprocess.CalledProcessError:
694+
pass
695+
logger.debug("packages = %s" % packages)
667696

668697
packages.sort()
698+
logger.warning(packages)
669699
return packages
670700

671701

0 commit comments

Comments
 (0)