Skip to contentSkip to conversation

A case of distro config overriding DISTRO var

RFC Paul Sokolovsky 2 participants 10 messages Jan 28, 2008 – Feb 9, 2008

lore
Share & tools
lore
#0 lore raw

Hello,

I'd like to know what's the idea behind overriding DISTRO var from the value being set by user? For example, angstrom.inc does:

DISTRO = "angstrom"

The problem with is that real distro name is lost, as thus cannot be passed to some other tool (e.g., bbimage).

If there're good reasons to do that, and we would be lazy enough to convert to something like: DISTRO_FOO = "${DISTRO}" in bitbake.conf, and let those good reasons apply to DISTRO_FOO, which must replace DISTRO in the appropriate places, then I at least propose to do:

DISTRO_ORIGINAL := "${DISTRO}"

in bitbake.conf, so we always have real distro config name handy.

Signature · 2 lines
Best regards,
 Paul                          mailto:[email protected]
#1 lore raw
Quoted 4 lines · Paul Sokolovsky

I'd like to know what's the idea behind overriding DISTRO var from the value being set by user? For example, angstrom.inc does:

DISTRO = "angstrom"

It means that the override in active use becomes "angstrom" and we don't have 1001 different overrides (angstrom2007, angstrom1008 etc.) all over the tree.

Quoted 11 lines

The problem with is that real distro name is lost, as thus cannot be passed to some other tool (e.g., bbimage).

If there're good reasons to do that, and we would be lazy enough to convert to something like: DISTRO_FOO = "${DISTRO}" in bitbake.conf, and let those good reasons apply to DISTRO_FOO, which must replace DISTRO in the appropriate places, then I at least propose to do:

DISTRO_ORIGINAL := "${DISTRO}"

in bitbake.conf, so we always have real distro config name handy.

What you didn't say is where exactly in bitbake.conf you are going to define that?

You need to put the := directly before the code that changes DISTRO. Yes, you could add this in bitbake.conf after local.conf and before including ${DISTRO}.conf but that seems ugly to me.

I'd prefer USERDISTRO = "${DISTRO}" in bitbake.conf and then having angstrom overriding that using := if it really has to...

Regards,

Richard

#2 lore raw

Hello Richard,

Quoted 9 lines · On Mon, 28 Jan 2008 23:22:50 +0000 Richard Purdie <[email protected]> wrote:
Quoted 4 lines · Paul Sokolovsky

I'd like to know what's the idea behind overriding DISTRO var from the value being set by user? For example, angstrom.inc does:

DISTRO = "angstrom"

It means that the override in active use becomes "angstrom" and we don't have 1001 different overrides (angstrom2007, angstrom1008 etc.) all over the tree.

That means that we use the same var for 2 different purposes, and that's where problem is.

Quoted 11 lines
Quoted 11 lines

The problem with is that real distro name is lost, as thus cannot be passed to some other tool (e.g., bbimage).

If there're good reasons to do that, and we would be lazy enough to convert to something like: DISTRO_FOO = "${DISTRO}" in bitbake.conf, and let those good reasons apply to DISTRO_FOO, which must replace DISTRO in the appropriate places, then I at least propose to do:

DISTRO_ORIGINAL := "${DISTRO}"

Quoted 8 lines
Quoted 1 line

in bitbake.conf, so we always have real distro config name handy.

What you didn't say is where exactly in bitbake.conf you are going to define that?

You need to put the := directly before the code that changes DISTRO. Yes, you could add this in bitbake.conf after local.conf and before including ${DISTRO}.conf but that seems ugly to me.

Ugly (or better, unclean) is to reuse top-level input parameter from user for different purpose. So, at first, the meaning of DISTRO is "name of the distro config", and then suddenly it changes to "value to use for overrides, etc". The second use should have different name then, as again, DISTRO is user's primary input param for OE. That would be clean solution...

Quoted 3 lines

