Skip to contentSkip to conversation

Staging - time to end the current mess?

DISCUSSION Richard Purdie 7 participants 13 messages Nov 2, 2009 – Nov 4, 2009

lore
Share & tools
lore
#0 lore raw

At OEDEM two years ago I proposed radically altering the way staging worked. For those that don't remember the bad old days, the staging directory layout didn't match that of the target file system meaning every recipe needed a custom do_stage and things were a mess.

We changed the layout allowing the use of the gcc/binutils sysroot options and also started widespread use of autotools_stage_all and I'd say things look much improved compared to how they were.

Anyone who has looked at the packaged-staging code will probably agree there is still a way to go though - its horrendously complicated. We also do a lot of duplication. I'd like to propose a new simple way of doing things. We'd have the following work flow:

[...]
do_compile - up to here all as usual
do_install - Everything installs into a DESTDIR (including -native) do_package - Takes a copy of the DESTDIR, applies any .la/.pc mangling
then splits into packages as usual
do_populate_staging - Takes a copy of the DESTDIR, mangles, installs
into staging and creates staging packages from this

Firstly, does any disagree with this approach or can we all agree its a nice objective?

Pros:

* Only one "make install"
* We can start to work out the differences between do_install and do_stage and minimise them (there should be none bar .la mangling)
* Cleaner and simpler do_stage step
* Packaged-Staging becomes much simpler
* Builds should be faster as staging timestamp snapshots are not required and staging lock taking should be minimal.

Cons:

* Very different to what we have now - how to get there?
* Likely to be some breakage in any transition

I really like the idea in principle, in practise its hard to get there incrementally without breaking things. I'm trying to come up with some code which does that and I'm hoping to have something for OEDEM.

For now I'd like to ask if there is agreement we need to do this and support to make this happen?

Cheers,

Richard

#1 lore raw
Quoted 23 lines · Richard Purdie

At OEDEM two years ago I proposed radically altering the way staging worked. For those that don't remember the bad old days, the staging directory layout didn't match that of the target file system meaning every recipe needed a custom do_stage and things were a mess.

We changed the layout allowing the use of the gcc/binutils sysroot options and also started widespread use of autotools_stage_all and I'd say things look much improved compared to how they were.

Anyone who has looked at the packaged-staging code will probably agree there is still a way to go though - its horrendously complicated. We also do a lot of duplication. I'd like to propose a new simple way of doing things. We'd have the following work flow:

[...]
do_compile - up to here all as usual
do_install - Everything installs into a DESTDIR (including -native) do_package - Takes a copy of the DESTDIR, applies any .la/.pc mangling
then splits into packages as usual
do_populate_staging - Takes a copy of the DESTDIR, mangles, installs
into staging and creates staging packages from this

Quoted 2 lines

Firstly, does any disagree with this approach or can we all agree its a nice objective?

Can we make the mangling a seperate tasks? I tend to do the mangling in do_compile_append to be able to do builds *on* the target as well.

Quoted 10 lines

Pros:

* Only one "make install"
* We can start to work out the differences between do_install and do_stage and minimise them (there should be none bar .la mangling)
* Cleaner and simpler do_stage step
* Packaged-Staging becomes much simpler
* Builds should be faster as staging timestamp snapshots are not required and staging lock taking should be minimal.

Quoted 4 lines

Cons:

* Very different to what we have now - how to get there?
* Likely to be some breakage in any transition

And

* 'make install' doesn't actually work properly for lots of packages (you know, the ones with handcrafted makefiles)

But we can solve that by putting the custom do_stage() methods for those in do_install(), right?

Quoted 6 lines

I really like the idea in principle, in practise its hard to get there incrementally without breaking things. I'm trying to come up with some code which does that and I'm hoping to have something for OEDEM.

For now I'd like to ask if there is agreement we need to do this and support to make this happen?

You have my agreement.

regards,

Koen

#2 lore raw
Quoted 24 lines · Koen Kooi
Quoted 23 lines · Richard Purdie

At OEDEM two years ago I proposed radically altering the way staging worked. For those that don't remember the bad old days, the staging directory layout didn't match that of the target file system meaning every recipe needed a custom do_stage and things were a mess.

