All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bitbake.conf, freeze.inc: Add version lockdown implementation and use it by default.
@ 2009-05-13 20:53 Chris Larson
  2009-05-13 21:25 ` Denys Dmytriyenko
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Chris Larson @ 2009-05-13 20:53 UTC (permalink / raw)
  To: openembedded-devel

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

Signed-off-by: Chris Larson <clarson@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




^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2009-05-18 19:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-13 20:53 [PATCH] bitbake.conf, freeze.inc: Add version lockdown implementation and use it by default Chris Larson
2009-05-13 21:25 ` Denys Dmytriyenko
2009-05-18 15:48   ` Denys Dmytriyenko
2009-05-18 18:00     ` Christopher Larson
2009-05-18 18:58       ` Denys Dmytriyenko
2009-05-15  3:56 ` Mike Westerhof (mwester)
2009-05-15  7:33   ` Andrea Adami
2009-05-15 15:09     ` Chris Larson
2009-05-15 21:07       ` Andrea Adami
2009-05-18 15:44         ` Denys Dmytriyenko
2009-05-15  8:24   ` Graeme Gregory
2009-05-15 15:08   ` Chris Larson
2009-05-15 16:02     ` Tom Rini
2009-05-15 15:55 ` Michael Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.