I'd prefer USERDISTRO = "${DISTRO}" in bitbake.conf and then having angstrom overriding that using := if it really has to...

... But as we don't want to revamp OE up to that level ;-), then we should find good place to work that around. The issue here is that overriding DISTRO is common practice, we even have pe(a)rls like:

DISTRO = "Jornada Linux Mobility Edition"

So, it should be worked around on OE's level (== bitbake.conf), not on distro's level.

Also, what's exactly ugly? ":="? Then we for sure should make exception for bitbake.conf, simply because := is unavoidable for meta-stuff, and bitbake.conf already has bunch of them. IMHO, it's uglier to have something defined as "=" in bitbake.conf, and require distro to override that with ":=".

So the patch I have now below. It assumes that local.conf is what may set DISTRO, so captures it after that.

bitbake.conf d28d0f5816ecef6736cc0b1cd2b48ce41d4a656e renamed from bitbake.conf 5044eed5572b1c9c12c31cf7952ccedc1648524c +2 -0
@@ -529,6 +531,8 @@ include conf/local.conf
 include conf/site.conf
 include conf/auto.conf
 include conf/local.conf
+# DISTRO may be overriden, so preserve real config name
+DISTRO_ORIGINAL := "${DISTRO}"
 include conf/build/${BUILD_SYS}.conf
 include conf/target/${TARGET_SYS}.conf
 include conf/machine/${MACHINE}.conf
