Split vim and xxd in different recipes
v2 cover Split vim and xxd in different recipes
Hello,
Honestly, my main motivation to send this series comes from a time when I was building u-boot (meta-freescale) and I saw vim-native in Bitbake's tasks. It blew my mind that a bootloader somehow dependend on a text editor (yes, only to be built, not to be executed, I know), and the whole text editor was being built to provide nothing more than xxd.
Just to be clear, what bothers me is NOT u-boot depending on xxd. It is actually configuring and compiling Vim (considering the overhead this represents) only to use a single tiny piece of it.
As for the tests I performed:
- machine: qemuriscv64
- toolchains: clang and gcc
- classes (xxd, vim-xxd): target, native, nativesdk
- classes (vim): target, native, nativesdk
- archiving: the resulting tarball includes only xxd's sources, as expected
Some benchmarks as well, from a previous mail:
vim-native-9.2.0340-r0: do_configure
Elapsed time: 6.81 seconds
vim-native-9.2.0340-r0: do_compile
Elapsed time: 4.43 seconds
vim-xxd-native-9.2.0340-r0: do_configure
Elapsed time: 0.03 seconds
vim-xxd-native-9.2.0340-r0: do_compile
Elapsed time: 0.23 seconds
(this data comes from tmp/buildstats)
Everything built fine, and the core-image-minimal running with qemu also correctly shipped vim and xxd, which executed fine as well.
Finally, regarding runtime, vim already RDEPENDs on vim-xxd, so by default they are installed together if you have 'vim' in IMAGE_INSTALL. After the split, it is true that both recipes will be built, but as per the numbers above, the time spent building vim-xxd-native is minimal.
Best regards,
Changes since v1:
- added the step where vim's sources are pruned
- fixed the license information in xxd
- moved the patches from vim-sources.inc to vim's recipe, as they don't apply to xxd
- added support to pruning in archiver.bbclass, to make things coherent
- added some benchmarks to the cover letter
João Marcos Costa (5):
vim: introduce vim-sources.inc file
vim-xxd: introduce new recipe for xxd
vim: drop references to xxd in base recipe vim.inc: remove xxd from the destination directory base.bbclass: introduce prune_source_tree function
meta/classes-global/base.bbclass | 49 ++++++++++++++++++++++++ meta/classes/archiver.bbclass | 1 + meta/conf/distro/include/maintainers.inc | 1 + meta/recipes-support/vim/vim-sources.inc | 9 +++++ meta/recipes-support/vim/vim-xxd_9.2.bb | 39 +++++++++++++++++++ meta/recipes-support/vim/vim.inc | 18 +++------ meta/recipes-support/vim/vim_9.2.bb | 13 ++----- 7 files changed, 108 insertions(+), 22 deletions(-) create mode 100644 meta/recipes-support/vim/vim-sources.inc create mode 100644 meta/recipes-support/vim/vim-xxd_9.2.bb
Signature · 1 line
2.43.0
PATCH v2 1/5 vim: introduce vim-sources.inc file
This include file contains source-related settings that should be common for any recipes whose sources belong into Vim's source code.
The first example is xxd, which will be introduced in a follow-up commit.
--- meta/recipes-support/vim/vim-sources.inc | 9 +++++++++ meta/recipes-support/vim/vim.inc | 14 +------------- meta/recipes-support/vim/vim_9.2.bb | 5 +++++ 3 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 meta/recipes-support/vim/vim-sources.inc
meta/recipes-support/vim/vim-sources.inc new file +9 -0
@@ -0,0 +1,9 @@ +SRC_URI = "git://github.com/vim/vim.git;branch=master;protocol=https;tag=v${PV}" + +PV .= ".0340" +SRCREV = "6addd6c101117706bc9b3609d3a418e26e92618f" + +# Do not consider .z in x.y.z, as that is updated with every commit +UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+\.\d+)\.0" +# Ignore that the upstream version .z in x.y.z is always newer +UPSTREAM_VERSION_UNKNOWN = "1"
meta/recipes-support/vim/vim.inc +1 -13
@@ -12,19 +12,7 @@ RSUGGESTS:${PN} = "diffutils" LICENSE = "Vim" LIC_FILES_CHKSUM = "file://LICENSE;md5=d1a651ab770b45d41c0f8cb5a8ca930e" -SRC_URI = "git://github.com/vim/vim.git;branch=master;protocol=https;tag=v${PV} \ - file://disable_acl_header_check.patch \ - file://0001-src-Makefile-improve-reproducibility.patch \ - file://no-path-adjust.patch \ - " - -PV .= ".0340" -SRCREV = "6addd6c101117706bc9b3609d3a418e26e92618f" - -# Do not consider .z in x.y.z, as that is updated with every commit -UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+\.\d+)\.0" -# Ignore that the upstream version .z in x.y.z is always newer -UPSTREAM_VERSION_UNKNOWN = "1" +require vim-sources.inc VIMDIR = "vim${@d.getVar('PV').split('.')[0]}${@d.getVar('PV').split('.')[1]}"
meta/recipes-support/vim/vim_9.2.bb +5 -0
@@ -1,5 +1,10 @@ require vim.inc +SRC_URI += "file://disable_acl_header_check.patch \ + file://0001-src-Makefile-improve-reproducibility.patch \ + file://no-path-adjust.patch \ +" + PROVIDES = "xxd" RDEPENDS:${PN} = "ncurses-terminfo-base ${PN}-xxd"
Signature · 1 line
2.43.0
PATCH v2 2/5 vim-xxd: introduce new recipe for xxd
In reply to João Marcos CostaThis new recipe's main purpose is to handle xxd in the simplest way possible, stripping it from any needless tasks and/or dependencies that come from the fact it was originally provided by the same recipe as Vim.
Not only this recipe is faster to build, but it still provides the very same program for both build-time and run-time, so there should be no migration needed by the recipes depend on xxd.
--- meta/conf/distro/include/maintainers.inc | 1 + meta/recipes-support/vim/vim-xxd_9.2.bb | 35 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 meta/recipes-support/vim/vim-xxd_9.2.bb
meta/conf/distro/include/maintainers.inc +1 -0
@@ -869,6 +869,7 @@ RECIPE_MAINTAINER:pn-vala = "Unassigned <[email protected]>" RECIPE_MAINTAINER:pn-valgrind = "Mingli Yu <[email protected]>" RECIPE_MAINTAINER:pn-vim = "Unassigned <[email protected]>" RECIPE_MAINTAINER:pn-vim-tiny = "Unassigned <[email protected]>" +RECIPE_MAINTAINER:pn-vim-xxd = "João Marcos Costa <[email protected]>" RECIPE_MAINTAINER:pn-virglrenderer = "Unassigned <[email protected]>" RECIPE_MAINTAINER:pn-volatile-binds = "Chen Qi <[email protected]>" RECIPE_MAINTAINER:pn-vte = "Unassigned <[email protected]>"
meta/recipes-support/vim/vim-xxd_9.2.bb new file +35 -0
@@ -0,0 +1,35 @@ +SUMMARY = "Hex dump and reverse utility from the Vim source tree" +DESCRIPTION = "xxd is a small utility usually distributed with Vim that creates hex dumps from binary data and can also convert hex dumps back to their original form." +SECTION = "console/utils" +HOMEPAGE = "https://www.vim.org/" +BUGTRACKER = "https://github.com/vim/vim/issues" + +LICENSE = "X11 | GPL-2.0-only" +LIC_FILES_CHKSUM = "\ + file://${COMMON_LICENSE_DIR}/X11;md5=87f08485cf6ba3c63a00eda8ecba7f1d \ + file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6 \ +" + +require vim-sources.inc + +inherit update-alternatives + +PROVIDES += "xxd" + +do_compile() { + cd ${S}/src/xxd; + oe_runmake xxd +} + +do_install() { + install -d ${D}${bindir} + install -m 0755 src/xxd/xxd ${D}${bindir} +} + +RPROVIDES:${PN} += "xxd" + +ALTERNATIVE:${PN} = "xxd" +ALTERNATIVE_TARGET[xxd] = "${bindir}/xxd" +ALTERNATIVE_LINK_NAME[xxd] = "${bindir}/xxd" + +BBCLASSEXTEND = "native nativesdk"
Signature · 1 line
2.43.0
PATCH v2 3/5 vim: drop references to xxd in base recipe
In reply to João Marcos CostaThe new vim-xxd recipe provides a binary package shipping xxd, along with the update-alternative specific settings, and it also provides xxd for build-time.
Remove these settings in Vim's base recipe to avoid duplication and potential conflicts.
--- meta/recipes-support/vim/vim_9.2.bb | 10 ---------- 1 file changed, 10 deletions(-)
meta/recipes-support/vim/vim_9.2.bb +0 -10
@@ -5,8 +5,6 @@ SRC_URI += "file://disable_acl_header_check.patch \ file://no-path-adjust.patch \ " -PROVIDES = "xxd" - RDEPENDS:${PN} = "ncurses-terminfo-base ${PN}-xxd" # Recommend that runtime data is installed along with vim RRECOMMENDS:${PN} = "${PN}-syntax ${PN}-help ${PN}-tutor ${PN}-vimrc ${PN}-common"
@@ -14,14 +12,6 @@ RRECOMMENDS:${PN} = "${PN}-syntax ${PN}-help ${PN}-tutor ${PN}-vimrc ${PN}-commo PACKAGECONFIG:class-native = "" BBCLASSEXTEND = "native nativesdk" -PACKAGES =+ "${PN}-xxd" -FILES:${PN}-xxd = "${bindir}/xxd" -RPROVIDES:${PN}-xxd = "xxd" - -ALTERNATIVE:${PN}-xxd = "xxd" -ALTERNATIVE_TARGET[xxd] = "${bindir}/xxd" -ALTERNATIVE_LINK_NAME[xxd] = "${bindir}/xxd" - # We override the default in security_flags.inc because vim (not vim-tiny!) will abort # in many places for _FORTIFY_SOURCE=2. Security flags become part of CC. #
Signature · 1 line
2.43.0
PATCH v2 4/5 vim.inc: remove xxd from the destination directory
In reply to João Marcos CostaSince the default target depends on xxd, building vim leads to building xxd as well, and this raises (for instance) the error below:
error: check_data_file_clashes: Package vim wants to install file /src/build/tmp/work/qemuriscv64-oe-linux/core-image-minimal/1.0/rootfs/usr/bin/xxd But that file is already provided by package vim-xxd
This is not the ideal approach, because we are just removing something after it is compiled instead of simply not compiling it in the first place.
That being said, merely compiling xxd does not add much (or any?) actual overhead.
--- meta/recipes-support/vim/vim.inc | 4 ++++ 1 file changed, 4 insertions(+)
meta/recipes-support/vim/vim.inc +4 -0
@@ -99,6 +99,10 @@ do_install() { # delete the block. sed -i '/the mouse works just fine/,+4d' ${D}/${datadir}/${BPN}/vimrc fi + + # FIXME: ideally, Vim's makefiles should be tweaked to not build xxd, + # considering xxd (vim-xxd) has its own recipe now + rm ${D}${bindir}/xxd } PARALLEL_MAKEINST = ""
Signature · 1 line
2.43.0
PATCH v2 5/5 base.bbclass: introduce prune_source_tree function
In reply to João Marcos CostaAdd a helper function to be executed after do_unpack, if PRUNE_KEEP_PATHS is defined.
This variable is a list (space-separated) of paths that should be kept, while the others will be pruned. They can be directory names and filenames, but globbing is not supported as of now.
prune_source_tree() is not a task on its own, of course. It belongs in do_unpack's 'postfuncs' list, and also in do_unpack_and_patch (archiver.bbclass): this ensures the archived sources (patched or configured) will also be pruned.
As a concrete example, add PRUNE_KEEP_PATHS to vim-xxd so that vim's sources are deleted and only xxd sources are kept.
--- meta/classes-global/base.bbclass | 49 +++++++++++++++++++++++++ meta/classes/archiver.bbclass | 1 + meta/recipes-support/vim/vim-xxd_9.2.bb | 4 ++ 3 files changed, 54 insertions(+)
meta/classes-global/base.bbclass +49 -0
@@ -256,6 +256,55 @@ python create_source_date_epoch_stamp() { } do_unpack[postfuncs] += "create_source_date_epoch_stamp" +PRUNE_KEEP_PATHS ??= "" +python prune_source_tree() { + import shutil + + # Space-separated list of paths (relative to ${S}) to keep. + # + # Example: + # PRUNE_KEEP_PATHS = "READMEdir/Contents.info src/xxd SECURITY.md" + # + keep_paths = (d.getVar("PRUNE_KEEP_PATHS") or "").split() + + if not keep_paths: + bb.debug(1, "do_unpack: prune_source_tree is disabled") + return + + s = d.getVar("S") + keep_abs = {os.path.abspath(os.path.join(s, p)) for p in keep_paths} + + def should_keep(path): + path = os.path.abspath(path) + + for keep in keep_abs: + if ( + path == keep or # exact match with PRUNE_KEEP_PATHS + path.startswith(keep + os.sep) or # parent directories + keep.startswith(path + os.sep) # child directories + ): + return True + return False + + for root, dirs, _ in os.walk(s, topdown=False): + for d in dirs: + path = os.path.join(root, d) + + if not should_keep(path): + bb.debug(1, "Removing directory: %s" % path) + shutil.rmtree(path) + + # in case there are leftover files: + for root, _, files in os.walk(s): + for f in files: + path = os.path.join(root, f) + + if not should_keep(path): + bb.debug(1, "Removing file: %s" % path) + os.remove(path) +} +do_unpack[postfuncs] .= "${@" prune_source_tree" if d.getVar("PRUNE_KEEP_PATHS") else ''}" + def get_source_date_epoch_value(d): return oe.reproducible.epochfile_read(d.getVar('SDE_FILE'), d)
meta/classes/archiver.bbclass +1 -0
@@ -620,6 +620,7 @@ addtask do_deploy_archives do_build[recrdeptask] += "do_deploy_archives" do_rootfs[recrdeptask] += "do_deploy_archives" do_populate_sdk[recrdeptask] += "do_deploy_archives" +do_unpack_and_patch[postfuncs] .= "${@" prune_source_tree" if d.getVar("PRUNE_KEEP_PATHS") else ''}" python () { # Add tasks in the correct order, specifically for linux-yocto to avoid race condition.
meta/recipes-support/vim/vim-xxd_9.2.bb +4 -0
@@ -16,6 +16,10 @@ inherit update-alternatives PROVIDES += "xxd" +# After unpacking, the files/dirs. outside of this list are removed +# see prune_source_tree() in base.bbclass +PRUNE_KEEP_PATHS = "src/xxd/Makefile src/xxd/xxd.c" + do_compile() { cd ${S}/src/xxd; oe_runmake xxd
Signature · 1 line
2.43.0
Re: [OE-core] [PATCH v2 5/5] base.bbclass: introduce prune_source_tree function
Hi João,
Quoted 7 lines · Joao Marcos Costa via lists.openembedded.org
Add a helper function to be executed after
do_unpack, ifPRUNE_KEEP_PATHSis defined.This variable is a list (space-separated) of paths that should be kept, while the others will be pruned. They can be directory names and filenames, but globbing is not supported as of now.
Quoted 8 lines
prune_source_tree()is not a task on its own, of course. It belongs in do_unpack's 'postfuncs' list, and also indo_unpack_and_patch(archiver.bbclass): this ensures the archived sources (patched or configured) will also be pruned.As a concrete example, add
PRUNE_KEEP_PATHSto vim-xxd so that vim's sources are deleted and only xxd sources are kept.
Have you tried the ;subpath=src/xxd argument in SRC_URI for the git fetcher?
I don't think we care about xxd being removed from vim recipe, but we do not want non-xxd in vim-xxd, so only checking out src/xxd should be enough hopefully?
Cheers,
Quentin
Hi,
I suspect for some reason this is triggering the following error on the Autobuilder:
ERROR: vim-tiny-9.2.0340-r0 do_package_qa: QA Issue: File /usr/src/debug/vim-tiny/9.2.0340/src/auto/pathdef.c in package vim-tiny-src contains reference to TMPDIR [buildpaths]
ERROR: vim-tiny-9.2.0340-r0 do_package_qa: QA Issue: File /usr/bin/vim.tiny in package vim-tiny contains reference to TMPDIR [buildpaths]
ERROR: vim-tiny-9.2.0340-r0 do_package_qa: Fatal QA errors were found, failing task.
https://autobuilder.yoctoproject.org/valkyrie/#/builders/25/builds/3794
https://autobuilder.yoctoproject.org/valkyrie/#/builders/17/builds/3635
https://autobuilder.yoctoproject.org/valkyrie/#/builders/6/builds/3818
Could you try reproducing this on your end?
Thanks,
Antonin
Hello,
Quoted 8 lines · Antonin Godard
Hi,
I suspect for some reason this is triggering the following error on the Autobuilder:
ERROR: vim-tiny-9.2.0340-r0
do_package_qa: QA Issue: File/usr/src/debug/vim-tiny/9.2.0340/src/auto/pathdef.cin package vim-tiny-src contains reference to TMPDIR [buildpaths]
ERROR: vim-tiny-9.2.0340-r0do_package_qa: QA Issue: File/usr/bin/vim.tinyin package vim-tiny contains reference to TMPDIR [buildpaths]
ERROR: vim-tiny-9.2.0340-r0do_package_qa: Fatal QA errors were found, failing task.
Quoted 8 lines
https://autobuilder.yoctoproject.org/valkyrie/#/builders/25/builds/3794
https://autobuilder.yoctoproject.org/valkyrie/#/builders/17/builds/3635
https://autobuilder.yoctoproject.org/valkyrie/#/builders/6/builds/3818Could you try reproducing this on your end?
Thanks,
Antonin
Yep, that comes from no longer applying (by mistake) the patches on vim-tiny. I will fix that in a v3, after collecting other feedbacks. Thanks!
Signature · 2 lines
Best regards, João Marcos Costa
Quoted 28 lines · Joao Marcos Costa via lists.openembedded.org
Hello,
Honestly, my main motivation to send this series comes from a time when I was building u-boot (meta-freescale) and I saw vim-native in Bitbake's tasks. It blew my mind that a bootloader somehow dependend on a text editor (yes, only to be built, not to be executed, I know), and the whole text editor was being built to provide nothing more than xxd.
Just to be clear, what bothers me is NOT u-boot depending on xxd. It is actually configuring and compiling Vim (considering the overhead this represents) only to use a single tiny piece of it.
As for the tests I performed:
- machine: qemuriscv64
- toolchains: clang and gcc
- classes (xxd, vim-xxd): target, native, nativesdk
- classes (vim): target, native, nativesdk
- archiving: the resulting tarball includes only xxd's sources, as expectedSome benchmarks as well, from a previous mail:
vim-native-9.2.0340-r0:
do_configure
Elapsed time: 6.81 secondsvim-native-9.2.0340-r0:
do_compile
Elapsed time: 4.43 seconds
Quoted 7 lines
vim-xxd-native-9.2.0340-r0:
do_configure
Elapsed time: 0.03 secondsvim-xxd-native-9.2.0340-r0:
do_compile
Elapsed time: 0.23 seconds(this data comes from tmp/buildstats)
I appreciate the effort here, but I don't think the ~10 seconds saved during the build justifies the extra complexity in the recipes.
The only dependency on xxd in OE-core is from the dosfsutils ptest. Have we tried running those tests using busybox xxd? If that lacks support for one or two arguments we need it to handle, have we considered submitting patches to busybox to support these?
Alternatively, we could look at tinyxxd [1]. This is based on xxd from vim with a few improvements, as a standalone repo.
[1]: https://github.com/xyproto/tinyxxd
Either of those two options would isolate xxd from vim completely, unblocking removal of vim from OE-core.
Best regards,
Signature · 1 line
Paul Barker
Hello,
Quoted 33 lines · Paul Barker
Quoted 31 lines · Joao Marcos Costa via lists.openembedded.org
Hello,
Honestly, my main motivation to send this series comes from a time when I was building u-boot (meta-freescale) and I saw vim-native in Bitbake's tasks. It blew my mind that a bootloader somehow dependend on a text editor (yes, only to be built, not to be executed, I know), and the whole text editor was being built to provide nothing more than xxd.
Just to be clear, what bothers me is NOT u-boot depending on xxd. It is actually configuring and compiling Vim (considering the overhead this represents) only to use a single tiny piece of it.
As for the tests I performed:
- machine: qemuriscv64
- toolchains: clang and gcc
- classes (xxd, vim-xxd): target, native, nativesdk
- classes (vim): target, native, nativesdk
- archiving: the resulting tarball includes only xxd's sources, as expectedSome benchmarks as well, from a previous mail:
vim-native-9.2.0340-r0:
do_configure
Elapsed time: 6.81 secondsvim-native-9.2.0340-r0:
do_compile
Elapsed time: 4.43 secondsvim-xxd-native-9.2.0340-r0:
do_configure
Elapsed time: 0.03 seconds
Quoted 7 lines
Quoted 4 lines
vim-xxd-native-9.2.0340-r0:
do_compile
Elapsed time: 0.23 seconds(this data comes from tmp/buildstats)
I appreciate the effort here, but I don't think the ~10 seconds saved during the build justifies the extra complexity in the recipes.
The whole difference is far beyond 10 seconds...
This also should include (some, not all) elements in the list of dependencies (see pn-buildlist from bitbake -g vim[-native]) that will no longer need to be built.
Quoted 4 lines
The only dependency on xxd in OE-core is from the dosfsutils ptest. Have we tried running those tests using busybox xxd? If that lacks support for one or two arguments we need it to handle, have we considered submitting patches to busybox to support these?
The only dependency in *oe-core*. My initial concern was other recipes (namely u-boot @ meta-freescale) that may require xxd. After all, a realistic list of layers includes more elements than oe-core itself.
Quoted 10 lines
Alternatively, we could look at tinyxxd [1]. This is based on xxd from vim with a few improvements, as a standalone repo.
[1]: https://github.com/xyproto/tinyxxd
Either of those two options would isolate xxd from vim completely, unblocking removal of vim from OE-core.
Best regards,
I still prefer the "complex" way that keeps xxd as it is (i.e., the same source code currently used), without far less risk of regressions in recipes from oe-core and/or 3rd party layers.
Signature · 2 lines
Best regards, João Marcos Costa