Skip to contentSkip to conversation

iputils (meson build system) has git version from buildroot instead of iputils

RFC Petr Vorel 3 participants 4 messages May 10, 2022 – May 15, 2022

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

Hi all,

meson.build [1] uses git-version.h.meson [2] to produce BUILD_DIRECTORY/git-version.h.

Building from sources (not in Buildroot) it works:

$ head -1 builddir/git-version.h
#define PACKAGE_VERSION "20211215-15-g309f285"

But building in Buildroot it gets git version from Buildroot:

$ head -1 output/build/iputils-20211215/build/git-version.h
#define PACKAGE_VERSION "2022.02-876-g3ef096786a"

Is it a bug in iputils or in Buildroot meson?
Any idea how to fix it?

Kind regards,
Petr

[1] https://github.com/iputils/iputils/blob/master/meson.build#L14
[2] https://github.com/iputils/iputils/blob/master/git-version.h.meson
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#1 lore raw

Hi Petr,

Quoted 6 lines · Petr Vorel

Hi all,

meson.build [1] uses git-version.h.meson [2] to produce BUILD_DIRECTORY/git-version.h.

Building from sources (not in Buildroot) it works:

Quoted 8 lines
$ head -1 builddir/git-version.h
#define PACKAGE_VERSION "20211215-15-g309f285"

But building in Buildroot it gets git version from Buildroot:

$ head -1 output/build/iputils-20211215/build/git-version.h
#define PACKAGE_VERSION "2022.02-876-g3ef096786a"

Is it a bug in iputils or in Buildroot meson?

This issue is raised because, in the context of buildroot, iputils is retrieved as a tarball, not a git clone.
So meson's vcs_tag will retrieve the git information from buildroot and will not use its fallback (i.e. meson.project_version()).

To fix it, there is three "simple" options:
- allow buildroot to configure the version (as already done in
open62541 package)
- don't use vcs_tag and always set package_version to
meson.project_version() outside of a "devel" mode as done for example in gnome console [1]
- override the default vcs command in vcs_tag call (e.g. command:
'git --git-dir=.git describe --dirty=+')

Another option would be to patch meson so vcs_tag is always run with "--git-dir=.git".
This is probably the more correct option as this issue is probably affecting other packages than iputils.
However, from my experience in meson, getting something merged upstream can take a very very long time (e.g. more than two years for a prefer_static option [2])
I don't know if this is completely related but this issue on vcs_tag is opened for more than one year [3] ...

Quoted 7 lines

Any idea how to fix it?

Kind regards,
Petr

[1] https://github.com/iputils/iputils/blob/master/meson.build#L14
[2] https://github.com/iputils/iputils/blob/master/git-version.h.meson

Best Regards,

Fabrice

[1] https://gitlab.gnome.org/GNOME/console/-/blob/main/meson.build#L35
[2] https://github.com/mesonbuild/meson/pull/6629
[3] https://github.com/mesonbuild/meson/issues/8567
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
Quoted 12 lines · Fabrice Fontaine

Hi Petr,

Quoted 9 lines · Petr Vorel

Hi all,

meson.build [1] uses git-version.h.meson [2] to produce BUILD_DIRECTORY/git-version.h.

Building from sources (not in Buildroot) it works:

$ head -1 builddir/git-version.h
#define PACKAGE_VERSION "20211215-15-g309f285"
Quoted 8 lines
Quoted 5 lines

But building in Buildroot it gets git version from Buildroot:

$ head -1 output/build/iputils-20211215/build/git-version.h
#define PACKAGE_VERSION "2022.02-876-g3ef096786a"

Is it a bug in iputils or in Buildroot meson?

This issue is raised because, in the context of buildroot, iputils is retrieved as a tarball, not a git clone.

This would be the case even if we take it from a it clone, because we first
archive the tree in a tarball and then extract the tarball in the build directory (i.e. without the .git directory).

Note also that this only happens if your output directory is below the
Buildroot tree. On the other hand, if you put your output directory, for example, under a BR2_EXTERNAL repository (which is what I usually do), then it will take the version from that repo.

Quoted 11 lines

So meson's vcs_tag will retrieve the git information from buildroot and will not use its fallback (i.e. meson.project_version()).

To fix it, there is three "simple" options:
- allow buildroot to configure the version (as already done in
open62541 package)
- don't use vcs_tag and always set package_version to
meson.project_version() outside of a "devel" mode as done for example in gnome console [1]
- override the default vcs command in vcs_tag call (e.g. command:
'git --git-dir=.git describe --dirty=+')