We changed the layout allowing the use of the gcc/binutils sysroot options and also started widespread use of autotools_stage_all and I'd say things look much improved compared to how they were.

Anyone who has looked at the packaged-staging code will probably agree there is still a way to go though - its horrendously complicated. We also do a lot of duplication. I'd like to propose a new simple way of doing things. We'd have the following work flow:

[...]
do_compile - up to here all as usual
do_install - Everything installs into a DESTDIR (including -native) do_package - Takes a copy of the DESTDIR, applies any .la/.pc mangling
then splits into packages as usual
do_populate_staging - Takes a copy of the DESTDIR, mangles, installs
into staging and creates staging packages from this

Quoted 5 lines
Quoted 2 lines

Firstly, does any disagree with this approach or can we all agree its a nice objective?

Can we make the mangling a seperate tasks? I tend to do the mangling in do_compile_append to be able to do builds *on* the target as well.

I just published my WIP tree:

http://cgit.openembedded.net/cgit.cgi/openembedded/log/?h=rpurdie/work-in-progress

and specifically:

http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?h=rpurdie/work-in-progress&id=1d69a38be629a70faf65dd9f2e9db12164071bfd

which means we'd start declaring "mangling" functions in their own right. Does that work for you?

Where we run these is then up to the core metadata so we can attach them to stage/install/compile as makes sense. I want to declare some conventions of the directories these operate on so we can make the functions "relocatable" by changing the input variables.

Quoted 7 lines

And

* 'make install' doesn't actually work properly for lots of packages (you know, the ones with handcrafted makefiles)

But we can solve that by putting the custom do_stage() methods for those in do_install(), right?

Those packages will already have a custom do_install in some directory so we can just use them as is.

Cheers,

Richard

#3 lore raw
Quoted 33 lines · Richard Purdie
Quoted 24 lines · Koen Kooi
Quoted 23 lines · Richard Purdie

At OEDEM two years ago I proposed radically altering the way staging worked. For those that don't remember the bad old days, the staging directory layout didn't match that of the target file system meaning every recipe needed a custom do_stage and things were a mess.

We changed the layout allowing the use of the gcc/binutils sysroot options and also started widespread use of autotools_stage_all and I'd say things look much improved compared to how they were.

Anyone who has looked at the packaged-staging code will probably agree there is still a way to go though - its horrendously complicated. We also do a lot of duplication. I'd like to propose a new simple way of doing things. We'd have the following work flow:

[...]
do_compile - up to here all as usual
do_install - Everything installs into a DESTDIR (including -native) do_package - Takes a copy of the DESTDIR, applies any .la/.pc mangling
then splits into packages as usual
do_populate_staging - Takes a copy of the DESTDIR, mangles, installs
into staging and creates staging packages from this

Quoted 5 lines
Quoted 2 lines

Firstly, does any disagree with this approach or can we all agree its a nice objective?

Can we make the mangling a seperate tasks? I tend to do the mangling in do_compile_append to be able to do builds *on* the target as well.

I just published my WIP tree:

Quoted 8 lines

http://cgit.openembedded.net/cgit.cgi/openembedded/log/?h=rpurdie/work-in-progress

and specifically:

http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?h=rpurdie/work-in-progress&id=1d69a38be629a70faf65dd9f2e9db12164071bfd

which means we'd start declaring "mangling" functions in their own right. Does that work for you?

That was exactly what I was thinking about :)

Quoted 7 lines

Where we run these is then up to the core metadata so we can attach them to stage/install/compile as makes sense. I want to declare some conventions of the directories these operate on so we can make the functions "relocatable" by changing the input variables.

Quoted 2 lines

And

Quoted 8 lines
Quoted 5 lines

* 'make install' doesn't actually work properly for lots of packages (you know, the ones with handcrafted makefiles)

But we can solve that by putting the custom do_stage() methods for those in do_install(), right?

Those packages will already have a custom do_install in some directory so we can just use them as is.

My biggest fear is these kind of recipes:

do_install() {
	oe_libinstall foo ${D}
}

do_stage() }

	oe_libinstall foo ${D}
	cp foo.h ${STAGING_INC_DIR}
}

