@@ -16,8 +16,8 @@ source "$GIT_ROOT_DIR/tools/functions"
16
16
17
17
# Make sure we have all the needed tools
18
18
function install_dependencies {
19
- sudo apt update
20
- sudo apt install -y bc flex bison gcc make libelf-dev libssl-dev squashfs-tools busybox-static tree cpio curl
19
+ apt update
20
+ apt install -y bc flex bison gcc make libelf-dev libssl-dev squashfs-tools busybox-static tree cpio curl patch docker.io
21
21
}
22
22
23
23
function dir2ext4img {
@@ -30,13 +30,21 @@ function dir2ext4img {
30
30
local TMP_MNT=$( mktemp -d)
31
31
truncate -s " $SIZE " " $IMG "
32
32
mkfs.ext4 -F " $IMG "
33
- sudo mount " $IMG " " $TMP_MNT "
34
- sudo tar c -C $DIR . | sudo tar x -C " $TMP_MNT "
33
+ mount " $IMG " " $TMP_MNT "
34
+ tar c -C $DIR . | tar x -C " $TMP_MNT "
35
35
# cleanup
36
- sudo umount " $TMP_MNT "
36
+ # Use the -l flag for lazy unmounting since sometimes umount fails
37
+ # with "device busy" and simply calling `sync` doesn't help
38
+ umount -l " $TMP_MNT "
37
39
rmdir $TMP_MNT
38
40
}
39
41
42
+ function prepare_docker {
43
+ nohup /usr/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 &
44
+
45
+ # Wait for Docker socket to be created
46
+ timeout 15 sh -c " until docker info; do echo .; sleep 1; done"
47
+ }
40
48
41
49
function compile_and_install {
42
50
local C_FILE=$1
@@ -54,6 +62,9 @@ function build_rootfs {
54
62
local rootfs=" tmp_rootfs"
55
63
mkdir -pv " $rootfs "
56
64
65
+ # Launch Docker
66
+ prepare_docker
67
+
57
68
cp -rvf overlay/* $rootfs
58
69
59
70
# curl -O https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64-root.tar.xz
@@ -76,25 +87,29 @@ mkdir -pv $rootfs/var/lib/dpkg/
76
87
EOF
77
88
78
89
# TBD what abt /etc/hosts?
79
- echo | sudo tee $rootfs /etc/resolv.conf
90
+ echo | tee $rootfs /etc/resolv.conf
80
91
81
92
# Generate key for ssh access from host
82
93
if [ ! -s id_rsa ]; then
83
94
ssh-keygen -f id_rsa -N " "
84
95
fi
85
- sudo install -d -m 0600 " $rootfs /root/.ssh/"
86
- sudo cp id_rsa.pub " $rootfs /root/.ssh/authorized_keys"
96
+ install -d -m 0600 " $rootfs /root/.ssh/"
97
+ cp id_rsa.pub " $rootfs /root/.ssh/authorized_keys"
87
98
id_rsa=$OUTPUT_DIR /$ROOTFS_NAME .id_rsa
88
- sudo cp id_rsa $id_rsa
99
+ cp id_rsa $id_rsa
89
100
90
101
# -comp zstd but guest kernel does not support
91
102
rootfs_img=" $OUTPUT_DIR /$ROOTFS_NAME .squashfs"
92
- sudo mv $rootfs /root/manifest $OUTPUT_DIR /$ROOTFS_NAME .manifest
93
- sudo mksquashfs $rootfs $rootfs_img -all-root -noappend
103
+ mv $rootfs /root/manifest $OUTPUT_DIR /$ROOTFS_NAME .manifest
104
+ mksquashfs $rootfs $rootfs_img -all-root -noappend
94
105
rootfs_ext4=$OUTPUT_DIR /$ROOTFS_NAME .ext4
95
106
dir2ext4img $rootfs $rootfs_ext4
96
- sudo rm -rf $rootfs
97
- sudo chown -Rc $USER . $OUTPUT_DIR
107
+ rm -rf $rootfs
108
+ for bin in fast_page_fault_helper fillmem init readmem; do
109
+ rm $PWD /overlay/usr/local/bin/$bin
110
+ done
111
+ rm -f id_rsa{,.pub}
112
+ rm -f nohup.out
98
113
}
99
114
100
115
@@ -241,6 +256,10 @@ function build_al_kernels {
241
256
if [[ " $KERNEL_VERSION " == @ (all| 6.1) ]]; then
242
257
build_al_kernel $PWD /guest_configs/microvm-kernel-ci-$ARCH -6.1.config 5.10
243
258
fi
259
+
260
+ # Undo kernel patches on top of AL configuration
261
+ git restore $PWD /guest_configs
262
+ rm -rf $PWD /guest_configs/* .orig
244
263
}
245
264
246
265
function print_help {
0 commit comments