* [PATCH 1/3] update-alternatives.bbclass: Add function to get renamed binaries
[not found] <cover.1554474048.git.just.another.mariano@gmail.com>
@ 2019-04-05 14:26 ` Mariano Lopez
2019-04-05 14:26 ` [PATCH 2/3] ptest.bbclass: Add feature to populate a binary directory Mariano Lopez
2019-04-05 14:26 ` [PATCH 3/3] util-linux: Use PTEST " Mariano Lopez
2 siblings, 0 replies; 3+ messages in thread
From: Mariano Lopez @ 2019-04-05 14:26 UTC (permalink / raw)
To: openembedded-core
This adds a function to get the new name for renamed binaries by the
update-alternatives class. The function uses the build metadata because
some update-alternatives binaries/scripts lack the feature to provide
this information.
This also adds the function _ua_alt_target for code reuse.
[YOCTO #13238]
Signed-off-by: Mariano Lopez <just.another.mariano@gmail.com>
---
meta/classes/update-alternatives.bbclass | 43 +++++++++++++++++++++---
1 file changed, 38 insertions(+), 5 deletions(-)
diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass
index 537e85d9a3..d601dfc700 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -216,6 +216,43 @@ python apply_update_alternative_renames () {
update_files(alt_target, alt_target_rename, pkg, d)
}
+def update_alternatives_get_alt_target(d, link):
+ """
+ Returns the renamed binary modified by update-alternatives class.
+
+ Unfortunately not all update-alternative binaries/scripts implement a way
+ to provide a list of binaries for a link, so we need to use the build
+ metadata to get the information.
+
+ NOTE: This function needs to run after apply_update_alternative_renames
+ """
+ for pkg in (d.getVar('PACKAGES') or "").split():
+ for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split():
+ alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name)
+
+ # Just care for the link being asked for
+ if link != alt_link:
+ continue
+
+ alt_target = _ua_alt_target(d, alt_name, alt_link, pkg)
+ if alt_target != alt_link:
+ return alt_target
+ else:
+ return None
+
+ return None
+
+def _ua_alt_target(d, alt_name, alt_link, pkg):
+ alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or \
+ d.getVarFlag('ALTERNATIVE_TARGET', alt_name) or \
+ d.getVar('ALTERNATIVE_TARGET_%s' % pkg) or \
+ d.getVar('ALTERNATIVE_TARGET') or \
+ alt_link
+
+ # Sometimes alt_target is specified as relative to the link name.
+ alt_target = os.path.join(os.path.dirname(alt_link), alt_target)
+ return alt_target
+
PACKAGESPLITFUNCS_prepend = "populate_packages_updatealternatives "
python populate_packages_updatealternatives () {
@@ -232,11 +269,7 @@ python populate_packages_updatealternatives () {
alt_remove_links = ""
for alt_name in (d.getVar('ALTERNATIVE_%s' % pkg) or "").split():
alt_link = d.getVarFlag('ALTERNATIVE_LINK_NAME', alt_name)
- alt_target = d.getVarFlag('ALTERNATIVE_TARGET_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_TARGET', alt_name)
- alt_target = alt_target or d.getVar('ALTERNATIVE_TARGET_%s' % pkg) or d.getVar('ALTERNATIVE_TARGET') or alt_link
- # Sometimes alt_target is specified as relative to the link name.
- alt_target = os.path.join(os.path.dirname(alt_link), alt_target)
-
+ alt_target = _ua_alt_target(d, alt_name, alt_link, pkg)
alt_priority = d.getVarFlag('ALTERNATIVE_PRIORITY_%s' % pkg, alt_name) or d.getVarFlag('ALTERNATIVE_PRIORITY', alt_name)
alt_priority = alt_priority or d.getVar('ALTERNATIVE_PRIORITY_%s' % pkg) or d.getVar('ALTERNATIVE_PRIORITY')
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/3] ptest.bbclass: Add feature to populate a binary directory
[not found] <cover.1554474048.git.just.another.mariano@gmail.com>
2019-04-05 14:26 ` [PATCH 1/3] update-alternatives.bbclass: Add function to get renamed binaries Mariano Lopez
@ 2019-04-05 14:26 ` Mariano Lopez
2019-04-05 14:26 ` [PATCH 3/3] util-linux: Use PTEST " Mariano Lopez
2 siblings, 0 replies; 3+ messages in thread
From: Mariano Lopez @ 2019-04-05 14:26 UTC (permalink / raw)
To: openembedded-core
This adds a functionality to populate a binary directory with symlinks
within the PTEST_PATH directory to the binaries build by the package. This
is helpful for binaries that are renamed by update-alternatives.
This will take all the package binaries' that are in bindir, sbindir
base_bindir, and base_sbindir and create symlinks in PTEST_BINDIR_PATH. To
enable this feature just add PTEST_BINDIR = "1" to the recipe.
[YOCTO #13238]
Signed-off-by: Mariano Lopez <just.another.mariano@gmail.com>
---
meta/classes/ptest.bbclass | 52 ++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/meta/classes/ptest.bbclass b/meta/classes/ptest.bbclass
index 97865c9338..735057c44d 100644
--- a/meta/classes/ptest.bbclass
+++ b/meta/classes/ptest.bbclass
@@ -63,6 +63,58 @@ do_install_ptest_base() {
fi
done
done
+
+ if [ "${PTEST_BINDIR}" == "1" ]; then
+ install_ptest_bindir
+ fi
+}
+
+PTEST_BINDIR_PATH="${D}${PTEST_PATH}/bin"
+
+install_ptest_bindir() {
+ # Create ${PTEST_PATH}/bin to create symlinks to the package's binaries
+ # this way the path can be added to PATH and execute the binaries easier
+ # from ptest-runner.
+ bbdebug 1 "Generating PTEST's bin directory"
+ binary_paths="${bindir} ${sbindir} ${base_bindir} ${base_sbindir}"
+ mkdir -p ${PTEST_BINDIR_PATH}
+
+ for path in ${binary_paths}; do
+ for src in ${D}${path}/*; do
+ binary=`basename ${src}`
+ ln -s ${path}/${binary} ${PTEST_BINDIR_PATH}/${binary}
+ done
+ done
+}
+
+# This function needs to run after apply_update_alternative_renames because the
+# aforementioned function will update the ALTERNATIVE_LINK_NAME flag. Append is
+# used here to make this function to run as late as possible.
+PACKAGE_PREPROCESS_FUNCS_append = "${@bb.utils.contains("PTEST_BINDIR", "1", " ptest_update_alternatives", "", d)}"
+
+python ptest_update_alternatives() {
+ """
+ This function will fix the symlinks in the PTEST_BINDIR that
+ were broken by the renaming of update-alternatives
+ """
+
+ if not bb.data.inherits_class('update-alternatives', d) \
+ or not update_alternatives_enabled(d):
+ return
+
+ bb.note("Updating PTEST symlinks after the renaming of update-alternatives")
+
+ ptest_pkgd_bindir = os.path.join(d.getVar("PKGD"),
+ d.getVar("PTEST_PATH")[1:],
+ "bin")
+ links_dict = { os.path.join(ptest_pkgd_bindir, link):
+ os.readlink(os.path.join(ptest_pkgd_bindir, link))
+ for link in os.listdir(ptest_pkgd_bindir) }
+ for filename, link in links_dict.items():
+ alt_link = update_alternatives_get_alt_target(d, link)
+ if alt_link:
+ os.unlink(filename)
+ os.symlink(alt_link, filename)
}
do_configure_ptest_base[dirs] = "${B}"
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 3/3] util-linux: Use PTEST binary directory
[not found] <cover.1554474048.git.just.another.mariano@gmail.com>
2019-04-05 14:26 ` [PATCH 1/3] update-alternatives.bbclass: Add function to get renamed binaries Mariano Lopez
2019-04-05 14:26 ` [PATCH 2/3] ptest.bbclass: Add feature to populate a binary directory Mariano Lopez
@ 2019-04-05 14:26 ` Mariano Lopez
2 siblings, 0 replies; 3+ messages in thread
From: Mariano Lopez @ 2019-04-05 14:26 UTC (permalink / raw)
To: openembedded-core
Some binaries generated by util-linux will be replaced by core-utils
in the final image by update-alternatives, so use a dedicated directory
with symlinks to avoid using a binary generated by another package.
This will solve the issue with the ptest runner timing out when running
the kill ptests for util-linux.
[YOCTO #13238]
Signed-off-by: Mariano Lopez <just.another.mariano@gmail.com>
---
meta/recipes-core/util-linux/util-linux.inc | 5 +++--
meta/recipes-core/util-linux/util-linux/run-ptest | 4 ++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/meta/recipes-core/util-linux/util-linux.inc b/meta/recipes-core/util-linux/util-linux.inc
index 18c3af240e..a67318e84e 100644
--- a/meta/recipes-core/util-linux/util-linux.inc
+++ b/meta/recipes-core/util-linux/util-linux.inc
@@ -284,6 +284,7 @@ ALTERNATIVE_LINK_NAME[wall.1] = "${mandir}/man1/wall.1"
BBCLASSEXTEND = "native nativesdk"
+PTEST_BINDIR = "1"
do_compile_ptest() {
oe_runmake buildtest-TESTS
}
@@ -312,8 +313,8 @@ do_install_ptest() {
'/^\tif[[:space:]]\[[[:space:]]![[:space:]]-x[[:space:]]"$1"/s|$1|`which $1 2>/dev/null`|g' \
${D}${PTEST_PATH}/tests/functions.sh
- # "kill -L" behaves differently than "/bin/kill -L" so we need an additional fix
+ # Running "kill" without the the complete path would use the shell's built-in kill
sed -i -e \
- '/^TS_CMD_KILL/ s|kill|/bin/kill|g' \
+ '/^TS_CMD_KILL/ s|kill|${PTEST_PATH}/bin/kill|g' \
${D}${PTEST_PATH}/tests/commands.sh
}
diff --git a/meta/recipes-core/util-linux/util-linux/run-ptest b/meta/recipes-core/util-linux/util-linux/run-ptest
index fbc2f9b56a..2178ab8fef 100644
--- a/meta/recipes-core/util-linux/util-linux/run-ptest
+++ b/meta/recipes-core/util-linux/util-linux/run-ptest
@@ -1,5 +1,9 @@
#!/bin/sh
+current_path=$(readlink -f $0)
+export bindir=$(dirname $current_path)
+export PATH=$bindir/bin:$PATH
+
cd tests || exit 1
comps=$(find ts/ -type f -perm -111 -regex ".*/[^\.~]*" | sort)
--
2.19.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-05 14:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <cover.1554474048.git.just.another.mariano@gmail.com>
2019-04-05 14:26 ` [PATCH 1/3] update-alternatives.bbclass: Add function to get renamed binaries Mariano Lopez
2019-04-05 14:26 ` [PATCH 2/3] ptest.bbclass: Add feature to populate a binary directory Mariano Lopez
2019-04-05 14:26 ` [PATCH 3/3] util-linux: Use PTEST " Mariano Lopez
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.