summaryrefslogtreecommitdiff
path: root/classes/patch.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'classes/patch.bbclass')
-rw-r--r--classes/patch.bbclass52
1 files changed, 37 insertions, 15 deletions
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