I guess we could grep for do_stage_{ap,pre}pend to find the worst offenders and gradually fix up remaining offenders.

regards,

Koen

#4 lore raw
Quoted 6 lines · Koen Kooi

My biggest fear is these kind of recipes:

do_install() {
	oe_libinstall foo ${D}
}
Quoted 7 lines

do_stage() }

	oe_libinstall foo ${D}
	cp foo.h ${STAGING_INC_DIR}
}

I guess we could grep for do_stage_{ap,pre}pend to find the worst offenders and gradually fix up remaining offenders.

I'm hoping that with some clever magic, what I create will continue to use these "legacy" staging functions when they're defined giving us a transition path. As we go through the recipes fixing them up to use the fastpath, we'll just have to catch those things. They are by definition broken anyway so this is a good thing to do.

Cheers,

Richard

#5 lore raw
In reply to Koen Kooi

2009/11/2 Koen Kooi <[email protected]>:

Quoted 46 lines · Richard Purdie
Quoted 24 lines

At OEDEM two years ago I proposed radically altering the way staging worked. For those that don't remember the bad old days, the staging directory layout didn't match that of the target file system meaning every recipe needed a custom do_stage and things were a mess.

We changed the layout allowing the use of the gcc/binutils sysroot options and also started widespread use of autotools_stage_all and I'd say things look much improved compared to how they were.

Anyone who has looked at the packaged-staging code will probably agree there is still a way to go though - its horrendously complicated. We also do a lot of duplication. I'd like to propose a new simple way of doing things. We'd have the following work flow:

[...]
do_compile - up to here all as usual
do_install - Everything installs into a DESTDIR (including -native) do_package - Takes a copy of the DESTDIR, applies any .la/.pc mangling then splits into packages as usual do_populate_staging - Takes a copy of the DESTDIR, mangles, installs into staging and creates staging packages from this

Quoted 2 lines

Firstly, does any disagree with this approach or can we all agree its a nice objective?

Can we make the mangling a seperate tasks? I tend to do the mangling in do_compile_append to be able to do builds *on* the target as well.

Quoted 10 lines

Pros:

* Only one "make install"
* We can start to work out the differences between do_install and do_stage and minimise them (there should be none bar .la mangling)
* Cleaner and simpler do_stage step
* Packaged-Staging becomes much simpler
* Builds should be faster as staging timestamp snapshots are not required and staging lock taking should be minimal.

Quoted 4 lines

Cons:

* Very different to what we have now - how to get there?
* Likely to be some breakage in any transition

Quoted 7 lines

And

* 'make install' doesn't actually work properly for lots of packages (you know, the ones with handcrafted makefiles)

But we can solve that by putting the custom do_stage() methods for those in do_install(), right?

I'm in favour of the proposal.
If not breaking things is important maybe we can call the stage differently and transfer packages from the old to the new. Perhaps not too desirable as this gives a transition period that probably never ends.

Wrt the packages were make install does not properly work:
I would expect for packages where it mostly matters (libs etc) the install to be proper.

And if make install does not work properly the desired solution is (imho) not to repair it in do_stage or do_install, but instead come up with a patch for the Makefile (and preferably submit it to the package to get it repaired more permanently.

Frans.

Quoted 21 lines
Quoted 8 lines

I really like the idea in principle, in practise its hard to get there incrementally without breaking things. I'm trying to come up with some code which does that and I'm hoping to have something for OEDEM.

For now I'd like to ask if there is agreement we need to do this and support to make this happen?

You have my agreement.

regards,

Koen

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

#6 lore raw
In reply to Richard Purdie

Dnia poniedziałek, 2 listopada 2009 o 14:43:27 Richard Purdie napisał(a):

Quoted 2 lines

For now I'd like to ask if there is agreement we need to do this and support to make this happen?

+1 from me

Regards,

Signature · 3 lines
JID:      [email protected]
Website:  http://marcin.juszkiewicz.com.pl/
LinkedIn: http://www.linkedin.com/in/marcinjuszkiewicz
#7 lore raw
In reply to Richard Purdie
Quoted 10 lines · Richard Purdie

[...]
do_compile - up to here all as usual
do_install - Everything installs into a DESTDIR (including -native) do_package - Takes a copy of the DESTDIR, applies any .la/.pc mangling
then splits into packages as usual
do_populate_staging - Takes a copy of the DESTDIR, mangles, installs
into staging and creates staging packages from this

Firstly, does any disagree with this approach or can we all agree its a nice objective?

Yeah thats nice. I will help for instance with pkgconfig-class which now "sed's" the .pc files in builddir before installing it.

Bye Henning

#8 lore raw

Staging - time to end the current mess - now with patches

In reply to Richard Purdie

This is much more interesting with patches so we now have:

http://cgit.openembedded.net/cgit.cgi/openembedded/log/?h=rpurdie/work-in-progress

I ended up cleaning a lot of stuff up as I went but the two really interesting things this branch contains are:

a) Removal of the layout_* variables. This allows Poky's cross canadian SDK functionality to be merged. It also cleans up things quite a bit, I've not tested how the other canadian implementation fairs with this but the intent is to replace that with the Poky implementation which is much cleaner (no boatloads of duplicated variables and uses BBCLASSEXTEND).

