1 |
lu_zero 12/02/28 13:55:53 |
2 |
|
3 |
Added: qemu-binfmt.initd |
4 |
Log: |
5 |
New version, static only |
6 |
|
7 |
(Portage version: 2.2.0_alpha89/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 app-emulation/qemu-user/files/qemu-binfmt.initd |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/qemu-user/files/qemu-binfmt.initd?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-emulation/qemu-user/files/qemu-binfmt.initd?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: qemu-binfmt.initd |
16 |
=================================================================== |
17 |
#!/sbin/runscript |
18 |
# Copyright 1999-2012 Gentoo Foundation |
19 |
# Distributed under the terms of the GNU General Public License v2 |
20 |
# $Header: /var/cvsroot/gentoo-x86/app-emulation/qemu-user/files/qemu-binfmt.initd,v 1.1 2012/02/28 13:55:53 lu_zero Exp $ |
21 |
|
22 |
# enable automatic i386/ARM/M68K/MIPS/SPARC/PPC/s390 program execution by the kernel |
23 |
|
24 |
depend() { |
25 |
after procfs |
26 |
} |
27 |
|
28 |
start() { |
29 |
ebegin "Registering qemu-user binaries" |
30 |
|
31 |
if [[ ! -d /proc/sys/fs/binfmt_misc ]] ; then |
32 |
eerror "You need support for \"misc binaries\" in your kernel!" |
33 |
eend 1 |
34 |
fi |
35 |
|
36 |
if [[ $(mount | grep -c binfmt_misc) -eq 0 ]] ; then |
37 |
mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc &> /dev/null |
38 |
local result=$? |
39 |
|
40 |
if [[ $result -ne 0 ]] ; then |
41 |
eend $result |
42 |
fi |
43 |
fi |
44 |
|
45 |
# probe cpu type |
46 |
cpu=`uname -m` |
47 |
case "$cpu" in |
48 |
i386|i486|i586|i686|i86pc|BePC|x86_64) |
49 |
cpu="i386" |
50 |
;; |
51 |
m68k) |
52 |
cpu="m68k" |
53 |
;; |
54 |
mips*) |
55 |
cpu="mips" |
56 |
;; |
57 |
"Power Macintosh"|ppc|ppc64) |
58 |
cpu="ppc" |
59 |
;; |
60 |
armv[4-9]*) |
61 |
cpu="arm" |
62 |
;; |
63 |
sparc*) |
64 |
cpu="sparc" |
65 |
;; |
66 |
esac |
67 |
|
68 |
# register the interpreter for each cpu except for the native one |
69 |
if [ $cpu != "i386" -a -x "/usr/bin/qemu-static-i386-binfmt" ] ; then |
70 |
echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-static-i386-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
71 |
echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-static-i386-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
72 |
fi |
73 |
if [ $cpu != "alpha" -a -x "/usr/bin/qemu-static-alpha-binfmt" ] ; then |
74 |
echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-static-alpha-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
75 |
fi |
76 |
if [ $cpu != "arm" -a -x "/usr/bin/qemu-static-arm-binfmt" ] ; then |
77 |
echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-static-arm-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
78 |
fi |
79 |
if [ $cpu != "arm" -a -x "/usr/bin/qemu-static-armeb-binfmt" ] ; then |
80 |
echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-static-armeb-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
81 |
fi |
82 |
if [ $cpu != "sparc" -a -x "/usr/bin/qemu-static-sparc-binfmt" ] ; then |
83 |
echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-static-sparc-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
84 |
fi |
85 |
if [ $cpu != "ppc" -a -x "/usr/bin/qemu-static-ppc-binfmt" ] ; then |
86 |
echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-static-ppc-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
87 |
fi |
88 |
if [ $cpu != "m68k" -a -x "/usr/bin/qemu-static-m68k-binfmt" ] ; then |
89 |
echo 'Please check cpu value and header information for m68k!' |
90 |
echo ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-static-m68k-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
91 |
fi |
92 |
if [ $cpu != "mips" -a -x "/usr/bin/qemu-static-mips-binfmt" ] ; then |
93 |
# FIXME: We could use the other endianness on a MIPS host. |
94 |
echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-static-mips-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
95 |
fi |
96 |
if [ $cpu != "mips" -a -x "/usr/bin/qemu-static-mipsel-binfmt" ] ; then |
97 |
echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-static-mipsel-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
98 |
fi |
99 |
if [ $cpu != "mips" -a -x "/usr/bin/qemu-static-mipsn32-binfmt" ] ; then |
100 |
echo ':mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-static-mipsn32-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
101 |
fi |
102 |
if [ $cpu != "mips" -a -x "/usr/bin/qemu-static-mipsn32el-binfmt" ] ; then |
103 |
echo ':mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-static-mipsn32el-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
104 |
fi |
105 |
if [ $cpu != "mips" -a -x "/usr/bin/qemu-static-mips64-binfmt" ] ; then |
106 |
echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-static-mips64-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
107 |
fi |
108 |
if [ $cpu != "mips" -a -x "/usr/bin/qemu-static-mips64el-binfmt" ] ; then |
109 |
echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-static-mips64el-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
110 |
fi |
111 |
if [ $cpu != "sh" -a -x "/usr/bin/qemu-static-sh4-binfmt" ] ; then |
112 |
echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-static-sh4-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
113 |
fi |
114 |
if [ $cpu != "sh" -a -x "/usr/bin/qemu-static-sh4eb-binfmt" ] ; then |
115 |
echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-static-sh4eb-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
116 |
fi |
117 |
if [ $cpu != "s390x" -a -x "/usr/local/bin/qemu-static-s390x-binfmt" ] ; then |
118 |
echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-static-s390x-binfmt:P' > /proc/sys/fs/binfmt_misc/register |
119 |
fi |
120 |
eend $? |
121 |
} |
122 |
|
123 |
stop() { |
124 |
ebegin "Unregistering qemu-user binaries" |
125 |
local arches |
126 |
|
127 |
arches="${arches} i386 i486" |
128 |
arches="${arches} alpha" |
129 |
arches="${arches} arm armeb" |
130 |
arches="${arches} sparc" |
131 |
arches="${arches} ppc" |
132 |
arches="${arches} m68k" |
133 |
arches="${arches} mips mipsel mipsn32 mipsn32el mips64 mips64el" |
134 |
arches="${arches} sh4 sh4eb" |
135 |
arches="${arches} s390x" |
136 |
|
137 |
for a in ${arches}; do |
138 |
if [[ -f /proc/sys/fs/binfmt_misc/$a ]] ; then |
139 |
echo '-1' > /proc/sys/fs/binfmt_misc/$a |
140 |
fi |
141 |
done |
142 |
|
143 |
eend $? |
144 |
} |
145 |
|
146 |
# vim: ts=4 : |