diff --git a/images/generated-images/Dockerfile b/images/generated-images/Dockerfile index f351a20..8aaada8 100644 --- a/images/generated-images/Dockerfile +++ b/images/generated-images/Dockerfile @@ -1,20 +1,29 @@ +FROM mainline-src as mainline-src FROM ubuntu:bionic ARG DEBIAN_FRONTEND=noninteractive WORKDIR /home/ubuntu +COPY /*.deb /home/ubuntu/ +COPY /version /home/ubuntu/ +COPY --from=mainline-src /mainline-src/ /home/ubuntu/mainline-src/ + RUN apt-get update && apt-get install -y \ + bc \ + bison \ build-essential \ clang \ curl \ dbus \ + flex \ git \ iproute2 \ iputils-ping \ kmod \ libcap-dev \ libelf-dev \ + libssl-dev \ llvm \ net-tools \ openssh-server \ @@ -24,20 +33,29 @@ RUN apt-get update && apt-get install -y \ systemd \ udev \ wget && \ + apt-get install -y '^gcc-[0-9]*$' && \ curl -LO https://cmake.org/files/v3.19/cmake-3.19.8-Linux-$(uname -m).tar.gz && \ tar -xaf cmake-3.19.8-Linux-$(uname -m).tar.gz && \ rm -vf cmake-3.19.8-Linux-$(uname -m).tar.gz && \ mv cmake-3.19.8-Linux-$(uname -m) /opt/cmake-3.19.8 && \ - ln -sf /opt/cmake-3.19.8/bin/* /usr/bin/ - -COPY /* /home/ubuntu/ - -RUN apt install -y --fix-broken ./*.deb || exit 1 && \ + ln -sf /opt/cmake-3.19.8/bin/* /usr/bin/ && \ + apt install -y --fix-broken ./*.deb || exit 1 && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ - rm -v ./*.deb && \ + rm -v ./*.deb Dockerfile* && \ find /lib/modules -name '*.ko' -delete ; \ + cd mainline-src && \ + git config --global user.name "user" && \ + git config --global user.email "user@example.com" && \ + git checkout cod/mainline/$(cat /home/ubuntu/version) && \ + cp /lib/modules/$(ls /lib/modules/ | head -1)/build/.config . && \ + make prepare0 && \ + rm -rf /lib/modules/$(ls /lib/modules/ | head -1)/build/scripts && \ + cp -rf scripts /lib/modules/$(ls /lib/modules/ | head -1)/build/ && \ + cd .. && \ + rm -rf mainline-src && \ echo "" > /etc/machine-id && echo "" > /var/lib/dbus/machine-id && \ + sed -ie '/^ConditionVirtualization.*/d' /lib/systemd/system/systemd-timesyncd.service ; \ sed -i -e 's/^AcceptEnv LANG LC_\*$/#AcceptEnv LANG LC_*/' /etc/ssh/sshd_config && \ echo 'UseDNS no' >> /etc/ssh/sshd_config && \ echo "root:root" | chpasswd diff --git a/images/generated-images/Dockerfile.source b/images/generated-images/Dockerfile.source new file mode 100644 index 0000000..74f70ab --- /dev/null +++ b/images/generated-images/Dockerfile.source @@ -0,0 +1,3 @@ +FROM scratch + +COPY /mainline-src/ /mainline-src/ diff --git a/images/generated-images/mainline.sh b/images/generated-images/mainline.sh index e935d00..fb1a6ec 100755 --- a/images/generated-images/mainline.sh +++ b/images/generated-images/mainline.sh @@ -40,3 +40,16 @@ cd ../../.. cp Makefile generated/ ls generated/$CANONARCH/mainline | xargs -I@ cp Dockerfile Dockerfile.kernel generated/$CANONARCH/mainline/@ + +# ubuntu mainline packages provide wrong scripts to build drivers: we need to add the source code +# to recompile those scripts and be able to compile kernel modules. +if [[ -d generated/aarch64 ]] ; then + [[ ! -d mainline-src ]] && \ + git clone git://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack mainline-src + find Dockerfile generated/aarch64 -name Dockerfile | sed 's/Dockerfile//g' | sed '/^$/d' | \ + while read DIR; do + VERSION=$(echo $DIR | rev | cut -d/ -f2 | rev) + echo $VERSION > ${DIR}/version + done + docker build -t mainline-src -f Dockerfile.source . +fi