Repository navigation
Expand file tree
/
Copy pathdeploy.sh
More file actions
107 lines (97 loc) · 2.7 KB
/
Copy pathdeploy.sh
File metadata and controls
107 lines (97 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
# Linux Deploy Component
# (c) Anton Skshidlevsky <meefik@gmail.com>, GPLv3
HOST_PLATFORM=$(get_platform)
GUEST_PLATFORM=$(get_platform "${ARCH}")
if [ -z "${EMULATOR}" -a "${HOST_PLATFORM}" != "${GUEST_PLATFORM}" ]; then
case "${GUEST_PLATFORM}" in
arm)
EMULATOR="qemu-arm-static"
;;
intel)
EMULATOR="qemu-i386-static"
;;
*)
EMULATOR=""
;;
esac
fi
do_configure()
{
if [ -z "${EMULATOR}" -o "${FAKEROOT}" = "1" ]; then
return 0
fi
multiarch_support || return 0
msg ":: Configuring ${COMPONENT} ... "
local qemu_source=$(which "${EMULATOR}")
local qemu_target="${CHROOT_DIR}/usr/local/bin/${EMULATOR}"
[ -e "${qemu_target}" ] && return 0
[ -z "${qemu_source}" ] && return 1
if [ ! -d "${CHROOT_DIR}/usr/local/bin" ]; then
mkdir -p "${CHROOT_DIR}/usr/local/bin"
fi
cp "${qemu_source}" "${qemu_target}"
chroot_exec chown root:root "/usr/local/bin/${EMULATOR}"
chmod 755 "${qemu_target}"
return 0
}
do_start()
{
if [ -z "${EMULATOR}" -o "${FAKEROOT}" = "1" ]; then
return 0
fi
multiarch_support || return 0
msg -n ":: Starting ${COMPONENT} ... "
case "$(get_platform)" in
arm)
if [ ! -e "${binfmt_dir}/qemu-i386" ]; then
echo ":qemu-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/local/bin/${EMULATOR}:" > "${binfmt_dir}/register"
is_ok "fail" "done"
else
msg "skip"
fi
;;
intel)
if [ ! -e "${binfmt_dir}/qemu-arm" ]; then
echo ":qemu-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/local/bin/${EMULATOR}:" > "${binfmt_dir}/register"
is_ok "fail" "done"
else
msg "skip"
fi
;;
*)
msg "skip"
;;
esac
return 0
}
do_stop()
{
if [ -z "${EMULATOR}" -o "${FAKEROOT}" = "1" ]; then
return 0
fi
multiarch_support || return 0
local binfmt_dir="/proc/sys/fs/binfmt_misc"
local binfmt_qemu=""
case "$(get_platform)" in
arm)
binfmt_qemu="${binfmt_dir}/qemu-i386"
;;
intel)
binfmt_qemu="${binfmt_dir}/qemu-arm"
;;
esac
if [ -e "${binfmt_qemu}" ]; then
msg -n ":: Stopping ${COMPONENT} ... "
echo -1 > "${binfmt_qemu}"
is_ok "fail" "done"
fi
return 0
}
do_help()
{
cat <<EOF
--emulator=PATH
Указать какой использовать эмулятор, по умолчанию QEMU.
EOF
}