-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathbuild_on_krunvm_debian.sh
executable file
·56 lines (46 loc) · 1.42 KB
/
build_on_krunvm_debian.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
#!/bin/sh
# This is a helper script for building the Linux kernel on macOS using
# a lightweight VM with krunvm.
KRUNVM=`which krunvm`
if [ -z "$KRUNVM" ]; then
echo "Couldn't find krunvm binary"
exit -1
fi
# realpath does not exist by default on macOS, use `brew install coreutils` to get it
SCRIPTPATH=`realpath $0`
WORKDIR=`dirname $SCRIPTPATH`
krunvm create debian:bookworm-slim --name libkrunfw-builder --cpus 2 --mem 2048 -v $WORKDIR:/work -w /work
if [ $? != 0 ]; then
echo "Error creating lightweight VM"
exit -1
fi
krunvm start libkrunfw-builder /usr/bin/apt-get -- update
if [ $? != 0 ]; then
echo "Error updating debian repository"
krunvm delete libkrunfw-builder
exit -1
fi
krunvm start libkrunfw-builder /usr/bin/apt-get -- upgrade -y
if [ $? != 0 ]; then
echo "Error upgrading debian packages"
krunvm delete libkrunfw-builder
exit -1
fi
krunvm start libkrunfw-builder /usr/bin/apt-get -- install -y curl build-essential python3-pyelftools bc kmod cpio flex libncurses5-dev libelf-dev libssl-dev dwarves bison
if [ $? != 0 ]; then
echo "Error installing build dependencies on VM"
krunvm delete libkrunfw-builder
exit -1
fi
krunvm start libkrunfw-builder /usr/bin/make -- -j2
if [ $? != 0 ]; then
echo "Error running command on VM"
krunvm delete libkrunfw-builder
exit -1
fi
krunvm delete libkrunfw-builder
if [ ! -e "kernel.c" ]; then
echo "There was a problem building the kernel bundle in the VM"
exit -1
fi
exit 0