-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.dev
executable file
·179 lines (164 loc) · 5.96 KB
/
Dockerfile.dev
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive \
BPFTOOL_VERSION=7.4.0 \
CJON_VERSION=1.7.18 \
ELFUTILS_VERSION=0.191 \
KERNEL_VERSION=6.9.6 \
LIBNL_VERSION=3.9.0 \
LIBMNL_VERSION=1.0.5 \
LIBBPF_VERSION=1.3.0 \
LVGL_VERSION=9.0 \
ZLIB_VERSION=1.3.1 \
PREFIX_DIR=/usr/glibc-compat
# Install.
RUN \
sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
apt-get -y update && \
apt-get -y upgrade && \
apt-get -qy install \
automake \
autoconf \
bc \
bison \
build-essential \
busybox-static \
clang \
cmake \
cpio \
flex \
git \
gawk \
gettext \
grub2 \
grub-common \
llvm \
openssl \
pkg-config \
python3 \
texinfo \
rsync \
unzip \
wget \
xorriso \
xz-utils && \
rm -rf /var/lib/apt/lists/*
RUN mkdir /build
# Kernel dependencies
# - zlib
RUN cd /build && \
wget -qO- "https://www.zlib.net/zlib-${ZLIB_VERSION}.tar.xz" | tar Jxf - && \
cd "zlib-${ZLIB_VERSION}" && \
./configure && \
make install -j $(nproc) --silent && \
ldconfig
# - libelf
RUN cd /build && \
wget -qO- "https://sourceware.org/elfutils/ftp/${ELFUTILS_VERSION}/elfutils-${ELFUTILS_VERSION}.tar.bz2" | tar jxf - && \
cd "elfutils-${ELFUTILS_VERSION}" && \
./configure --disable-libdebuginfod --disable-debuginfod && \
make install -j $(nproc) --silent && \
cp /usr/local/lib/libelf* /lib/x86_64-linux-gnu/ && \
ldconfig
# Kernel
RUN cd /build && \
wget -qO- "https://mirrors.edge.kernel.org/pub/linux/kernel/v${KERNEL_VERSION%%.*}.x/linux-${KERNEL_VERSION}.tar.xz" | tar Jxf -
ADD .config.dev /build/linux-${KERNEL_VERSION}/.config
RUN cd "/build/linux-${KERNEL_VERSION}" && \
ARCH=x86_64 make -j $(nproc) --silent && \
ARCH=x86_64 make headers_install -j $(nproc) --silent && \
cp "/build/linux-${KERNEL_VERSION}/arch/x86/boot/bzImage" /build/bzImage
# LVGL app dependencies
# - libbpf
RUN cd /build && \
wget -qO- "https://github.com/libbpf/libbpf/archive/refs/tags/v${LIBBPF_VERSION}.tar.gz" | tar zxf - && \
cd "libbpf-${LIBBPF_VERSION}/src" && \
LIBDIR=/lib/x86_64-linux-gnu make install -j $(nproc) --silent && \
ldconfig
# - bpftool
RUN cd /build && \
wget -q "https://github.com/libbpf/bpftool/archive/refs/tags/v${BPFTOOL_VERSION}.zip" && \
unzip "v${BPFTOOL_VERSION}.zip" && \
cd "bpftool-${BPFTOOL_VERSION}" && \
rmdir libbpf && \
ln -s "/build/libbpf-${LIBBPF_VERSION}" libbpf && \
cd src && \
EXTRA_CFLAGS=--static make -j $(nproc) --silent
# - libnl-3
RUN cd /build && \
wget -qO- "https://github.com/thom311/libnl/releases/download/libnl$(echo ${LIBNL_VERSION}|tr '.' '_')/libnl-${LIBNL_VERSION}.tar.gz" | tar zxf - && \
cd "libnl-${LIBNL_VERSION}" && \
./configure --enable-static && \
make install -j $(nproc) --silent && \
ldconfig
# - libmnl
RUN cd /build && \
wget -qO- "https://www.netfilter.org/pub/libmnl/libmnl-${LIBMNL_VERSION}.tar.bz2" | tar jxf - && \
cd "libmnl-${LIBMNL_VERSION}" && \
./configure --enable-static && \
make install -j $(nproc) --silent && \
ldconfig
# - libcjson
RUN cd /build && \
wget -q "https://github.com/DaveGamble/cJSON/archive/refs/tags/v${CJON_VERSION}.zip" && \
unzip "v${CJON_VERSION}.zip" && \
cd "cJSON-${CJON_VERSION}" && \
mkdir build && \
cd build && \
cmake .. -DBUILD_SHARED_AND_STATIC_LIBS=On && \
make install -j $(nproc) --silent && \
ldconfig
# - ethtool
RUN cd /build/ && \
git clone --recursive https://git.launchpad.net/ubuntu/+source/ethtool && \
cd ethtool && \
git switch "ubuntu/noble" && \
./autogen.sh && \
./configure --disable-pretty-dump && \
make -j $(nproc) CFLAGS="-O2 -static" --silent
# LVGL app
RUN cd /build && \
git clone --recursive https://github.com/lvgl/lv_port_linux_frame_buffer && \
cd lv_port_linux_frame_buffer && \
git switch "release/v${LVGL_VERSION}"
ADD CMakeLists.dev.txt /build/lv_port_linux_frame_buffer/CMakeLists.txt
ADD custom.cmake /build/lv_port_linux_frame_buffer/lvgl/env_support/cmake/custom.cmake
ADD app /build/lv_port_linux_frame_buffer
RUN cd /build/lv_port_linux_frame_buffer && \
cmake . && \
sed -i 's|// #define VX_DEV|#define VX_DEV|g' vx_config.h && \
make -j $(nproc) --silent
# XDP kernel program
ADD xdp/xdp_redirect.c /build/
RUN cd /build/ && \
clang -g -c -O2 -target bpf -I/usr/include/x86_64-linux-gnu/ -c xdp_redirect.c -o xdp_redirect.o
# Building initramfs
ADD vxspan.json /build/vxspan.json
RUN cd /build && \
mkdir initramfs && \
cd initramfs && \
mkdir -p dev proc sys bin
ADD etc /build/initramfs/etc
RUN cd /build/initramfs && \
ln -s /bin/busybox init && \
chmod +x etc/init.d/rcS && \
cp /build/lv_port_linux_frame_buffer/bin/main /build/ethtool/ethtool /build/bpftool-${BPFTOOL_VERSION}/src/bpftool bin/ && \
chmod +x bin/main bin/ethtool bin/bpftool && \
cp /usr/bin/busybox bin/busybox && \
for cmd in arp ash awk base64 bc brctl cat chgrp chmod chown chvt clear cmp cp date dd df diff dmesg du echo env false findgrep groups halt head hexdump hostname hwclock id ifconfig ifdown ifup init ip kill killallless less ln loadkmap ls lsscsi mdev mkdirmore mount mv nc netstat nproc ping poweroff printf ps pwd rebootrm rmdir route sed sh sleep sort stat static-sh strings stty suswapoff swapon sysctl tail tar tee telnet test time top touch tr traceroute traceroute6 true truncate tty umount uname uniq unlink uptime usleep vconfig vi watch wc wget which who whoami xargs xxd; do \
ln -s /bin/busybox bin/$cmd;\
done && \
cp /build/xdp_redirect.o . && \
cp /build/vxspan.json . && \
find . -print0 | cpio --null -o --format=newc | xz --format=lzma > /build/rootfs.xz
# Building ISO
RUN cd /build && \
mkdir -p /build/iso/boot/grub && \
cp /build/bzImage /build/iso/boot/bzImage && \
cp /build/rootfs.xz /build/iso/boot/initramfs && \
echo "set default=0\n\
set timeout=0\n\
menuentry 'vxspan' --class os {\n\
linux /boot/bzImage vga=789 tsc=unstable ipv6.disable=1 init=/bin/sh\n\
initrd /boot/initramfs\n\
}" > /build/iso/boot/grub/grub.cfg && \
grub-mkrescue -o vxspan.iso iso/