summaryrefslogtreecommitdiffstats
path: root/meta/classes/devshell.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/devshell.bbclass')
-rw-r--r--meta/classes/devshell.bbclass155
1 files changed, 0 insertions, 155 deletions
diff --git a/meta/classes/devshell.bbclass b/meta/classes/devshell.bbclass
deleted file mode 100644
index fdf7dc100f..0000000000
--- a/meta/classes/devshell.bbclass
+++ /dev/null
@@ -1,155 +0,0 @@
1inherit terminal
2
3DEVSHELL = "${SHELL}"
4
5python do_devshell () {
6 if d.getVarFlag("do_devshell", "manualfakeroot"):
7 d.prependVar("DEVSHELL", "pseudo ")
8 fakeenv = d.getVar("FAKEROOTENV").split()
9 for f in fakeenv:
10 k = f.split("=")
11 d.setVar(k[0], k[1])
12 d.appendVar("OE_TERMINAL_EXPORTS", " " + k[0])
13 d.delVarFlag("do_devshell", "fakeroot")
14
15 oe_terminal(d.getVar('DEVSHELL'), 'OpenEmbedded Developer Shell', d)
16}
17
18addtask devshell after do_patch do_prepare_recipe_sysroot
19
20# The directory that the terminal starts in
21DEVSHELL_STARTDIR ?= "${S}"
22do_devshell[dirs] = "${DEVSHELL_STARTDIR}"
23do_devshell[nostamp] = "1"
24
25# devshell and fakeroot/pseudo need careful handling since only the final
26# command should run under fakeroot emulation, any X connection should
27# be done as the normal user. We therfore carefully construct the envionment
28# manually
29python () {
30 if d.getVarFlag("do_devshell", "fakeroot"):
31 # We need to signal our code that we want fakeroot however we
32 # can't manipulate the environment and variables here yet (see YOCTO #4795)
33 d.setVarFlag("do_devshell", "manualfakeroot", "1")
34 d.delVarFlag("do_devshell", "fakeroot")
35}
36
37def devpyshell(d):
38
39 import code
40 import select
41 import signal
42 import termios
43
44 m, s = os.openpty()
45 sname = os.ttyname(s)
46
47 def noechoicanon(fd):
48 old = termios.tcgetattr(fd)
49 old[3] = old[3] &~ termios.ECHO &~ termios.ICANON
50 # &~ termios.ISIG
51 termios.tcsetattr(fd, termios.TCSADRAIN, old)
52
53 # No echo or buffering over the pty
54 noechoicanon(s)
55
56 pid = os.fork()
57 if pid:
58 os.close(m)
59 oe_terminal("oepydevshell-internal.py %s %d" % (sname, pid), 'OpenEmbedded Developer PyShell', d)
60 os._exit(0)
61 else:
62 os.close(s)
63
64 os.dup2(m, sys.stdin.fileno())
65 os.dup2(m, sys.stdout.fileno())
66 os.dup2(m, sys.stderr.fileno())
67
68 bb.utils.nonblockingfd(sys.stdout)
69 bb.utils.nonblockingfd(sys.stderr)
70 bb.utils.nonblockingfd(sys.stdin)
71
72 _context = {
73 "os": os,
74 "bb": bb,
75 "time": time,
76 "d": d,
77 }
78
79 ps1 = "pydevshell> "
80 ps2 = "... "
81 buf = []
82 more = False
83
84 i = code.InteractiveInterpreter(locals=_context)
85 print("OE PyShell (PN = %s)\n" % d.getVar("PN"))
86
87 def prompt(more):
88 if more:
89 prompt = ps2
90 else:
91 prompt = ps1
92 sys.stdout.write(prompt)
93 sys.stdout.flush()
94
95 # Restore Ctrl+C since bitbake masks this
96 def signal_handler(signal, frame):
97 raise KeyboardInterrupt
98 signal.signal(signal.SIGINT, signal_handler)
99
100 child = None
101
102 prompt(more)
103 while True:
104 try:
105 try:
106 (r, _, _) = select.select([sys.stdin], [], [], 1)
107 if not r:
108 continue
109 line = sys.stdin.readline().strip()
110 if not line:
111 prompt(more)
112 continue
113 except EOFError as e:
114 sys.stdout.write("\n")
115 sys.stdout.flush()
116 except (OSError, IOError) as e:
117 if e.errno == 11:
118 continue
119 if e.errno == 5:
120 return
121 raise
122 else:
123 if not child:
124 child = int(line)
125 continue
126 buf.append(line)
127 source = "\n".join(buf)
128 more = i.runsource(source, "<pyshell>")
129 if not more:
130 buf = []
131 prompt(more)
132 except KeyboardInterrupt:
133 i.write("\nKeyboardInterrupt\n")
134 buf = []
135 more = False
136 prompt(more)
137 except SystemExit:
138 # Easiest way to ensure everything exits
139 os.kill(child, signal.SIGTERM)
140 break
141
142python do_devpyshell() {
143 import signal
144
145 try:
146 devpyshell(d)
147 except SystemExit:
148 # Stop the SIGTERM above causing an error exit code
149 return
150 finally:
151 return
152}
153addtask devpyshell after do_patch
154
155do_devpyshell[nostamp] = "1"