[RFC] bitbake.conf: Add base package version (BPV) variable

Message ID 20220330081614.12772-1-stefan.herbrechtsmeier-oss@weidmueller.com
State New
Headers show
Series [RFC] bitbake.conf: Add base package version (BPV) variable | expand

Commit Message

Stefan Herbrechtsmeier March 30, 2022, 8:16 a.m. UTC
From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

Add a base package version (BPV) variable and use it as default for the
package version (PV) variable. The BPV variable contains the base
package version of the recipe read from the recipe filename.

The base package version variable supports an expansion of the version
from the recipe filename without the need of an immediate variable
expansion:
    PV = "${BPV}+git${SRCPV}"

It allows the inclusion of include files inside a recipe file with the
same version in the recipe and include filename even if the package
version is different to the base package version in the filename:
    require linux-yocto-${BPV}.inc

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>

---

 meta/conf/bitbake.conf | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Alexander Kanavin March 30, 2022, 8:41 a.m. UTC | #1
Mangling PV is more flexibly done with a lambda function in the
recipe, where you can trim and tweak PV to your heart's desire, e.g.
gnomebase.bbclass:

def gnome_verdir(v):
    return ".".join(v.split(".")[:-1])

SRC_URI = "${GNOME_MIRROR}/${GNOMEBN}/${@gnome_verdir("${PV}")}/${GNOMEBN}-${PV}.tar.${GNOME_COMPRESS_TYPE};name=archive"

Alex

On Wed, 30 Mar 2022 at 10:16, Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> Add a base package version (BPV) variable and use it as default for the
> package version (PV) variable. The BPV variable contains the base
> package version of the recipe read from the recipe filename.
>
> The base package version variable supports an expansion of the version
> from the recipe filename without the need of an immediate variable
> expansion:
>     PV = "${BPV}+git${SRCPV}"
>
> It allows the inclusion of include files inside a recipe file with the
> same version in the recipe and include filename even if the package
> version is different to the base package version in the filename:
>     require linux-yocto-${BPV}.inc
>
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> ---
>
>  meta/conf/bitbake.conf | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 7705415a4f..d56cf811ba 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -232,7 +232,8 @@ ASSUME_PROVIDED = "\
>  ##################################################################
>
>  PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
> -PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> +BPV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> +PV = "${BPV}"
>  PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
>  PE = ""
>  PF = "${PN}-${EXTENDPE}${PV}-${PR}"
> --
> 2.30.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#163774): https://lists.openembedded.org/g/openembedded-core/message/163774
> Mute This Topic: https://lists.openembedded.org/mt/90127138/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Alexander Kanavin March 30, 2022, 8:41 a.m. UTC | #2
Not lambda in this case, but nevermind :)

Alex

On Wed, 30 Mar 2022 at 10:41, Alexander Kanavin <alex.kanavin@gmail.com> wrote:
>
> Mangling PV is more flexibly done with a lambda function in the
> recipe, where you can trim and tweak PV to your heart's desire, e.g.
> gnomebase.bbclass:
>
> def gnome_verdir(v):
>     return ".".join(v.split(".")[:-1])
>
> SRC_URI = "${GNOME_MIRROR}/${GNOMEBN}/${@gnome_verdir("${PV}")}/${GNOMEBN}-${PV}.tar.${GNOME_COMPRESS_TYPE};name=archive"
>
> Alex
>
> On Wed, 30 Mar 2022 at 10:16, Stefan Herbrechtsmeier
> <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
> >
> > From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> >
> > Add a base package version (BPV) variable and use it as default for the
> > package version (PV) variable. The BPV variable contains the base
> > package version of the recipe read from the recipe filename.
> >
> > The base package version variable supports an expansion of the version
> > from the recipe filename without the need of an immediate variable
> > expansion:
> >     PV = "${BPV}+git${SRCPV}"
> >
> > It allows the inclusion of include files inside a recipe file with the
> > same version in the recipe and include filename even if the package
> > version is different to the base package version in the filename:
> >     require linux-yocto-${BPV}.inc
> >
> > Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> >
> > ---
> >
> >  meta/conf/bitbake.conf | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> > index 7705415a4f..d56cf811ba 100644
> > --- a/meta/conf/bitbake.conf
> > +++ b/meta/conf/bitbake.conf
> > @@ -232,7 +232,8 @@ ASSUME_PROVIDED = "\
> >  ##################################################################
> >
> >  PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
> > -PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> > +BPV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> > +PV = "${BPV}"
> >  PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
> >  PE = ""
> >  PF = "${PN}-${EXTENDPE}${PV}-${PR}"
> > --
> > 2.30.2
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#163774): https://lists.openembedded.org/g/openembedded-core/message/163774
> > Mute This Topic: https://lists.openembedded.org/mt/90127138/1686489
> > Group Owner: openembedded-core+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
Stefan Herbrechtsmeier March 30, 2022, 11:42 a.m. UTC | #3
Hi Alex,