image.bbclass dbdb61a027253ac692cf3fb722fd4a3549d31f78 renamed from image.bbclass 4d92381733b09bae07a07da35bd0024744924c3c +1 -0
@@ -90,6 +90,7 @@ fakeroot do_rootfs () {
        ${IMAGE_PREPROCESS_COMMAND}
 
        export TOPDIR=${TOPDIR}
+       export DISTRO=${DISTRO_ORIGINAL}
        export MACHINE=${MACHINE}
 
        for type in ${IMAGE_FSTYPES}; do
Quoted 5 lines

Regards,

Richard

#3 lore raw
Quoted 6 lines · Paul Sokolovsky
Quoted 3 lines · On Mon, 28 Jan 2008 23:22:50 +0000 Richard Purdie <[email protected]> wrote:

You need to put the := directly before the code that changes DISTRO. Yes, you could add this in bitbake.conf after local.conf and before including ${DISTRO}.conf but that seems ugly to me.

Quoted 6 lines

Ugly (or better, unclean) is to reuse top-level input parameter from user for different purpose. So, at first, the meaning of DISTRO is "name of the distro config", and then suddenly it changes to "value to use for overrides, etc". The second use should have different name then, as again, DISTRO is user's primary input param for OE. That would be clean solution...

Distro maintainers have chosen to do this. They could use an ANGSTROM_DISTRO_VERSION variable to do this instead...

Quoted 8 lines
Quoted 2 lines

I'd prefer USERDISTRO = "${DISTRO}" in bitbake.conf and then having angstrom overriding that using := if it really has to...

... But as we don't want to revamp OE up to that level ;-), then we should find good place to work that around. The issue here is that overriding DISTRO is common practice, we even have pe(a)rls like:

DISTRO = "Jornada Linux Mobility Edition"

Whoever merged that should be shot...

Quoted 2 lines

So, it should be worked around on OE's level (== bitbake.conf), not on distro's level.

Distro maintainers dug themselves into this hole...

But yes, I think something at OE level can help. That was my proposal...

Quoted 1 line

Also, what's exactly ugly? ":="?

It breaks the way standard variables work and catches people out. It has a long history of confusing users, developers and even the core devs. I ended up purging hundreds of the things from the metadata a while back since all but about 10 were totally unneeded and just confused and broke things. I have no desire to return to that.

It also stops people from overriding something from their local.conf.

Quoted 3 lines

Then we for sure should make exception
for bitbake.conf, simply because := is unavoidable for meta-stuff, and bitbake.conf already has bunch of them.

Ok, looking through the conf directory, bitbake.conf has exactly 3 of them. DATE and TIME are obvious special cases and CACHE is commented to explain why its special.

Angstrom has one, there are several to trigger fatal errors and the nylon distro is doing something that looks dubious at best.

In classes there are six references, I know three are valid offhand, the others look dubious.

So we only have say 10 cases in the core, not very many at all and they are avoidable.

Quoted 3 lines

IMHO, it's uglier to have
something defined as "=" in bitbake.conf, and require distro to override that with ":=".

The distro is the entity that is overriding DISTRO and making it do two things. Having it jump through an extra hoop because of that isn't a problem.

Cheers,

Richard

#4 lore raw

Hello,

Quoted 14 lines · On Tue, 29 Jan 2008 01:00:52 +0000 Richard Purdie <[email protected]> wrote:
Quoted 6 lines · Paul Sokolovsky
Quoted 3 lines · On Mon, 28 Jan 2008 23:22:50 +0000 Richard Purdie <[email protected]> wrote:

You need to put the := directly before the code that changes DISTRO. Yes, you could add this in bitbake.conf after local.conf and before including ${DISTRO}.conf but that seems ugly to me.

Quoted 6 lines

Ugly (or better, unclean) is to reuse top-level input parameter from user for different purpose. So, at first, the meaning of DISTRO is "name of the distro config", and then suddenly it changes to "value to use for overrides, etc". The second use should have different name then, as again, DISTRO is user's primary input param for OE. That would be clean solution...

Quoted 2 lines

Distro maintainers have chosen to do this. They could use an ANGSTROM_DISTRO_VERSION variable to do this instead...

Well, ok, as only Angstrom does that, it's hard to call for OE to come at save for all future distros and their users.

Quoted 11 lines
Quoted 9 lines
Quoted 3 lines

I'd prefer USERDISTRO = "${DISTRO}" in bitbake.conf and then having angstrom overriding that using := if it really has to...

... But as we don't want to revamp OE up to that level ;-), then we should find good place to work that around. The issue here is that overriding DISTRO is common practice, we even have pe(a)rls like:

DISTRO = "Jornada Linux Mobility Edition"

Whoever merged that should be shot...

Ok, so at least we agree that overriding DISTRO without good reasons is superfluous, if not bad. Please see patch below. This actually leaves only Angstrom as overriding that variable.

Quoted 7 lines
Quoted 2 lines

So, it should be worked around on OE's level (== bitbake.conf), not on distro's level.

Distro maintainers dug themselves into this hole...

But yes, I think something at OE level can help. That was my proposal...

One more question about "USERDISTRO". It breaks that prefix convention, moreover I feel that it's tide against underscores in names. Is that the case? Then I guess we should sit and think that problem is not underscore used in identifiers, but underscore used for override syntax. I have no idea why "_" was chosen for such role and even what influence that could be (except shell??). But replacing it with "." probably should not bring any problems (besides just doing that of course! ;-)) and would improve syntax clarity.

Quoted 10 lines
Quoted 1 line

Also, what's exactly ugly? ":="?

It breaks the way standard variables work and catches people out. It has a long history of confusing users, developers and even the core devs. I ended up purging hundreds of the things from the metadata a while back since all but about 10 were totally unneeded and just confused and broke things. I have no desire to return to that.

It also stops people from overriding something from their local.conf.

Quoted 7 lines
Quoted 3 lines

Then we for sure should make exception
for bitbake.conf, simply because := is unavoidable for meta-stuff, and bitbake.conf already has bunch of them.

Ok, looking through the conf directory, bitbake.conf has exactly 3 of them. DATE and TIME are obvious special cases and CACHE is commented to explain why its special.

DISTRO_ORIGINAL as was proposed by me is of the same class as DATE and TIME - it just captures stuff once, and is "imperative" variable, not supposed to be part of .bb expressions.

[]

Quoted 6 lines

Cheers,

Richard

============================================================
--- conf/distro/amsdelta-oe.conf
2444b09294bbede8664e4a7ed9234c099ea438c8 +++
conf/distro/amsdelta-oe.conf
76da0f1ba0c0bff5d385850eab80adec09746803
@@ -1,4 +1,3 @@ -DISTRO =
"amsdelta-oe" DISTRO_NAME = "AmsDelta Linux"
DISTRO_VERSION = "unstable-${DATE}"

============================================================
--- conf/distro/chinook-compat.conf 71a18c9555e92f4daa94631ec75895dff4657653 +++ conf/distro/chinook-compat.conf b947a8f2568d5737e4ac97e8f352727f74f5e52d
@@ -13,7 +13,6 @@ # of some
packages. If you encounter such a problem please provide a recipe # or file a bug!
-DISTRO = "chinook-compat"
DISTRO_NAME = "Chinook-compat"
DISTRO_VERSION = "test-${DATE}"
DISTRO_TYPE = "debug"
============================================================

distro/foonas.conf 98a2a8a7f1273c47a8f19105d91023e6c24ff330 renamed from distro/foonas.conf 798d1fa5c36020aa53c1313d2a9f58c32108afae +0 -1
@@ -10,7 +10,6 @@ require conf/distro/angstrom-2008.1.conf
 ANGSTROM_MODE = ${FOONAS_MODE}
 require conf/distro/angstrom-2008.1.conf
 
-DISTRO = "foonas"
 DISTRO_NAME = "foonas"
 DISTRO_VERSION = "1.0-dev"
 DISTRO_REVISION = "1"

============================================================
--- conf/distro/jlime-shrek.conf ba46d1959e57011f17da3184fd76bdf9e176677e +++ conf/distro/jlime-shrek.conf 4aa79fa3f008b3d4c92169d9af94ffa1dc1e8491
@@ -1,9 +1,8 @@ #@TYPE: Distribution #@NAME: Jornada Linux Mobility Edition (JLime) <www.jlime.com> #@DESCRIPTION: Distribution file for JLime (Linux for HP jornada 5xx,6xx,7xx,8xx series) #@MAINTAINER:
Kristoffer Ericson <[email protected]>
-DISTRO = "Jornada Linux Mobility Edition"
DISTRO_NAME = "JLime"
DISTRO_VERSION = "Shrek"
DISTRO_TYPE = "release"
============================================================

distro/mamona.conf 5d40e92d458ce0b59a7069cdbdf8eaab449ed77f renamed from distro/mamona.conf 79c71417e4ff26abcb40d138494fa02b837f1e76 +0 -1
@@ -1,9 +1,8 @@
 #@--------------------------------------------------------------------
 #@TYPE: Distribution
 #@NAME: Mamona 
 #@--------------------------------------------------------------------
 
-DISTRO = "mamona"
 DISTRO_NAME = Mamona""
 DISTRO_VERSION = "test-${DATE}"
 DISTRO_TYPE = "debug"

============================================================

distro/mokoslug.conf 65e3a76d9784539c4bfe189e558417b05fffc97a renamed from distro/mokoslug.conf 66f7b238488b8415f9c78e9e344f98a74e83edcf +0 -0
@@ -8,7 +8,6 @@ require conf/distro/angstrom-2008.1.conf
 # MokoSlug is based on Angstrom, and would hopefully just be done by

features one day ... require conf/distro/angstrom-2008.1.conf

-DISTRO = "mokoslug"
DISTRO_NAME = "MokoSlug"
DISTRO_VERSION = "1.0-alpha"
DISTRO_REVISION = "1"
============================================================

distro/openmoko.conf 32e366a34046342c394581a28fe3f1af2a0a1a4c renamed from distro/openmoko.conf 0faa207a22693f2ef2ed13e12ce53f250340b63f +0 -1
@@ -10,7 +10,6 @@ require conf/distro/include/angstrom-200
 #
 # Header
 #
-DISTRO = "openmoko"
 DISTRO_NAME = "OpenMoko"
 DISTRO_VERSION = "P1-Snapshot-${DATE}"
 #DISTRO_TYPE = "release"
Signature · 2 lines
Best regards,
 Paul                          mailto:[email protected]
#5 lore raw

Hello,

On Thu, 31 Jan 2008 14:44:17 +0200
Paul Sokolovsky <[email protected]> wrote:

[]

Quoted 4 lines

Ok, so at least we agree that overriding DISTRO without good reasons is superfluous, if not bad. Please see patch below. This actually leaves only Angstrom as overriding that variable.

Ok, that patch was applied, now one to actually preserve original DISTRO value. Fully made per Richard's suggestions:

============================================================

image.bbclass +1 -0
@@ -90,6 +90,7 @@ fakeroot do_rootfs () {
 	${IMAGE_PREPROCESS_COMMAND}
 		
 	export TOPDIR=${TOPDIR}
+	export DISTRO=${USERDISTRO}
 	export MACHINE=${MACHINE}
 
 	for type in ${IMAGE_FSTYPES}; do

============================================================

bitbake.conf +4 -0
@@ -529,6 +531,10 @@ include conf/local.conf
 include conf/site.conf
 include conf/auto.conf
 include conf/local.conf
+# USERDISTRO should always contain original DISTRO value as set by user
+# If a distro config overrides DISTRO for whatever reason (e.g. to get
+# overrides like it wants), USERDISTRO must be reassigned with := first
+USERDISTRO = "${DISTRO}"
 include conf/build/${BUILD_SYS}.conf
 include conf/target/${TARGET_SYS}.conf
 include conf/machine/${MACHINE}.conf

============================================================

distro/include/angstrom.inc +2 -0
@@ -1,7 +1,9 @@
 #@TYPE: Distribution
 #@NAME: Angstrom 
 #@DESCRIPTION: Release independent distribution configuration for Angstrom
 
+# Preserve original DISTRO value
+USERDISTRO := "${DISTRO}"
 DISTRO = "angstrom"
 DISTRO_NAME = "Angstrom"
 

[]

Signature · 2 lines
Best regards,
 Paul                          mailto:[email protected]
#6 lore raw

Hi,

image.bbclass fakeroot do_rootfs () { · line 94

Quoted 9 lines · Paul Sokolovsky

============================================================

image.bbclass +1 -0
@@ -90,6 +90,7 @@ fakeroot do_rootfs () {
 	${IMAGE_PREPROCESS_COMMAND}
 
 	export TOPDIR=${TOPDIR}
+	export DISTRO=${USERDISTRO}
 	export MACHINE=${MACHINE}

This could be rather confusing, can we not have:

USERDISTRO=${USERDISTRO}

then its obvious which variable we mean?

Otherwise its fine with me.

Cheers,

Richard

#7 lore raw

Hello,

Quoted 15 lines · On Sat, 09 Feb 2008 18:42:49 +0000 Richard Purdie <[email protected]> wrote:

Hi,

image.bbclass fakeroot do_rootfs () { · line 94

Quoted 9 lines · Paul Sokolovsky

============================================================
--- classes/image.bbclass 4d92381733b09bae07a07da35bd0024744924c3c +++ classes/image.bbclass 6eeae6a01c36465bc36cc737d42ea6b8ab09b152 @@ -90,6 +90,7 @@ fakeroot do_rootfs () { ${IMAGE_PREPROCESS_COMMAND}

image.bbclass +1 -0
 	export TOPDIR=${TOPDIR}
+	export DISTRO=${USERDISTRO}
 	export MACHINE=${MACHINE}

This could be rather confusing, can we not have:

Quoted 3 lines

USERDISTRO=${USERDISTRO}

then its obvious which variable we mean?

Not sure I understand. USERDISTRO is the variable which holds *real* DISTRO value, and here, we just use that real value to set a top-level parameter DISTRO for a tool which expects such top-level parameter (bbimage in this case).

Quoted 7 lines

Otherwise its fine with me.

Cheers,

Richard

Signature · 2 lines
Best regards,
 Paul                          mailto:[email protected]
#8 lore raw
Quoted 15 lines · Paul Sokolovsky
Quoted 13 lines · On Sat, 09 Feb 2008 18:42:49 +0000 Richard Purdie <[email protected]> wrote:

image.bbclass fakeroot do_rootfs () { · line 94

Quoted 9 lines · Paul Sokolovsky

============================================================
--- classes/image.bbclass 4d92381733b09bae07a07da35bd0024744924c3c +++ classes/image.bbclass 6eeae6a01c36465bc36cc737d42ea6b8ab09b152 @@ -90,6 +90,7 @@ fakeroot do_rootfs () { ${IMAGE_PREPROCESS_COMMAND}

image.bbclass +1 -0
 	export TOPDIR=${TOPDIR}
+	export DISTRO=${USERDISTRO}
 	export MACHINE=${MACHINE}

This could be rather confusing, can we not have:

Quoted 8 lines
Quoted 3 lines

USERDISTRO=${USERDISTRO}

then its obvious which variable we mean?

Not sure I understand. USERDISTRO is the variable which holds *real* DISTRO value, and here, we just use that real value to set a top-level parameter DISTRO for a tool which expects such top-level parameter (bbimage in this case).

Can it not expect USERDISTRO though? Where exactly is this being used?

I just worry that people are going to get confused if we call this DISTRO since its not the value in the "DISTRO" variable...

Cheers,

Richard

#9 lore raw

Hello,

Quoted 26 lines · On Sat, 09 Feb 2008 19:04:33 +0000 Richard Purdie <[email protected]> wrote:
Quoted 15 lines · Paul Sokolovsky
Quoted 13 lines · On Sat, 09 Feb 2008 18:42:49 +0000 Richard Purdie <[email protected]> wrote:

image.bbclass fakeroot do_rootfs () { · line 94

Quoted 9 lines · Paul Sokolovsky

============================================================
--- classes/image.bbclass 4d92381733b09bae07a07da35bd0024744924c3c +++ classes/image.bbclass 6eeae6a01c36465bc36cc737d42ea6b8ab09b152 @@ -90,6 +90,7 @@ fakeroot do_rootfs () { ${IMAGE_PREPROCESS_COMMAND}

image.bbclass +1 -0
 	export TOPDIR=${TOPDIR}
+	export DISTRO=${USERDISTRO}
 	export MACHINE=${MACHINE}

This could be rather confusing, can we not have:

Quoted 8 lines
Quoted 3 lines

USERDISTRO=${USERDISTRO}

then its obvious which variable we mean?

Not sure I understand. USERDISTRO is the variable which holds *real* DISTRO value, and here, we just use that real value to set a top-level parameter DISTRO for a tool which expects such top-level parameter (bbimage in this case).

Quoted 4 lines

Can it not expect USERDISTRO though? Where exactly is this being used?

I just worry that people are going to get confused if we call this DISTRO since its not the value in the "DISTRO" variable...

Well, it *is* value of DISTRO variable. Secondly, how you imagine that
- bitbake accepts some notion as DISTRO variable, yet bbimage as USERDISTRO variable? And people should not be confused or even concerned with all this stuff - it's just internal OE workings made to make external whitebox interface (DISTRO being a part of it) work as it should.

Well, after all, bitbake is your area. Pragmatically, I of course would prefer to avoid waiting for next bitbake release to get this right though. Ah, and why bbimage needs DISTRO set properly? It just loads bitbake.conf and that references ${DISTRO}.conf.

Quoted 7 lines

Cheers,

Richard

Signature · 2 lines
Best regards,
 Paul                          mailto:[email protected]