-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun_RISC_OS
executable file
·117 lines (102 loc) · 3.14 KB
/
run_RISC_OS
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
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
#
# Copyright (c) 2018, Timothy Baldwin
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
: ${RISC_OS__OpenTerm:=0}
term=
choose_term() {
for term in xterm x-terminal-emulator konsole gnome-terminal mate-terminal
do
if command -v $term 2>/dev/null; then
return 0
fi
done
return 1
}
readonly() {
RISC_OS__BWRAP_EXTRA="$RISC_OS__BWRAP_EXTRA --ro-bind ${1@Q} ${1@Q}"
}
readwrite() {
RISC_OS__BWRAP_EXTRA="$RISC_OS__BWRAP_EXTRA --bind ${1@Q} ${1@Q}"
}
init_make_opts() {
make_opts=( -f Unix/LinuxSupport/common.mk script-all )
if [[ "$RISC_OS__INSECURE" == "YES" ]]; then
make_opts+=( INSECURE=YES )
else
make_opts+=( Built/seccomp- )
fi
}
gui_make_opts() {
eval "gui=( ${RISC_OS__GUI:=Built/sdl} )"
if [[ $gui == Built/sdl || $gui == Built/opengl ]]; then
make_opts+=( "$gui" )
fi
}
run_make() {
mkdir -p Built
if [[ $RISC_OS__OpenTerm -gt 0 ]]; then
(
flock --close Built make -j$(getconf _NPROCESSORS_ONLN) "${make_opts[@]}" || { sleep 3600; false; }
) 2>&1 | (
if ! Built/wait_stdin; then
choose_term
( $term -e bash -c "cat </proc/$BASHPID/fd/0; sleep 6" ) &
fi
)
else
flock --close Built make -j$(getconf _NPROCESSORS_ONLN) "${make_opts[@]}"
fi
}
if [[ -r config ]]; then
. config
fi
if [[ $RISC_OS__OpenTerm -gt 0 ]]; then
exec >/dev/null </dev/null
exec 2> >(cat >&2)
fi
init_make_opts
gui_make_opts
run_make
if [[ ! -e 'HardDisc4/!Boot/Loader/CMOS' ]]; then (
shopt -s nullglob
mkdir -p 'HardDisc4/!Boot/Loader'
nvram=('HardDisc4/!Boot/CMOS',??? 'HardDisc4/!Boot/CMOS')
ln "$nvram" 'HardDisc4/!Boot/Loader/CMOS'
) fi
: ${RISC_OS_Alias_IXFSBoot:='/<IXFS$HardDisc4>.!Boot'}
export RISC_OS_Alias_IXFSBoot
eval "bwrap_extra=($RISC_OS__BWRAP_EXTRA)"
for i in /usr /sbin /bin /lib* /etc/alternatives /etc/manpath.config; do
if [[ -L "$i" ]]; then
bwrap_extra+=(--symlink "$(readlink "$i")" "$i")
else
bwrap_extra+=(--ro-bind-try "$i" "$i")
fi
done
if [[ "$RISC_OS__INSECURE" == "YES" ]]; then
RISC_OS_IXFS_HardDisc4='IXFS:$.dev.fd.5.HardDisc4' exec $RISC_OS__GUI Built/wrapper --handle-reboots -- Built/qemu-link Unix/RISCOS.IMG --nvram 'HardDisc4/!Boot/Loader/CMOS' 5<.
else
RISC_OS_IXFS_HardDisc4='IXFS:$.HardDisc4' exec $RISC_OS__GUI Built/wrapper --network --handle-reboots \
bwrap --seccomp -- --unshare-all --die-with-parent --cap-drop ALL --tmpfs / --proc /proc --dev /dev \
--ro-bind Built /Built \
--ro-bind Unix/RISCOS.IMG /RISC_OS \
--bind HardDisc4 /HardDisc4 \
"${bwrap_extra[@]}" --chdir /bin \
--tmpfs /tmp --tmpfs /run \
--remount-ro / \
/Built/qemu-link /RISC_OS --nvram '/HardDisc4/!Boot/Loader/CMOS'
fi