b) Change the way do_stage operates.

The intent is that do_install installs to ${D}. Nothing should operate directly on ${D} other than the install.

do_package takes a copy of ${D} into ${PKGD} and then runs the functions in PACKAGE_PREPROCESS_FUNCS which can alter this directory. The result is then packaged.

do_stage detects if the do_stage function is defined. The default is there is no definition anymore. If it is defined we go into legacy mode which works like current staging, we take a lock, take a snapshot of staging, run do_stage, run any SYSROOT_PREPROCESS_FUNCS which operate against SYSROOT_DESTDIR="", see what changed, take a copy of the changes and release the lock.

If we're not legacy, SYSROOT_DESTDIR=${WORKDIR}/sysroot-destdir, we copy ${D} into ${SYSROOT_DESTDIR}/${STAGING_DIR_TARGET}, we any SYSROOT_PREPROCESS_FUNCS against SYSROOT_DESTDIR, save the result for creating the staging package, take the staging lock and copy into staging ("install the package"), release the lock.

For fun, we also detect two special cases - where autotools_stage_all is used by itself and where native.bbclass is used with an autotooled recipe with no do_stage changes. In those two cases we don't need to use legacy mode.

Porting Guide
=============

There is a bb.debug in base.bbclass which tells us which functions are using legacy staging functions. We can raise the profile of this message as we work through the recipes dealing with the staging functions.

As a guide:

* Any do_stage where we do an autotools_stage_all can just be deleted.

* Any do_stage which matches the do_install can just be removed.

* Native packages with delete do_install should not anymore.

* Any do_stage function which installs extra things compared to do_install is very suspect and needs an explanation of why. Most likely do_install should be fixed and do_stage then deleted.

* If do_stage really needs to do something other than what is in do_install a function should be written to operate on SYSROOT_DESTDIR and that function should be appended to SYSROOT_PREPROCESS_FUNCS. There are some -native binary special cases which will need this but almost everything should *not* need this.

* Any other cases, post to the list and we'll work something out

Comments and experiments with the branch welcome. If I get some time I'll try and start adding a few conversions to the branch.

FWIW in Poky I have about 25% legacy staging and 75% using the new functions since I've been pushing autotools_stage there heavily the past few months.

Cheers,

Richard

Acked-by
#9 lore raw

Re: Staging - time to end the current mess - now with patches

On commits 4adf2f2 through 54d5f30:

Quoted 88 lines · Richard Purdie

This is much more interesting with patches so we now have:

http://cgit.openembedded.net/cgit.cgi/openembedded/log/?h=rpurdie/work-in-progress

I ended up cleaning a lot of stuff up as I went but the two really interesting things this branch contains are:

a) Removal of the layout_* variables. This allows Poky's cross canadian SDK functionality to be merged. It also cleans up things quite a bit, I've not tested how the other canadian implementation fairs with this but the intent is to replace that with the Poky implementation which is much cleaner (no boatloads of duplicated variables and uses BBCLASSEXTEND).

b) Change the way do_stage operates.

