-
Notifications
You must be signed in to change notification settings - Fork 12
/
kerndev-install
executable file
·75 lines (57 loc) · 1.8 KB
/
kerndev-install
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
#!/bin/bash
set -e; set -o pipefail; source kerndev-shared.sh
# If argument provided it specifies a cross-compile target architecture.
target_arch=${1:-$(uname -m)}
rootfs=rootfs.img
case $target_arch in
arm)
# Use aarch64 + backwards compatibility.
;&
aarch64)
linux_arch="arm64"
cross_compile_prefix="aarch64-linux-gnu-"
;;
x86_64)
kernel_image_path=$LINUX_DEV_PATH/arch/x86/boot/bzImage
check_linux_dev_path
[[ ! -f $kernel_image_path ]] && \
fatal "can't find kernel image at $kernel_image_path"
;;
*)
fatal "unknown architecture: $target_arch"
;;
esac
if [[ "$target_arch" != "$(uname -m)" ]]; then
rootfs=rootfs_${target_arch}.img
make_opts="ARCH=${linux_arch} CROSS_COMPILE=$cross_compile_prefix"
fi
# Sanity checks.
rootfs_image_path=$KERNDEV_PATH/$rootfs
[[ ! -f $rootfs_image_path ]] && \
fatal "can't find root fs image at $rootfs_image_path"
elevate $@
push_linux
unmount
mount_image $rootfs
trap unmount EXIT
echo Installing headers and modules...
mak headers_install INSTALL_HDR_PATH=/mnt/usr/
mak modules_install INSTALL_MOD_PATH=/mnt/
if [[ -z "$USE_EXISTING_IMAGE" ]] && [[ -n "$ENABLE_GCOV" ]]; then
# We need to copy the linux source code to be able to gcov it.
echo "Copying linux source to image (gcov)..."
image_linux_dev_path=/mnt/home/$SUDO_USER/linux
rm -rf $image_linux_dev_path
mkdir $image_linux_dev_path
# Create dir structure.
find . -type d | xargs -i mkdir -p $image_linux_dev_path/{}
# Adapted from https://www.kernel.org/doc/Documentation/gcov.txt
# But you need .o files too...? so the docs are wrong? TODO: Investigate...
find -name '*.gcno' -o -name '*.[choS]' -o -type l | \
xargs -i cp -a {} $image_linux_dev_path/{}
# Executing this outside of the chroot probably means uids need to be
# synced. TODO: Fix.
give_back $image_linux_dev_path
fi
pop
say_done