From f4a53b765a6801f836586b5ee662b5f9392dcfab Mon Sep 17 00:00:00 2001 From: Holger Freyther Date: Sat, 31 Mar 2007 15:57:22 +0000 Subject: classes/patch.bbclass: Make sure to raise func_failed on any exception from within Import non existing patches raised a IOError by the md5sum method which was not catched at all and lead bitbake to exit due an unhandled exception. This is bad for all autobuilders. --- classes/patch.bbclass | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'classes/patch.bbclass') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index 0a7b94cffc..07d18470f7 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -3,10 +3,20 @@ def patch_init(d): import os, sys + class NotFoundError(Exception): + def __init__(self, path): + self.path = path + def __str__(self): + return "Error: %s not found." % self.path + def md5sum(fname): import md5, sys - f = file(fname, 'rb') + try: + f = file(fname, 'rb') + except IOError: + raise NotFoundError(fname) + m = md5.new() while True: d = f.read(8096) @@ -24,11 +34,6 @@ def patch_init(d): def __str__(self): return "Command Error: exit status: %d Output:\n%s" % (self.status, self.output) - class NotFoundError(Exception): - def __init__(self, path): - self.path = path - def __str__(self): - return "Error: %s not found." % self.path def runcmd(args, dir = None): import commands @@ -482,7 +487,7 @@ python patch_do_patch() { bb.note("Applying patch '%s'" % pname) try: patchset.Import({"file":unpacked, "remote":url, "strippath": pnum}, True) - except NotFoundError: + except: import sys raise bb.build.FuncFailed(str(sys.exc_value)) resolver.Resolve() -- cgit v1.2.3 From c89f99d26d4c54205988d91ca2417075ba737bc8 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 9 Apr 2007 21:50:12 +0000 Subject: patch.bbclass/devshell.bbclass: Switch to new form of interactive task handling as per RFC which is more compatible with bitbake 1.8+ --- classes/patch.bbclass | 52 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) (limited to 'classes/patch.bbclass') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index 07d18470f7..a28f8896c9 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -128,11 +128,14 @@ def patch_init(d): i = 0 self.patches.insert(i, patch) - def _applypatch(self, patch, force = None, reverse = None): + def _applypatch(self, patch, force = False, reverse = False, run = True): shellcmd = ["cat", patch['file'], "|", "patch", "-p", patch['strippath']] if reverse: shellcmd.append('-R') + if not run: + return "sh" + "-c" + " ".join(shellcmd) + if not force: shellcmd.append('--dry-run') @@ -145,7 +148,7 @@ def patch_init(d): output = runcmd(["sh", "-c", " ".join(shellcmd)], self.dir) return output - def Push(self, force = None, all = None): + def Push(self, force = False, all = False, run = True): bb.note("self._current is %s" % self._current) bb.note("patches is %s" % self.patches) if all: @@ -162,7 +165,7 @@ def patch_init(d): else: self._current = 0 bb.note("applying patch %s" % self.patches[self._current]) - self._applypatch(self.patches[self._current], force) + return self._applypatch(self.patches[self._current], force) def Pop(self, force = None, all = None): @@ -176,7 +179,9 @@ def patch_init(d): """""" class QuiltTree(PatchSet): - def _runcmd(self, args): + def _runcmd(self, args, run = True): + if not run: + return ["quilt"] + args runcmd(["quilt"] + args, self.dir) def _quiltpatchpath(self, file): @@ -251,7 +256,7 @@ def patch_init(d): self.patches.insert(self._current or 0, patch) - def Push(self, force = None, all = None): + def Push(self, force = False, all = False, run = True): # quilt push [-f] args = ["push"] @@ -259,6 +264,8 @@ def patch_init(d): args.append("-f") if all: args.append("-a") + if not run: + return self._runcmd(args, run) self._runcmd(args) @@ -345,16 +352,31 @@ def patch_init(d): olddir = os.path.abspath(os.curdir) os.chdir(self.patchset.dir) - try: - self.patchset.Push(True) - except CmdError, v: - # Patch application failed - if sys.exc_value.output.strip() == "No patches applied": - return - print(sys.exc_value) - print('NOTE: dropping user into a shell, so that patch rejects can be fixed manually.') - - os.system('/bin/sh') + try: + self.patchset.Push(False) + except CmdError, v: + # Patch application failed + patchcmd = self.patchset.Push(True, False, False) + + t = bb.data.getVar('T', d, 1) + if not t: + bb.msg.fatal(bb.msg.domain.Build, "T not set") + bb.mkdirhier(t) + import random + rcfile = "%s/bashrc.%s.%s" % (t, str(os.getpid()), random.random()) + f = open(rcfile, "w") + f.write("echo '*** Manual patch resolution mode ***'\n") + f.write("echo 'Dropping to a shell, so patch rejects can be fixed manually.'\n") + f.write("echo 'Run \"quilt refresh\" when patch is corrected, press CTRL+D to exit.'\n") + f.write("echo ''\n") + f.write(" ".join(patchcmd) + "\n") + f.write("#" + bb.data.getVar('TERMCMDRUN', d, 1)) + f.close() + os.chmod(rcfile, 0775) + + os.environ['TERMWINDOWTITLE'] = "Bitbake: Please fix patch rejects manually" + os.environ['TERMRCFILE'] = rcfile + os.system(bb.data.getVar('TERMCMDRUN', d, 1)) # Construct a new PatchSet after the user's changes, compare the # sets, checking patches for modifications, and doing a remote -- cgit v1.2.3 From 1a7cff6077b770083062952ef6f6f7517bfd2c07 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 18 Apr 2007 21:22:03 +0000 Subject: classes: Add support for intertask dependencies to be specified, needed for correct operation with bitbake 1.8.x. Old behaviour is maintained in a special legacy anonymous function in base.bbclass. The patch is an improved version of the one discussed on the mailing list. --- classes/patch.bbclass | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'classes/patch.bbclass') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index a28f8896c9..84cca7f5a0 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -417,6 +417,17 @@ def patch_init(d): addtask patch after do_unpack do_patch[dirs] = "${WORKDIR}" + +python () { + import bb + # do_patch tasks require PATCHTOOL-native to have staged + patchdeps = bb.data.getVar("PATCHTOOL", d, True) + if patchdeps: + patchdeps = "%s-native" % patchdeps + if not patchdeps in bb.data.getVar("PROVIDES", d, True): + bb.data.setVarFlag('do_patch', 'depends', patchdeps + ":do_populate_staging", d) +} + python patch_do_patch() { import re import bb.fetch -- cgit v1.2.3 From 2e2348dbf283fe186a7e45a4823b56fed70d47f0 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 11 May 2007 11:43:28 +0000 Subject: devshell.bbclass, patch.bbclass: Check exit code of TERMCMD* commands to see if they were found at all. * Fixes #2274. --- classes/patch.bbclass | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'classes/patch.bbclass') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index 84cca7f5a0..7a5dcac57a 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -376,7 +376,10 @@ def patch_init(d): os.environ['TERMWINDOWTITLE'] = "Bitbake: Please fix patch rejects manually" os.environ['TERMRCFILE'] = rcfile - os.system(bb.data.getVar('TERMCMDRUN', d, 1)) + rc = os.system(bb.data.getVar('TERMCMDRUN', d, 1)) + if os.WIFEXITED(rc) and os.WEXITSTATUS(rc) == 127: + bb.msg.fatal(bb.msg.domain.Build, ("Cannot proceed with manual patch resolution - '%s' not found. " \ + + "Check TERMCMDRUN variable.") % bb.data.getVar('TERMCMDRUN', d, 1)) # Construct a new PatchSet after the user's changes, compare the # sets, checking patches for modifications, and doing a remote -- cgit v1.2.3 From 500967160d58626953ec52c4f927445aed6150b2 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 11 May 2007 11:45:42 +0000 Subject: devshell.bbclass, patch.bbclass: Error on any non-zero rc from TERMCMD*. * Suggested by Richard Purdie. * Closes #2274. --- classes/patch.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/patch.bbclass') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index 7a5dcac57a..12657fa0f6 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -377,7 +377,7 @@ def patch_init(d): os.environ['TERMWINDOWTITLE'] = "Bitbake: Please fix patch rejects manually" os.environ['TERMRCFILE'] = rcfile rc = os.system(bb.data.getVar('TERMCMDRUN', d, 1)) - if os.WIFEXITED(rc) and os.WEXITSTATUS(rc) == 127: + if os.WIFEXITED(rc) and os.WEXITSTATUS(rc) != 0: bb.msg.fatal(bb.msg.domain.Build, ("Cannot proceed with manual patch resolution - '%s' not found. " \ + "Check TERMCMDRUN variable.") % bb.data.getVar('TERMCMDRUN', d, 1)) -- cgit v1.2.3 From f8b12ef5be647d1bd011d2415c458b937ab61c96 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 3 Aug 2007 00:18:28 +0000 Subject: patch.bbclass: Add minrev and maxrev support for patches, cleanup maxdate and mindate support --- classes/patch.bbclass | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'classes/patch.bbclass') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index 12657fa0f6..2ba6729af8 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -492,33 +492,35 @@ python patch_do_patch() { else: pname = os.path.basename(unpacked) - if "mindate" in parm: - mindate = parm["mindate"] - else: - mindate = 0 - - if "maxdate" in parm: - maxdate = parm["maxdate"] - else: - maxdate = "20711226" - - pn = bb.data.getVar('PN', d, 1) - srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1) + if "mindate" in parm or "maxdate" in parm: + pn = bb.data.getVar('PN', d, 1) + srcdate = bb.data.getVar('SRCDATE_%s' % pn, d, 1) + if not srcdate: + srcdate = bb.data.getVar('SRCDATE', d, 1) - if not srcdate: - srcdate = bb.data.getVar('SRCDATE', d, 1) + if srcdate == "now": + srcdate = bb.data.getVar('DATE', d, 1) - if srcdate == "now": - srcdate = bb.data.getVar('DATE', d, 1) - - if (maxdate < srcdate) or (mindate > srcdate): - if (maxdate < srcdate): + if "maxdate" in parm and parm["maxdate"] < srcdate: bb.note("Patch '%s' is outdated" % pname) + continue - if (mindate > srcdate): + if "mindate" in parm and parm["mindate"] > srcdate: bb.note("Patch '%s' is predated" % pname) + continue - continue + + if "minrev" in parm: + srcrev = bb.data.getVar('SRCREV', d, 1) + if srcrev and srcrev < parm["minrev"]: + bb.note("Patch '%s' applies to later revisions" % pname) + continue + + if "maxrev" in parm: + srcrev = bb.data.getVar('SRCREV', d, 1) + if srcrev and srcrev > parm["maxrev"]: + bb.note("Patch '%s' applies to earlier revisions" % pname) + continue bb.note("Applying patch '%s'" % pname) try: -- cgit v1.2.3 From 31af90140f95e186bc2f5a53f725429abaa8df57 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Fri, 3 Aug 2007 14:32:53 +0000 Subject: patch.bbclass: give empty file for quilt so it will not use config from user homedir - closes #2704 (code from Poky) --- classes/patch.bbclass | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'classes/patch.bbclass') diff --git a/classes/patch.bbclass b/classes/patch.bbclass index 2ba6729af8..0cc202820f 100644 --- a/classes/patch.bbclass +++ b/classes/patch.bbclass @@ -1,5 +1,8 @@ # Copyright (C) 2006 OpenedHand LTD +# Point to an empty file so any user's custom settings don't break things +QUILTRCFILE ?= "${STAGING_BINDIR_NATIVE}/quiltrc" + def patch_init(d): import os, sys @@ -180,9 +183,10 @@ def patch_init(d): class QuiltTree(PatchSet): def _runcmd(self, args, run = True): + quiltrc = bb.data.getVar('QUILTRCFILE', self.d, 1) if not run: - return ["quilt"] + args - runcmd(["quilt"] + args, self.dir) + return ["quilt"] + ["--quiltrc"] + [quiltrc] + args + runcmd(["quilt"] + ["--quiltrc"] + [quiltrc] + args, self.dir) def _quiltpatchpath(self, file): return os.path.join(self.dir, "patches", os.path.basename(file)) -- cgit v1.2.3