This is a problem for all packages, not just iputils.

I think a solution could be to

export GIT_CEILING_DIRECTORIES = $(OUTPUT_DIR)

That way, git won't travel up to the buildroot directory. Should be tested with putting the output directory in various places, and also with putting DL_DIR below OUTPUT_DIR or equal to OUTPUT_DIR and downloading git packages.

Regards,
Arnout

Quoted 19 lines

Another option would be to patch meson so vcs_tag is always run with "--git-dir=.git".
This is probably the more correct option as this issue is probably affecting other packages than iputils.
However, from my experience in meson, getting something merged upstream can take a very very long time (e.g. more than two years for a prefer_static option [2])
I don't know if this is completely related but this issue on vcs_tag is opened for more than one year [3] ...

Quoted 7 lines

Any idea how to fix it?

Kind regards,
Petr

[1] https://github.com/iputils/iputils/blob/master/meson.build#L14
[2] https://github.com/iputils/iputils/blob/master/git-version.h.meson

Quoted 7 lines

Best Regards,

Fabrice

[1] https://gitlab.gnome.org/GNOME/console/-/blob/main/meson.build#L35
[2] https://github.com/mesonbuild/meson/pull/6629
[3] https://github.com/mesonbuild/meson/issues/8567

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

author
#3 lore raw

Hi Fabrice, Arnout,

thanks a lot for a valuable info.

...

Quoted 15 lines
Quoted 6 lines
Quoted 5 lines

meson.build [1] uses git-version.h.meson [2] to produce BUILD_DIRECTORY/git-version.h.

Building from sources (not in Buildroot) it works:

$ head -1 builddir/git-version.h
#define PACKAGE_VERSION "20211215-15-g309f285"
Quoted 8 lines
Quoted 5 lines

But building in Buildroot it gets git version from Buildroot:

$ head -1 output/build/iputils-20211215/build/git-version.h
#define PACKAGE_VERSION "2022.02-876-g3ef096786a"

Is it a bug in iputils or in Buildroot meson?

This issue is raised because, in the context of buildroot, iputils is retrieved as a tarball, not a git clone.

Quoted 8 lines

This would be the case even if we take it from a it clone, because we first
archive the tree in a tarball and then extract the tarball in the build directory (i.e. without the .git directory).

Note also that this only happens if your output directory is below the
Buildroot tree. On the other hand, if you put your output directory, for example, under a BR2_EXTERNAL repository (which is what I usually do), then it will take the version from that repo.

Right, I'll usually keep the default BR2_EXTERNAL.

Quoted 14 lines
Quoted 11 lines

So meson's vcs_tag will retrieve the git information from buildroot and will not use its fallback (i.e. meson.project_version()).

To fix it, there is three "simple" options:
- allow buildroot to configure the version (as already done in
open62541 package)
- don't use vcs_tag and always set package_version to
meson.project_version() outside of a "devel" mode as done for example in gnome console [1]
- override the default vcs command in vcs_tag call (e.g. command:
'git --git-dir=.git describe --dirty=+')

This is a problem for all packages, not just iputils.

Quoted 7 lines

I think a solution could be to

export GIT_CEILING_DIRECTORIES = $(OUTPUT_DIR)

That way, git won't travel up to the buildroot directory. Should be tested with putting the output directory in various places, and also with putting DL_DIR below OUTPUT_DIR or equal to OUTPUT_DIR and downloading git packages.

I'll try to do some testing soon. Obviously I prefer general solution, fixing by setting variable would be easier than trying to merge anything in meson upstream (if needed I'd open PR in upstream, just for a record of the problem).

Kind regards,
Petr

Quoted 29 lines

Regards,
Arnout

Quoted 25 lines

Another option would be to patch meson so vcs_tag is always run with "--git-dir=.git".
This is probably the more correct option as this issue is probably affecting other packages than iputils.
However, from my experience in meson, getting something merged upstream can take a very very long time (e.g. more than two years for a prefer_static option [2])
I don't know if this is completely related but this issue on vcs_tag is opened for more than one year [3] ...

Quoted 7 lines

Any idea how to fix it?

Kind regards,
Petr

[1] https://github.com/iputils/iputils/blob/master/meson.build#L14
[2] https://github.com/iputils/iputils/blob/master/git-version.h.meson

Best Regards,

Fabrice

[1] https://gitlab.gnome.org/GNOME/console/-/blob/main/meson.build#L35
[2] https://github.com/mesonbuild/meson/pull/6629
[3] https://github.com/mesonbuild/meson/issues/8567

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot