diff options
author | Leon Woestenberg <leon.woestenberg@gmail.com> | 2008-05-20 20:23:12 +0000 |
---|---|---|
committer | Leon Woestenberg <leon.woestenberg@gmail.com> | 2008-05-20 20:23:12 +0000 |
commit | d8e3cbb7e1ae86507b7cfd8142be8a1e7323270f (patch) | |
tree | 604773c65fdddff8365cc45027defcf9a4b21cca /classes | |
parent | e93dabbb3ecc45cfd55f5ef103479e2b3d4ccd1e (diff) | |
parent | 1bfb615d5157cf619a9d40189ed992f8958ce4c6 (diff) |
merge of '635b19191517f99ee151ae6157a22f5d56406238'
and 'c179e5e451e08eb1f3266b4da027de66abad7a9b'
Diffstat (limited to 'classes')
-rw-r--r-- | classes/gtk-icon-cache.bbclass | 12 | ||||
-rw-r--r-- | classes/image.bbclass | 3 | ||||
-rw-r--r-- | classes/oestats-client.bbclass | 128 |
3 files changed, 108 insertions, 35 deletions
diff --git a/classes/gtk-icon-cache.bbclass b/classes/gtk-icon-cache.bbclass index b86562890a..b256365175 100644 --- a/classes/gtk-icon-cache.bbclass +++ b/classes/gtk-icon-cache.bbclass @@ -3,14 +3,18 @@ RDEPENDS += "hicolor-icon-theme" # This could run on the host as icon cache files are architecture independent, # but there is no gtk-update-icon-cache built natively. -gtk-icon-cache_postinst() { +gtk_icon_cache_postinst() { if [ "x$D" != "x" ]; then exit 1 fi + +# Update the pixbuf loaders in case they haven't been registered yet +gdk-pixbuf-query-loaders > /etc/gtk-2.0/gdk-pixbuf.loaders + gtk-update-icon-cache -q /usr/share/icons/hicolor } -gtk-icon-cache_postrm() { +gtk_icon_cache_postrm() { gtk-update-icon-cache -q /usr/share/icons/hicolor } @@ -29,13 +33,13 @@ python populate_packages_append () { postinst = bb.data.getVar('pkg_postinst_%s' % pkg, d, 1) or bb.data.getVar('pkg_postinst', d, 1) if not postinst: postinst = '#!/bin/sh\n' - postinst += bb.data.getVar('gtk-icon-cache_postinst', d, 1) + postinst += bb.data.getVar('gtk_icon_cache_postinst', d, 1) bb.data.setVar('pkg_postinst_%s' % pkg, postinst, d) postrm = bb.data.getVar('pkg_postrm_%s' % pkg, d, 1) or bb.data.getVar('pkg_postrm', d, 1) if not postrm: postrm = '#!/bin/sh\n' - postrm += bb.data.getVar('gtk-icon-cache_postrm', d, 1) + postrm += bb.data.getVar('gtk_icon_cache_postrm', d, 1) bb.data.setVar('pkg_postrm_%s' % pkg, postrm, d) } diff --git a/classes/image.bbclass b/classes/image.bbclass index f8d896d813..35080c19eb 100644 --- a/classes/image.bbclass +++ b/classes/image.bbclass @@ -32,6 +32,8 @@ python () { for dep in (bb.data.getVar('EXTRA_IMAGEDEPENDS', d, True) or "").split(): deps += " %s:do_populate_staging" % dep bb.data.setVarFlag('do_rootfs', 'depends', deps, d) + + runtime_mapping_rename("PACKAGE_INSTALL", d) } # @@ -66,6 +68,7 @@ LINGUAS_INSTALL = "${@" ".join(map(lambda s: "locale-base-%s" % s, bb.data.getVa do_rootfs[nostamp] = "1" do_rootfs[dirs] = "${TOPDIR}" +do_rootfs[lockfiles] = "${IMAGE_ROOTFS}.lock" do_build[nostamp] = "1" # Must call real_do_rootfs() from inside here, rather than as a separate diff --git a/classes/oestats-client.bbclass b/classes/oestats-client.bbclass index b98177d40a..c05ede481f 100644 --- a/classes/oestats-client.bbclass +++ b/classes/oestats-client.bbclass @@ -5,8 +5,8 @@ # To make use of this class, add to your local.conf: # # INHERIT += "oestats-client" -# OESTATS_SERVER = "some.server.org:8000" -# OESTATS_BUILDER = "some title" +# OESTATS_SERVER = "some.server.org" +# OESTATS_BUILDER = "some_nickname" def oestats_setid(d, val): import bb @@ -18,65 +18,131 @@ def oestats_getid(d): f = file(bb.data.getVar('TMPDIR', d, True) + '/oestats.id', 'r') return f.read() -def oestats_send(server, action, vars = {}): - import httplib, urllib - - params = urllib.urlencode(vars) - headers = {"Content-type": "application/x-www-form-urlencoded", - "Accept": "text/plain"} +def oestats_send(server, action, vars = {}, files = {}): + import httplib + + # build body + output = [] + bound = '----------ThIs_Is_tHe_bouNdaRY_$' + for key in vars: + assert vars[key] + output.append('--' + bound) + output.append('Content-Disposition: form-data; name="%s"' % key) + output.append('') + output.append(vars[key]) + for key in files: + assert files[key] + output.append('--' + bound) + output.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, files[key]['filename'])) + output.append('Content-Type: %s' % files[key]['content-type']) + + output.append('') + output.append(files[key]['content']) + output.append('--' + bound + '--') + output.append('') + body = "\r\n".join(output) + + # build headers + headers = { + "User-agent": "oestats-client/0.3", + "Content-type": "multipart/form-data; boundary=%s" % bound, + "Content-length": str(len(body))} + + # send request conn = httplib.HTTPConnection(server) - conn.request("POST", action, params, headers) + conn.request("POST", action, body, headers) response = conn.getresponse() + data = response.read() conn.close() - return response + return data def oestats_start(server, builder, d): import bb import os.path + import re # send report - response = oestats_send(server, "/builds/start/", { - 'builder': builder, - 'revision': bb.data.getVar('METADATA_REVISION', d, True), - 'machine': bb.data.getVar('MACHINE', d, True), - 'distro': bb.data.getVar('DISTRO', d, True), - }) - id = response.read() + id = "" + try: + data = oestats_send(server, "/builds/", { + 'builder': builder, + 'revision': bb.data.getVar('METADATA_REVISION', d, True), + 'machine': bb.data.getVar('MACHINE', d, True), + 'distro': bb.data.getVar('DISTRO', d, True), + }) + if re.match("^\d+$", data): id=data + except: + pass # save the build id + if id: + bb.note("oestats: build %s" % id) + else: + bb.note("oestats: error starting build, disabling stats") oestats_setid(d, id) -def oestats_stop(server, d, status): +def oestats_stop(server, d, failures): import bb # retrieve build id id = oestats_getid(d) + if not id: return # send report - response = oestats_send(server, "/builds/stop/%s/" % id, { - 'status': status, - }) + if failures > 0: + status = "Failed" + else: + status = "Succeeded" + + try: + response = oestats_send(server, "/builds/%s/" % id, { + 'status': status, + }) + except: + bb.note("oestats: error stopping build") def oestats_task(server, d, task, status): import bb + import glob import time # retrieve build id id = oestats_getid(d) + if not id: return + + # calculate build time try: elapsed = time.time() - float(bb.data.getVar('OESTATS_STAMP', d, True)) except: elapsed = 0 - + + # send the log for failures + files = {} + if status == 'Failed': + logs = glob.glob("%s/log.%s.*" % (bb.data.getVar('T', d, True), task)) + if len(logs) > 0: + log = logs[0] + bb.note("oestats: sending log file : %s" % log) + files['log'] = { + 'filename': 'log.txt', + 'content': file(log).read(), + 'content-type': 'text/plain'} + # send report - response = oestats_send(server, "/builds/task/%s/" % id, { - 'package': bb.data.getVar('PN', d, True), - 'version': bb.data.getVar('PV', d, True), - 'revision': bb.data.getVar('PR', d, True), - 'task': task, - 'status': status, - 'time': elapsed, - }) + try: + response = oestats_send(server, "/tasks/", { + 'build': id, + 'package': bb.data.getVar('PN', d, True), + 'version': bb.data.getVar('PV', d, True), + 'revision': bb.data.getVar('PR', d, True), + 'depends': bb.data.getVar('DEPENDS', d, True), + 'task': task, + 'status': status, + 'time': str(elapsed), + }, files) + except: + bb.note("oestats: error sending task, disabling stats") + oestats_setid(d, "") addhandler oestats_eventhandler python oestats_eventhandler () { @@ -95,7 +161,7 @@ python oestats_eventhandler () { if getName(e) == 'BuildStarted': oestats_start(server, builder, e.data) elif getName(e) == 'BuildCompleted': - oestats_stop(server, e.data, 'Completed') + oestats_stop(server, e.data, e.getFailures()) elif getName(e) == 'TaskStarted': bb.data.setVar('OESTATS_STAMP', repr(time.time()), e.data) elif getName(e) == 'TaskSucceeded': |