Skip to content

Commit

Permalink
Can build linuxkit for 4.14.x (#21)
Browse files Browse the repository at this point in the history
Update linuxkit builder to build in tree based on linuxkit kernel dev best practices
  • Loading branch information
mcred authored Aug 21, 2020
1 parent 6e90c31 commit 9a05eb1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
16 changes: 16 additions & 0 deletions src/linuxkit-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
#
# Copyright The Titan Project Contributors.
#

set -xe

. $(dirname $0)/common.sh

get_zfs_source

cd /src/zfs
sh ./autogen.sh
./configure
make -j8
make install DESTDIR=/build
73 changes: 38 additions & 35 deletions src/linuxkit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,47 @@
#
# Get linuxkit-specific source. With linuxkit, the canonical data source is through
# docker images, so we launch a docker container and then copy out the data we need.
# The linuxkit images have no usable binaries, so we launch with a command that we
# know will fail, and then simply ignore the failure. The container will persist
# in the stopped state so we can copy the necessary data out of it.
# The linuxkit images have no usable binaries, so we launch an alpine container from
# the linuxkit kernel image with the required zfs build dependencies.
#
function get_kernel() {
local container_name=zfs-builder-$(generate_random_string 8)
docker run --name $container_name linuxkit/kernel:$KERNEL_VERSION /ignore || /bin/true
cd /
docker cp $container_name:kernel-dev.tar .
docker cp $container_name:kernel.tar .
bsdtar xf kernel-dev.tar
bsdtar xf kernel.tar
rm kernel-dev.tar kernel.tar

cd /src
docker cp $container_name:linux.tar.xz .
bsdtar xf linux.tar.xz
rm linux.tar.xz
function build() {
local linuxkit_release

#
# Some versions of linuxkit apparently leave the built gcc plugins in the
# kernel tree, which can then generate errors because it's looking for
# symbols or libraries that might not exist on this system. Build works
# fine without them, so blow them away if they happen to be there.
#
rm -f /usr/src/*/scripts/gcc-plugins/*.so
rm -f /usr/src/*/scripts/gcc-plugins/*.o
mkdir /docker
cp /*.sh /docker

cat > /docker/Dockerfile <<EOF
FROM linuxkit/kernel:$KERNEL_VERSION AS ksrc
FROM linuxkit/alpine:e2391e0b164c57db9f6c4ae110ee84f766edc430 AS build
RUN apk update
RUN apk add bash \
attr-dev \
autoconf \
automake \
build-base \
gettext-dev \
git \
gettext-dev \
linux-headers \
libtirpc-dev \
libintl \
libtool \
libressl-dev \
util-linux-dev \
zlib-dev \
zfs-libs
COPY --from=ksrc /kernel-dev.tar /
RUN tar xf kernel-dev.tar
COPY *.sh /
CMD /linuxkit-build.sh
EOF
local image_name=zfs-builder-linuxkit:$(generate_random_string 8)
cd /docker && docker build -t $image_name .
local container_name=zfs-builder-$(generate_random_string 8)
docker run --name $container_name -e KERNEL_RELEASE=$KERNEL_RELEASE \
-e KERNEL_SRC=/src/linux -e KERNEL_OBJ=/lib/modules/$KERNEL_RELEASE/build $image_name
docker cp $container_name:/build /
docker rm $container_name

KERNEL_SRC=/src/linux
KERNEL_OBJ=/lib/modules/$KERNEL_RELEASE/build
}

function build() {
get_zfs_source
if [ "$ZFS_CONFIG" != "user" ]; then
get_kernel
fi
build_zfs
docker rmi $image_name
}

0 comments on commit 9a05eb1

Please sign in to comment.