[oe-commits] org.oe.dev patch.bbclass/devshell.bbclass: Switch to new form of interactive task handling as per RFC which is more compatible with bitbake 1.8+

rpurdie commit openembedded-commits at lists.openembedded.org
Mon Apr 9 21:53:14 UTC 2007


patch.bbclass/devshell.bbclass: Switch to new form of interactive task handling as per RFC which is more compatible with bitbake 1.8+

Author: rpurdie at openembedded.org
Branch: org.openembedded.dev
Revision: 8a8c931a85ea0693a8522c7123b4127c0cabc431
ViewMTN: http://monotone.openembedded.org/revision.psp?id=8a8c931a85ea0693a8522c7123b4127c0cabc431
Files:
1
classes/devshell.bbclass
classes/patch.bbclass
conf/bitbake.conf
Diffs:

#
# mt diff -r11e188745d3928bb298b7098cc047078e51abf61 -r8a8c931a85ea0693a8522c7123b4127c0cabc431
#
# 
# 
# patch "classes/devshell.bbclass"
#  from [2c90ac56d14aa5ab4e7c1b2950129d31018f02ca]
#    to [ad428a97132e45ce98ab989da39f89beb8ceb5be]
# 
# patch "classes/patch.bbclass"
#  from [c003cee48863ad38aa2a48daab2a06cceaaee977]
#    to [27225cf1e714d9fe8497a039e8af77c65472940c]
# 
# patch "conf/bitbake.conf"
#  from [4dbad01557f0aca5fb71dee774989b86858d501c]
#    to [5b2d727f9640faac120f9e47969de2eadd6e2648]
# 
============================================================
--- classes/devshell.bbclass	2c90ac56d14aa5ab4e7c1b2950129d31018f02ca
+++ classes/devshell.bbclass	ad428a97132e45ce98ab989da39f89beb8ceb5be
@@ -1,10 +1,11 @@ do_devshell[nostamp] = "1"
 EXTRA_OEMAKE[export] = "1"
 
 do_devshell[dirs] = "${S}"
 do_devshell[nostamp] = "1"
-do_devshell[interactive] = "1"
+
 devshell_do_devshell() {
-	bash -i
+	export TERMWINDOWTITLE="Bitbake Developer Shell"
+	${TERMCMD}
 }
 addtask devshell after do_patch
 
============================================================
--- classes/patch.bbclass	c003cee48863ad38aa2a48daab2a06cceaaee977
+++ classes/patch.bbclass	27225cf1e714d9fe8497a039e8af77c65472940c
@@ -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,17 +352,32 @@ 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.')
+ 			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))
 
-				os.system('/bin/sh')
-
 				# Construct a new PatchSet after the user's changes, compare the
 				# sets, checking patches for modifications, and doing a remote
 				# refresh on each.
============================================================
--- conf/bitbake.conf	4dbad01557f0aca5fb71dee774989b86858d501c
+++ conf/bitbake.conf	5b2d727f9640faac120f9e47969de2eadd6e2648
@@ -365,6 +365,25 @@ SRC_URI = "file://${FILE}"
 SRC_URI = "file://${FILE}"
 
 ##################################################################
+# UI/Interaction Configuration
+##################################################################
+
+SHELLRCCMD = "bash --rcfile $TERMRCFILE"
+# Some common terminal programs to choose from
+GNOME_TERMCMD = 'gnome-terminal --disable-factory -t "$TERMWINDOWTITLE"'
+GNOME_TERMCMDRUN = '${GNOME_TERMCMD} -x ${SHELLRCCMD}'
+SCREEN_TERMCMD = 'screen -D -m -t "$TERMWINDOWTITLE"'
+SCREEN_TERMCMDRUN = '${SCREEN_TERMCMD} ${SHELLRCCMD}'
+XTERM_TERMCMD = 'xterm -T "$TERMWINDOWTITLE"'
+XTERM_TERMCMDRUN = '${XTERM_TERMCMD} -e ${SHELLRCCMD}'
+KONSOLE_TERMCMD = 'konsole -T "$TERMWINDOWTITLE"'
+KONSOLE_TERMCMDRUN = '${KCONSOLE_TERMCMD} -e ${SHELLRCCMD}'
+
+# Set a default
+TERMCMD ?= "${GNOME_TERMCMD}"
+TERMCMDRUN ?= "${GNOME_TERMCMDRUN}"
+
+##################################################################
 # Miscellaneous utilities.
 ##################################################################
 






More information about the Openembedded-commits mailing list