[oe] [PATCH] bitbake.conf, freeze.inc: Add version lockdown implementation and use it by default.

Denys Dmytriyenko denis at denix.org
Wed May 13 21:25:46 UTC 2009


On Wed, May 13, 2009 at 01:53:18PM -0700, Chris Larson wrote:
> For each recipe which completes a task successfully, this emits the current
> version into ${TMPDIR}/versions.conf as a PREFERRED_VERSION line.
> ${TMPDIR}/versions.conf and conf/versions.conf are automatically included,
> in that order, in subsequent builds, to provide more deterinistic builds by
> default, and to let the user make the lockdown persist via a simple cp
> command.
> 
> Assuming that the latest ncurses in the recipes is 5.7, and that 5.7 is
> preferred over 5.3 by default given any distro version preferences, if they
> exist, the following are examples of its behavior:
> 
> $ rm -rf tmp
> $ bitbake ncurses-5.3
> $ bitbake -c clean ncurses
> $ bitbake ncurses # builds ncurses 5.3
> 
> $ cp tmp/versions.conf conf/
> $ rm -rf tmp
> $ bitbake ncurses # builds ncurses 5.3

Very nice! Let me try it here...

> Signed-off-by: Chris Larson <clarson at mvista.com>
> ---
>  conf/bitbake.conf |    1 +
>  conf/freeze.inc   |   71 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 72 insertions(+), 0 deletions(-)
>  create mode 100644 conf/freeze.inc
> 
> diff --git a/conf/bitbake.conf b/conf/bitbake.conf
> index f7df60c..9b6ffcc 100644
> --- a/conf/bitbake.conf
> +++ b/conf/bitbake.conf
> @@ -618,6 +618,7 @@ OVERRIDES = "local:${MACHINE}:${DISTRO}:${TARGET_OS}:${TARGET_ARCH}:build-${BUIL
>  ##################################################################
>  
>  require conf/collections.inc
> +require conf/freeze.inc
>  include conf/site.conf
>  include conf/auto.conf
>  include conf/local.conf
> diff --git a/conf/freeze.inc b/conf/freeze.inc
> new file mode 100644
> index 0000000..82acebf
> --- /dev/null
> +++ b/conf/freeze.inc
> @@ -0,0 +1,71 @@
> +# Recipe version "freeze" aka lockdown implementation.
> +#
> +# For each recipe which completes a task successfully, this emits the current
> +# version into ${TMPDIR}/versions.conf as a PREFERRED_VERSION line.
> +# ${TMPDIR}/versions.conf and conf/versions.conf are automatically included,
> +# in that order, in subsequent builds, to provide more deterinistic builds by
> +# default, and to let the user make the lockdown persist via a simple cp
> +# command.
> +#
> +# Assuming that the latest ncurses in the recipes is 5.7, and that 5.7 is
> +# preferred over 5.3 by default given any distro version preferences, if they
> +# exist, the following are examples of its behavior:
> +#
> +# $ rm -rf tmp
> +# $ bitbake ncurses-5.3
> +# $ bitbake -c clean ncurses
> +# $ bitbake ncurses # builds ncurses 5.3
> +#
> +# $ cp tmp/versions.conf conf/
> +# $ rm -rf tmp
> +# $ bitbake ncurses # builds ncurses 5.3
> +
> +__FREEZEFN ?= "versions.conf"
> +__FREEZEFILE = "${TMPDIR}/${__FREEZEFN}"
> +__FREEZELINE = 'PREFERRED_VERSION_%s = "%s"'
> +__FREEZELINERE = '^PREFERRED_VERSION_(.*) = "(.*)"$'
> +
> +include ${__FREEZEFILE}
> +include conf/${__FREEZEFN}
> +
> +def freeze_add(d):
> +    fn = d.getVar("__FREEZEFILE", 1)
> +    f = open(fn, "a")
> +    f.write("%s\n" % (d.getVar("__FREEZELINE", 1) % (d.getVar("PN", 1), d.getVar("PV", 1))))
> +    f.close()
> +
> +def freeze_finish(d):
> +    import re
> +
> +    # Cleaning up the freezefile
> +    freezefile = d.getVar("__FREEZEFILE", 1)
> +    verdata = {}
> +
> +    try:
> +        f = open(freezefile, "r")
> +    except (OSError, IOError):
> +        pass
> +
> +    regexp = re.compile(d.getVar("__FREEZELINERE", 1))
> +    for line in f:
> +        m = regexp.match(line)
> +        verdata[m.group(1)] = m.group(2)
> +    f.close()
> +
> +    fl = d.getVar("__FREEZELINE", 1)
> +    f = open(freezefile, "w")
> +    f.writelines([("%s\n" % (fl % (pn, pv))) for (pn, pv) in verdata.items()])
> +    f.close()
> +
> +addhandler freeze_eventhandler
> +python freeze_eventhandler () {
> +    from bb.event import BuildCompleted
> +    from bb.build import TaskSucceeded
> +
> +    if isinstance(e, TaskSucceeded):
> +        freeze_add(e.data)
> +    elif isinstance(e, BuildCompleted):
> +        freeze_finish(e.data)
> +}
> +
> +# vim: set ft=bitbake fenc=utf-8 sts=4 sw=4 et :
> -- 
> 1.6.2
> 
> 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel at lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel




More information about the Openembedded-devel mailing list