The intent is that do_install installs to ${D}. Nothing should operate directly on ${D} other than the install.

do_package takes a copy of ${D} into ${PKGD} and then runs the functions in PACKAGE_PREPROCESS_FUNCS which can alter this directory. The result is then packaged.

do_stage detects if the do_stage function is defined. The default is there is no definition anymore. If it is defined we go into legacy mode which works like current staging, we take a lock, take a snapshot of staging, run do_stage, run any SYSROOT_PREPROCESS_FUNCS which operate against SYSROOT_DESTDIR="", see what changed, take a copy of the changes and release the lock.

If we're not legacy, SYSROOT_DESTDIR=${WORKDIR}/sysroot-destdir, we copy ${D} into ${SYSROOT_DESTDIR}/${STAGING_DIR_TARGET}, we any SYSROOT_PREPROCESS_FUNCS against SYSROOT_DESTDIR, save the result for creating the staging package, take the staging lock and copy into staging ("install the package"), release the lock.

For fun, we also detect two special cases - where autotools_stage_all is used by itself and where native.bbclass is used with an autotooled recipe with no do_stage changes. In those two cases we don't need to use legacy mode.

Porting Guide
=============

There is a bb.debug in base.bbclass which tells us which functions are using legacy staging functions. We can raise the profile of this message as we work through the recipes dealing with the staging functions.

As a guide:

* Any do_stage where we do an autotools_stage_all can just be deleted.

* Any do_stage which matches the do_install can just be removed.

* Native packages with delete do_install should not anymore.

* Any do_stage function which installs extra things compared to do_install is very suspect and needs an explanation of why. Most likely do_install should be fixed and do_stage then deleted.

* If do_stage really needs to do something other than what is in do_install a function should be written to operate on SYSROOT_DESTDIR and that function should be appended to SYSROOT_PREPROCESS_FUNCS. There are some -native binary special cases which will need this but almost everything should *not* need this.

* Any other cases, post to the list and we'll work something out

Comments and experiments with the branch welcome. If I get some time I'll try and start adding a few conversions to the branch.

FWIW in Poky I have about 25% legacy staging and 75% using the new functions since I've been pushing autotools_stage there heavily the past few months.

Cheers,

Richard

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

Signature · 7 lines
Chris Larson
clarson at kergoth dot com
clarson at mvista dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Software Engineer
MontaVista Software, Inc.
#10 lore raw

Re: Staging - time to end the current mess - now with patches

In reply to Richard Purdie

Richard Purdie wrote:

I agree with the new concept. I did not understand, why we need do_stage, if we can mangle and stage DESTDIR directly.

Quoted 3 lines

do_package takes a copy of ${D} into ${PKGD} and then runs the functions in PACKAGE_PREPROCESS_FUNCS which can alter this directory. The result is then packaged.

Maybe do_mangle and do_mangle_append or so may look better from an user aspect and easier to port (just move extra commands from do_stage to do_mangle_append). But PACKAGE_PREPROCESS_FUNCS should be OK as well.

Quoted 1 line

* Any do_stage where we do an autotools_stage_all can just be deleted.

And autotools_stage class will become just autotools.

Quoted 1 line

* Native packages with delete do_install should not anymore.

Thinking about it, do still make separate native recipes sense after this change? Most of them could recycle nearly the same recipe then. (Specially patched utilities would be an exception.)

I can imagine, that native build will be built from the host recipe, just with a different setup.

Quoted 3 lines

* Any do_stage function which installs extra things compared to do_install is very suspect and needs an explanation of why. Most likely do_install should be fixed and do_stage then deleted.

I agree. Shorter file list in do_stage might have had some sense to save few megabytes of unused stuff in staging dir, but it is a small profit from the double work.

Quoted 5 lines

* If do_stage really needs to do something other than what is in do_install a function should be written to operate on SYSROOT_DESTDIR and that function should be appended to SYSROOT_PREPROCESS_FUNCS. There are some -native binary special cases which will need this but almost everything should *not* need this.

Example of special case may be guile. Mangling of guile-config must be done in a special way (guile-config is a guile script, not shell script). I cannot remember any other recipe, that needs it.

Quoted 2 lines

