-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.sh
executable file
·79 lines (68 loc) · 1.78 KB
/
build.sh
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
#!/bin/bash
# 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
set -o pipefail
# Path to statically built busybox binary i.e.
# busybox=/usr/bin/busybox-static-aarch64
execs="start delete state serial_start create pause mount"
# Clean the repo, but save the vendor area
if [ "x${1:-}" != "x" ] && [ "clean" == "$1" ]; then
echo "cleaning project"
rm -rf kernel/out
rm -rf kernel/build
rm -rf initrd/out
rm -rf target
cd sendfd
make clean
cd -
exit 0
fi
# Support cross-compiling via ARCH variable
if [[ -z "$ARCH" ]]
then
ARCH=`uname -m`
fi
if [[ $ARCH = "x86_64" ]]
then
export ARCH="x86"
elif [[ $ARCH = "aarch64" || $ARCH = "arm64" ]]
then
export ARCH="arm64"
elif [[ $ARCH = "arm" || $ARCH = "arm32" ]]
then
export ARCH="arm"
else
echo Architecture not supported
exit 1
fi
mkdir -p target/usr/share/runX
for i in $execs; do
cp files/$i target/usr/share/runX
done
cd sendfd
make
cd ..
cp sendfd/sendfd target/usr/share/runX/
mkdir -p target/usr/sbin
cp runX target/usr/sbin
# Build the kernel and initrd
if test \! -f target/usr/share/runX/kernel
then
kernel/make-kernel
cp kernel/out/kernel target/usr/share/runX
fi
if test \! -f target/usr/share/runX/initrd
then
initrd/make-initrd
cp initrd/out/initrd target/usr/share/runX
fi