-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.kernel
85 lines (72 loc) · 3.06 KB
/
Dockerfile.kernel
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
#
# Add cross-build environment scripts
# Dockerfile.kernel: Multi-arch Kernel Build environment
#
FROM ubuntu:18.04
MAINTAINER John Stultz <[email protected]>
ENV TERM xterm
# Update the image to the lastest updates
RUN apt-get update && apt-get -y dist-upgrade && apt-get clean && apt-get -y autoremove
# Get tools
RUN apt-get update && apt-get install -y \
bc \
cpio \
flex \
bison \
clang-format-10 \
gcc \
gcc-arm-linux-gnueabi \
gcc-aarch64-linux-gnu \
git \
libssl-dev \
libncurses5-dev \
libelf-dev \
libyaml-0-2 \
libyaml-dev \
make \
kmod \
pkg-config \
python3 \
python3-pip \
sparse \
zstd
# make username a variable, so the script is portable
# add '--build-arg user_name=$USER' to the docker build command
ARG --description="user name for container" user_name=docker
# Add $user_name user
RUN useradd -m $user_name
USER $user_name
#RUN cd ~/ ; git clone --depth=1 https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9
RUN cd ~/ ; git clone --depth=1 https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86
RUN mkdir /home/$user_name/bin
# Add cross-build environment scripts
RUN echo '#!/bin/bash' > /home/$user_name/bin/clangenv.sh
RUN echo 'export TOOLCHAIN="clang-r349610b"' >> /home/$user_name/bin/clangenv.sh
RUN echo 'export C_COMPILER="clang"' >> /home/$user_name/bin/clangenv.sh
RUN echo 'export PATH=${PWD}/linux-x86/${TOOLCHAIN}/bin/:${PATH}' >> /home/$user_name/bin/clangenv.sh
RUN echo 'export CLANG_TRIPLE=aarch64-linux-gnu-' >> /home/$user_name/bin/clangenv.sh
RUN echo 'export CROSS_COMPILE=aarch64-linux-android-' >> /home/$user_name/bin/clangenv.sh
RUN echo 'export ARCH=arm64' >> /home/$user_name/bin/clangenv.sh
RUN echo 'export CC=clang' >> /home/$user_name/bin/clangenv.sh
RUN echo 'export HOSTCC=clang' >> /home/$user_name/bin/clangenv.sh
RUN echo '#!/bin/bash' > /home/$user_name/bin/armenv.sh
RUN echo 'export ARCH="arm"' >> /home/$user_name/bin/armenv.sh
RUN echo 'export CROSS_COMPILE="arm-linux-gnueabi-"' >> /home/$user_name/bin/armenv.sh
RUN echo '#!/bin/bash' > /home/$user_name/bin/arm64env.sh
RUN echo 'export ARCH="arm64"' >> /home/$user_name/bin/arm64env.sh
RUN echo 'export CROSS_COMPILE="aarch64-linux-gnu-"' >> /home/$user_name/bin/arm64env.sh
RUN echo '#!/bin/bash' > /home/$user_name/bin/x86env.sh
# create run-script
run echo '#!/bin/bash' > /home/$user_name/run-script.sh
run echo "export PATH=$PATH:~/.local/bin/" >> /home/$user_name/run-script.sh
run echo 'if [ -z $TARGET ]; then echo "No TARGET value"; exit; fi' >> /home/$user_name/run-script.sh
run echo 'if [[ -z "${COMMAND}" ]]; then echo "No COMMAND value"; exit; fi' >> /home/$user_name/run-script.sh
run echo '. ~/bin/${TARGET}env.sh' >> /home/$user_name/run-script.sh
run echo 'cd kernel' >> /home/$user_name/run-script.sh
run echo 'eval ${COMMAND}' >> /home/$user_name/run-script.sh
run chmod +x /home/$user_name/run-script.sh
WORKDIR /home/$user_name
USER $user_name
run pip3 install --user --upgrade dtschema
#RUN pip install --user git+https://github.com/devicetree-org/dt-schema.git@master
CMD ./run-script.sh