Comments and experiments with the branch welcome. If I get some time I'll try and start adding a few conversions to the branch.

It's a bit unrelated, but I would like to see temp/run.do_... script for splitting install dir to sub-package dirs and packages and temp/log.do_... with QA output that warns about unpackaged files.

Signature · 2 lines
Stanislav Brabec
http://www.penguin.cz/~utx/zaurus
#11 lore raw

Re: Staging - time to end the current mess - now with patches

Quoted 8 lines · Stanislav Brabec
Quoted 3 lines · Richard Purdie

do_package takes a copy of ${D} into ${PKGD} and then runs the functions in PACKAGE_PREPROCESS_FUNCS which can alter this directory. The result is then packaged.

Maybe do_mangle and do_mangle_append or so may look better from an user aspect and easier to port (just move extra commands from do_stage to do_mangle_append). But PACKAGE_PREPROCESS_FUNCS should be OK as well.

I have a slight preference for having specific defined functions rather than concatenation of a load of different things.

I'm toying with the idea of renaming the whole idea of "stage" to sysroot so we could have do_sysroot_package, do_sysroot_install and do_sysroot_mangle. That could be a lot clearer for the user?

Quoted 3 lines
Quoted 1 line

* Any do_stage where we do an autotools_stage_all can just be deleted.

And autotools_stage class will become just autotools.

Yes, it was always intended as a transition step and this would remove the need for it.

Quoted 8 lines
Quoted 1 line

* Native packages with delete do_install should not anymore.

Thinking about it, do still make separate native recipes sense after this change? Most of them could recycle nearly the same recipe then. (Specially patched utilities would be an exception.)

I can imagine, that native build will be built from the host recipe, just with a different setup.

I'm a step ahead here with BBCLASSEXTEND :). Since we have a new bitbake release we can now bump the bitbake version dependency and start using this.

An example of its use:

http://git.pokylinux.org/cgit.cgi/poky/tree/meta/packages/mpfr/mpfr_2.3.1.bb

Quoted 7 lines
Quoted 3 lines

* Any do_stage function which installs extra things compared to do_install is very suspect and needs an explanation of why. Most likely do_install should be fixed and do_stage then deleted.

I agree. Shorter file list in do_stage might have had some sense to save few megabytes of unused stuff in staging dir, but it is a small profit from the double work.

We can always remove things from staging we know to be useless like docs in a global/central function. Disk space is not a top consideration though.

Quoted 9 lines
Quoted 5 lines

* If do_stage really needs to do something other than what is in do_install a function should be written to operate on SYSROOT_DESTDIR and that function should be appended to SYSROOT_PREPROCESS_FUNCS. There are some -native binary special cases which will need this but almost everything should *not* need this.

Example of special case may be guile. Mangling of guile-config must be done in a special way (guile-config is a guile script, not shell script). I cannot remember any other recipe, that needs it.

Ok, the framework shout fit that.

Quoted 6 lines
Quoted 2 lines

Comments and experiments with the branch welcome. If I get some time I'll try and start adding a few conversions to the branch.

It's a bit unrelated, but I would like to see temp/run.do_... script for splitting install dir to sub-package dirs and packages and temp/log.do_... with QA output that warns about unpackaged files.

bitbake master does this already :)

Cheers,

Richard

#12 lore raw

Re: Staging - time to end the current mess - now with patches

Quoted 3 lines · Richard Purdie

I'm toying with the idea of renaming the whole idea of "stage" to sysroot so we could have do_sysroot_package, do_sysroot_install and do_sysroot_mangle. That could be a lot clearer for the user?

It makes sense. But the sysroot directory itself has name "staging". It would be nice to have consistent names.

Quoted 5 lines
Quoted 3 lines

It's a bit unrelated, but I would like to see temp/run.do_... script for splitting install dir to sub-package dirs and packages and temp/log.do_... with QA output that warns about unpackaged files.

bitbake master does this already :)

Nice.

Well, just another trivial idea that can simplify life:

- files in temp/ and stamps/ can have number somewhere in its name - if they will be sorted by name, then they will have its natural order.

Signature · 2 lines
Stanislav Brabec
http://www.penguin.cz/~utx/zaurus