Am 30.03.2022 um 10:41 schrieb Alexander Kanavin:
> Mangling PV is more flexibly done with a lambda function in the
> recipe, where you can trim and tweak PV to your heart's desire, e.g.
> gnomebase.bbclass:
> 
> def gnome_verdir(v):
>      return ".".join(v.split(".")[:-1])
> 
> SRC_URI = "${GNOME_MIRROR}/${GNOMEBN}/${@gnome_verdir("${PV}")}/${GNOMEBN}-${PV}.tar.${GNOME_COMPRESS_TYPE};name=archive"

What is the intention of your comment? Do you recommend a function per 
recipe and thereby code duplication?

Or is your objection that the base package version isn't always the file 
name version and the variable name is wrong?

The advantage of the BPV is that you can change the PV outside of the 
recipe file:

PV:pn-<package_name> = "${BPV}+git${SRCPV}"

The `PV .= "+git${SRCPV}"` assume that the PV is the base package 
version but couldn't ensure it.

Regards
   Stefan

> On Wed, 30 Mar 2022 at 10:16, Stefan Herbrechtsmeier
> <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>>
>> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>
>> Add a base package version (BPV) variable and use it as default for the
>> package version (PV) variable. The BPV variable contains the base
>> package version of the recipe read from the recipe filename.
>>
>> The base package version variable supports an expansion of the version
>> from the recipe filename without the need of an immediate variable
>> expansion:
>>      PV = "${BPV}+git${SRCPV}"
>>
>> It allows the inclusion of include files inside a recipe file with the
>> same version in the recipe and include filename even if the package
>> version is different to the base package version in the filename:
>>      require linux-yocto-${BPV}.inc
>>
>> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>
>> ---
>>
>>   meta/conf/bitbake.conf | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
>> index 7705415a4f..d56cf811ba 100644
>> --- a/meta/conf/bitbake.conf
>> +++ b/meta/conf/bitbake.conf
>> @@ -232,7 +232,8 @@ ASSUME_PROVIDED = "\
>>   ##################################################################
>>
>>   PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
>> -PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
>> +BPV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
>> +PV = "${BPV}"
>>   PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
>>   PE = ""
>>   PF = "${PN}-${EXTENDPE}${PV}-${PR}"
>> --
>> 2.30.2
>>
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> View/Reply Online (#163774): https://lists.openembedded.org/g/openembedded-core/message/163774
>> Mute This Topic: https://lists.openembedded.org/mt/90127138/1686489
>> Group Owner: openembedded-core+owner@lists.openembedded.org
>> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
Alexander Kanavin March 30, 2022, 11:46 a.m. UTC | #4
The intention is that changing bitbake.conf is heavy handed, and the
use case is not well presented. Why and where this is needed?

Alex

On Wed, 30 Mar 2022 at 13:42, Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>
> Hi Alex,
>
> Am 30.03.2022 um 10:41 schrieb Alexander Kanavin:
> > Mangling PV is more flexibly done with a lambda function in the
> > recipe, where you can trim and tweak PV to your heart's desire, e.g.
> > gnomebase.bbclass:
> >
> > def gnome_verdir(v):
> >      return ".".join(v.split(".")[:-1])
> >
> > SRC_URI = "${GNOME_MIRROR}/${GNOMEBN}/${@gnome_verdir("${PV}")}/${GNOMEBN}-${PV}.tar.${GNOME_COMPRESS_TYPE};name=archive"
>
> What is the intention of your comment? Do you recommend a function per
> recipe and thereby code duplication?
>
> Or is your objection that the base package version isn't always the file
> name version and the variable name is wrong?
>
> The advantage of the BPV is that you can change the PV outside of the
> recipe file:
>
> PV:pn-<package_name> = "${BPV}+git${SRCPV}"
>
> The `PV .= "+git${SRCPV}"` assume that the PV is the base package
> version but couldn't ensure it.
>
> Regards
>    Stefan
>
> > On Wed, 30 Mar 2022 at 10:16, Stefan Herbrechtsmeier
> > <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
> >>
> >> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> >>
> >> Add a base package version (BPV) variable and use it as default for the
> >> package version (PV) variable. The BPV variable contains the base
> >> package version of the recipe read from the recipe filename.
> >>
> >> The base package version variable supports an expansion of the version
> >> from the recipe filename without the need of an immediate variable
> >> expansion:
> >>      PV = "${BPV}+git${SRCPV}"
> >>
> >> It allows the inclusion of include files inside a recipe file with the
> >> same version in the recipe and include filename even if the package
> >> version is different to the base package version in the filename:
> >>      require linux-yocto-${BPV}.inc
> >>
> >> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> >>
> >> ---
> >>
> >>   meta/conf/bitbake.conf | 3 ++-
> >>   1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> >> index 7705415a4f..d56cf811ba 100644
> >> --- a/meta/conf/bitbake.conf
> >> +++ b/meta/conf/bitbake.conf
> >> @@ -232,7 +232,8 @@ ASSUME_PROVIDED = "\
> >>   ##################################################################
> >>
> >>   PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
> >> -PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> >> +BPV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> >> +PV = "${BPV}"
> >>   PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
> >>   PE = ""
> >>   PF = "${PN}-${EXTENDPE}${PV}-${PR}"
> >> --
> >> 2.30.2
> >>
> >>
> >> -=-=-=-=-=-=-=-=-=-=-=-
> >> Links: You receive all messages sent to this group.
> >> View/Reply Online (#163774): https://lists.openembedded.org/g/openembedded-core/message/163774
> >> Mute This Topic: https://lists.openembedded.org/mt/90127138/1686489
> >> Group Owner: openembedded-core+owner@lists.openembedded.org
> >> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> >> -=-=-=-=-=-=-=-=-=-=-=-
> >>
Richard Purdie March 30, 2022, 11:51 a.m. UTC | #5
On Wed, 2022-03-30 at 10:16 +0200, Stefan Herbrechtsmeier wrote:
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> Add a base package version (BPV) variable and use it as default for the
> package version (PV) variable. The BPV variable contains the base
> package version of the recipe read from the recipe filename.
> 
> The base package version variable supports an expansion of the version
> from the recipe filename without the need of an immediate variable
> expansion:
>     PV = "${BPV}+git${SRCPV}"
> 
> It allows the inclusion of include files inside a recipe file with the
> same version in the recipe and include filename even if the package
> version is different to the base package version in the filename:
>     require linux-yocto-${BPV}.inc
> 
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> 
> ---
> 
>  meta/conf/bitbake.conf | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 7705415a4f..d56cf811ba 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -232,7 +232,8 @@ ASSUME_PROVIDED = "\
>  ##################################################################
>  
>  PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
> -PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> +BPV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> +PV = "${BPV}"
>  PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
>  PE = ""
>  PF = "${PN}-${EXTENDPE}${PV}-${PR}"

I'm not really seeing a compelling use case for what is a fairly core change,
you've not really said why we need changes and what the big win is for users.

I'm also quite worried that this behaves quite differently to BPN. "base" in the
case of PN means strip off prefixes and suffixes yet here, BPV doesn't actually
strip anything off PV, you're just expected to set it differently yourself as
the user. The different usage semantics will likely confuse people and that
confusion isn't worth it IMO.

Cheers,

Richard
Stefan Herbrechtsmeier March 30, 2022, 4:23 p.m. UTC | #6
Hi Richard,

Am 30.03.2022 um 13:51 schrieb Richard Purdie:
> On Wed, 2022-03-30 at 10:16 +0200, Stefan Herbrechtsmeier wrote:
>> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>
>> Add a base package version (BPV) variable and use it as default for the
>> package version (PV) variable. The BPV variable contains the base
>> package version of the recipe read from the recipe filename.
>>
>> The base package version variable supports an expansion of the version
>> from the recipe filename without the need of an immediate variable
>> expansion:
>>      PV = "${BPV}+git${SRCPV}"
>>
>> It allows the inclusion of include files inside a recipe file with the
>> same version in the recipe and include filename even if the package
>> version is different to the base package version in the filename:
>>      require linux-yocto-${BPV}.inc
>>
>> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>
>> ---
>>
>>   meta/conf/bitbake.conf | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
>> index 7705415a4f..d56cf811ba 100644
>> --- a/meta/conf/bitbake.conf
>> +++ b/meta/conf/bitbake.conf
>> @@ -232,7 +232,8 @@ ASSUME_PROVIDED = "\
>>   ##################################################################
>>   
>>   PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
>> -PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
>> +BPV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
>> +PV = "${BPV}"
>>   PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
>>   PE = ""
>>   PF = "${PN}-${EXTENDPE}${PV}-${PR}"
> 
> I'm not really seeing a compelling use case for what is a fairly core change,
> you've not really said why we need changes and what the big win is for users.

binutils_2.32.bb:
   require binutils-${PV}.inc
binutils-2.32.inc:
   PV = "2.32.0"
   CVE_VERSION = "2.32"

cdrtools-native_3.01.bb:
   PV = "3.01a31+really3.01"
   REALPV = "3.01"
   S = "${WORKDIR}/${BPN}-${REALPV}"

gcc-cross_8.3.bb:
   require recipes-devtools/gcc/gcc-${PV}.inc
gcc-8.3.inc:
   PV = "8.3.0"

gdk-pixbuf_2.38.0.bb:
   MAJ_VER = "${@oe.utils.trim_version("${PV}", 2)}"

util-linux.inc:
   MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"

Does the binutils and gcc-cross trick works inside a bbappend? The other 
examples could benefit from a variable.

> I'm also quite worried that this behaves quite differently to BPN. "base" in the
> case of PN means strip off prefixes and suffixes yet here, BPV doesn't actually
> strip anything off PV, you're just expected to set it differently yourself as
> the user. The different usage semantics will likely confuse people and that
> confusion isn't worth it IMO.

BPV = "${@oe.utils.trim_version("${PV}", 3)}"

This would make it inline with the BPN but disallow the usage of the 
variable inside the PV itself.

Until now I don't know the oe.utils.trim_version function.

Regards
   Stefan
Khem Raj March 30, 2022, 5:32 p.m. UTC | #7
On Wed, Mar 30, 2022 at 1:16 AM Stefan Herbrechtsmeier
<stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> Add a base package version (BPV) variable and use it as default for the
> package version (PV) variable. The BPV variable contains the base
> package version of the recipe read from the recipe filename.
>
> The base package version variable supports an expansion of the version
> from the recipe filename without the need of an immediate variable
> expansion:
>     PV = "${BPV}+git${SRCPV}"
>
> It allows the inclusion of include files inside a recipe file with the
> same version in the recipe and include filename even if the package
> version is different to the base package version in the filename:
>     require linux-yocto-${BPV}.inc
>

how many such usecase do we have ? seems to be quite errorprone too.

> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> ---
>
>  meta/conf/bitbake.conf | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
> index 7705415a4f..d56cf811ba 100644
> --- a/meta/conf/bitbake.conf
> +++ b/meta/conf/bitbake.conf
> @@ -232,7 +232,8 @@ ASSUME_PROVIDED = "\
>  ##################################################################
>
>  PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
> -PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> +BPV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
> +PV = "${BPV}"
>  PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
>  PE = ""
>  PF = "${PN}-${EXTENDPE}${PV}-${PR}"
> --
> 2.30.2
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#163774): https://lists.openembedded.org/g/openembedded-core/message/163774
> Mute This Topic: https://lists.openembedded.org/mt/90127138/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Stefan Herbrechtsmeier March 31, 2022, 7:15 a.m. UTC | #8
Am 30.03.2022 um 19:32 schrieb Khem Raj:
> On Wed, Mar 30, 2022 at 1:16 AM Stefan Herbrechtsmeier
> <stefan.herbrechtsmeier-oss@weidmueller.com> wrote:
>>
>> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>>
>> Add a base package version (BPV) variable and use it as default for the
>> package version (PV) variable. The BPV variable contains the base
>> package version of the recipe read from the recipe filename.
>>
>> The base package version variable supports an expansion of the version
>> from the recipe filename without the need of an immediate variable
>> expansion:
>>      PV = "${BPV}+git${SRCPV}"
>>
>> It allows the inclusion of include files inside a recipe file with the
>> same version in the recipe and include filename even if the package
>> version is different to the base package version in the filename:
>>      require linux-yocto-${BPV}.inc
>>
> 
> how many such usecase do we have ?

4x require binutils-${PV}.inc
9x require recipes-devtools/gcc/gcc-${PV}.inc
6x require go-${PV}.inc
4x require libtool-${PV}.inc
2x require m4-${PV}.inc
1x require boost-${PV}.inc

Thereby binutils and gcc set the real PV inside the .inc file.

> seems to be quite errorprone too.

The current use cases in oe core is much more error-prone because they 
use ${PV} and set the PV inside the .inc file. This means a second .inc 
file must use the new PV. Furthermore, if somebody in oe-core add a `PV 
.= "+git${SRCPV}"` it breaks includes in other layers.

A MAIN_VERSION (MAJOR.MINOR) and a BPV (MAJOR.MINOR.PATCH) would make 
the use case explicit:

require binutils-${MAIN_VERSION}.inc
require recipes-devtools/gcc/gcc-${MAIN_VERSION}.inc
require go-${BPV}.inc
require libtool-${BPV}.inc
require m4-${BPV}.inc
require boost-${BPV}.inc


At the moment oe-core have recipe specific names and code for the same 
value:

MAJOR.MINOR.PATCH:
MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"
CMAKE_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"

MAJOR.MINOR:
WESTON_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:1])}"
SHRT_VER = 
"${@d.getVar('PV').split('.')[0]}.${@d.getVar('PV').split('.')[1]}"
VIMDIR = 
"vim${@d.getVar('PV').split('.')[0]}${@d.getVar('PV').split('.')[1]}"
SHRT_VER = "${@oe.utils.trim_version("${PV}", 2)}"
NAMEVER = "${@oe.utils.trim_version("${PV}", 2)}"
SHRT_VER = "${@oe.utils.trim_version("${PV}", 2)}"
MAJ_VER = "${@oe.utils.trim_version("${PV}", 2)}"
MAJ_VER = "${@oe.utils.trim_version("${PV}", 2)}"
MAJ_VER = "${@oe.utils.trim_version("${PV}", 2)}"

MAJOR:
MAJ_VER = "${@oe.utils.trim_version("${PV}", 2).split('.')[0]}"
ICU_MAJOR_VER = "${@d.getVar('PV').split('.')[0]}"

MINOR:
MIN_VER = "${@oe.utils.trim_version("${PV}", 2).split('.')[1]}"


Sometimes the same name is used for different values:

MAJOR_VERSION = "${@oe.utils.trim_version("${PV}", 1)}"
WESTON_MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:1])}"
MAJOR_VERSION = "${@'.'.join(d.getVar('PV').split('.')[0:2])}"

Maybe the bitbake.conf isn't the ride place but I think a common name 
for the base / short version (MAJOR.MINOR), base package version 
(MAJOR.MINOR.PATCH) and major, minor and patch would be helpful.

Patch

diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index 7705415a4f..d56cf811ba 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -232,7 +232,8 @@  ASSUME_PROVIDED = "\
 ##################################################################
 
 PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
-PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
+BPV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
+PV = "${BPV}"
 PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
 PE = ""
 PF = "${PN}-${EXTENDPE}${PV}-${PR}"