vim: put xxd in its own package

Message ID 20220608074245.1962967-1-rasmus.villemoes@prevas.dk
State Accepted, archived
Commit 06ed2aa93fc25a681e3a00ee120d9395b04845da
Headers show
Series vim: put xxd in its own package | expand

Commit Message

Rasmus Villemoes June 8, 2022, 7:42 a.m. UTC
The xxd tool can be quite handy by itself, and doesn't have anything
to do with vim per se. Make it possible to include the rather tiny xxd
in a rootfs without pulling in the several MB vim binary and
associated data.

For backwards compatibility, add an RDEPENDS from the main package to
the new vim-xxd package.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 meta/recipes-support/vim/vim_8.2.bb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Paulo Neves June 8, 2022, 11:58 a.m. UTC | #1
Forgive me if it is a stupid question, but does xxd not rdepend on ncurses-terminfo-base as well? I ask because before your patch it could was implied it that it did, s part of PN.
Rasmus Villemoes June 8, 2022, 12:13 p.m. UTC | #2
On 08/06/2022 13.58, Paulo Neves via lists.openembedded.org wrote:
> Forgive me if it is a stupid question, but does xxd not rdepend on
> ncurses-terminfo-base as well?

No, it does not, it's a trivial standalone utility whose only dynamic
dependency is libc.

> I ask because before your patch it could
> was implied it that it did, s part of PN.

I don't understand what you're trying to say. I just put the extra
RDEPENDS from vim to vim-xxd into the existing RDEPENDS:vim line. That
doesn't imply any dependency either way between the two items listed on
the RHS.

Rasmus
Paulo Neves June 8, 2022, 12:30 p.m. UTC | #3
On 6/8/22 14:13, Rasmus Villemoes wrote:

> On 08/06/2022 13.58, Paulo Neves via lists.openembedded.org wrote:
>> Forgive me if it is a stupid question, but does xxd not rdepend on
>> ncurses-terminfo-base as well?
> No, it does not, it's a trivial standalone utility whose only dynamic
> dependency is libc.

The original RDEPENDS on ncurses-terminfo-base is not about dynamic
libraries but about terminfo files that are used for describing capabilities
of terminals. They are usually in /etc/terminfo directory.
There are programs that load these files and without them will
display broken output our refuse to run. vim seemed to be one of those programs.
Have you tested that xxd works without these files?

>> I ask because before your patch it could
>> was implied it that it did, s part of PN.
> I don't understand what you're trying to say. I just put the extra
> RDEPENDS from vim to vim-xxd into the existing RDEPENDS:vim line. That
> doesn't imply any dependency either way between the two items listed on
> the RHS.

I mean that your patch allows for a new standalone package ${PN}-xxd.
Were somebody to use this package standalone, meaning without installing vim,
the ncurses-terminfo-base would not be installed, possibly breaking xxd.

Before your patch this risk did not occur due to xxd being include in the ${PN}
which had an RDEPENDS to ncurses-terminfo-base.

> Rasmus

Paulo Neves
Rasmus Villemoes June 8, 2022, 12:36 p.m. UTC | #4
On 08/06/2022 14.30, Paulo Neves wrote:
> On 6/8/22 14:13, Rasmus Villemoes wrote:
> 
>> On 08/06/2022 13.58, Paulo Neves via lists.openembedded.org wrote:
> I mean that your patch allows for a new standalone package ${PN}-xxd.
> Were somebody to use this package standalone, meaning without installing vim,
> the ncurses-terminfo-base would not be installed, possibly breaking xxd.
> 
> Before your patch this risk did not occur due to xxd being include in the ${PN}
> which had an RDEPENDS to ncurses-terminfo-base.

Thanks, now I understand what you were saying. And no, xxd does not in
any way depend on those terminfo files; it's a simple utility for
converting binary files to hex (or the reverse, which is what I happen
to need, taking input in the form of ascii hex chars and producing
binary output). Yes, I've tested it on target as well.

Rasmus
Paulo Neves June 8, 2022, 1:34 p.m. UTC | #5
Looks good to me then ;) Had a look at the code [1] and indeed it is a 
very minimal standalone binary.

Grateful for your patience
Paulo Neves

[1] https://github.com/vim/vim/blob/master/src/xxd/xxd.c

On 6/8/22 14:36, Rasmus Villemoes wrote:
> On 08/06/2022 14.30, Paulo Neves wrote:
>> On 6/8/22 14:13, Rasmus Villemoes wrote:
>>
>>> On 08/06/2022 13.58, Paulo Neves via lists.openembedded.org wrote:
>> I mean that your patch allows for a new standalone package ${PN}-xxd.
>> Were somebody to use this package standalone, meaning without installing vim,
>> the ncurses-terminfo-base would not be installed, possibly breaking xxd.
>>
>> Before your patch this risk did not occur due to xxd being include in the ${PN}
>> which had an RDEPENDS to ncurses-terminfo-base.
> Thanks, now I understand what you were saying. And no, xxd does not in
> any way depend on those terminfo files; it's a simple utility for
> converting binary files to hex (or the reverse, which is what I happen
> to need, taking input in the form of ascii hex chars and producing
> binary output). Yes, I've tested it on target as well.
>
> Rasmus
Tom Rini June 8, 2022, 1:54 p.m. UTC | #6
On Wed, Jun 08, 2022 at 09:42:45AM +0200, Rasmus Villemoes wrote:

> The xxd tool can be quite handy by itself, and doesn't have anything
> to do with vim per se. Make it possible to include the rather tiny xxd
> in a rootfs without pulling in the several MB vim binary and
> associated data.
> 
> For backwards compatibility, add an RDEPENDS from the main package to
> the new vim-xxd package.
> 
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>

Reviewed-by: Tom Rini <trini@konsulko.com>

Patch

diff --git a/meta/recipes-support/vim/vim_8.2.bb b/meta/recipes-support/vim/vim_8.2.bb
index f358e61132b..fee9f055e9a 100644
--- a/meta/recipes-support/vim/vim_8.2.bb
+++ b/meta/recipes-support/vim/vim_8.2.bb
@@ -2,14 +2,18 @@  require vim.inc
 
 PROVIDES = "xxd"
 
-RDEPENDS:${PN} = "ncurses-terminfo-base"
+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"
 
 PACKAGECONFIG:class-native = ""
 BBCLASSEXTEND = "native nativesdk"
 
-ALTERNATIVE:${PN}:append = " xxd"
+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"