[Exherbo-dev] Multiple calls to default

Elias Pipping pipping at lavabit.com
Fri Sep 30 21:27:57 BST 2011


Hi,

I'd like to point out a problem with default().

Exlibs tend to define phases that they export, e.g. src_prepare, in the following way:

  # foo.exlib

  export_exlib_phases src_prepare

  foo_src_prepare() {
    do_stuff1
    do_stuff2
    # etc.

    default
  }

The effect is that an exheres, e.g. foo-1.exheres-0 can do the following:

  # Example 1

  require foo

to have do_stuff* run. default will just be a no-op. Or if it
e.g. wants to apply patches on top of that, it can use

  # Example 2

  require foo

  DEFAULT_SRC_PREPARE_PATCHES=( ... )

This works because default() is called at the end of
foo_src_prepare. If it wasn't, example 2 would look like this:

  # Example 2 the ugly way

  require foo

  DEFAULT_SRC_PREPARE_PATCHES=( ... )

  src_prepare() {
    foo_src_prepare
    default
  }

Example 1 would stay unchanged.

This makes clear why a lot of exlibs define phases like src_prepare
such that default() is called at some point.

What if we require two such exlibs? Then we end up calling default
twice. That's in general not desirable: In the case of src_prepare
e.g., if DEFAULT_SRC_PREPARE_PATCHES is non-empty, those patches will
be applied twice!

What should we do about this?


Regards,

Elias Pipping




More information about the Exherbo-dev mailing list