kernels: Create LinuKit kernel images from Ubuntu mainline

The Ubuntu mainline PPA has kernel.org based kernels for many
kernel releaseis.  This commit adds suport for downloading and
converting the 3.16.x long long term support kernel as well
as the current 4.x series.  The "mainline.sh" script only
downloads/processes kernels which have not yet been put on
Hub.

The kernels are stored under "linuxkit/kernel-mainline" and are
tagged with the kernel version.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-04-24 14:50:12 +01:00
parent ab1ae3f271
commit 82c7118de9
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,24 @@
FROM alpine:3.5 AS extract
ARG DEB_URLS
RUN apk add --no-cache curl dpkg tar && true
WORKDIR /deb
RUN mkdir extract
RUN for url in ${DEB_URLS}; do \
echo "Extracting: $url"; \
curl -fsSL -o dl.deb $url && \
dpkg-deb -x dl.deb . ;\
done
RUN mkdir /out
RUN cp -a boot/vmlinuz-* /out/kernel
RUN cp -a boot/config-* /out/kernel_config
RUN tar cf /out/kernel.tar lib
RUN tar cf /out/kernel-dev.tar usr
FROM linuxkit/toybox-media:d7e82a7d19ccc84c9071fa7a88ecaa58ae958f7c@sha256:4c7d25f2be2429cd08417c36e04161cb924e46f3e419ee33a0aa9ff3a0942e02
WORKDIR /
ENTRYPOINT []
CMD []
COPY --from=extract /out/* /

49
scripts/kernels/mainline.sh Executable file
View File

@ -0,0 +1,49 @@
#! /bin/sh
REPO="linuxkit/kernel-mainline"
BASE_URL=http://kernel.ubuntu.com/~kernel-ppa/mainline
build_image() {
VERSION=$1
KDIR=$2
ARCH=amd64
LINKS=$(curl -s ${BASE_URL}/${KDIR}/ | \
sed -n 's/.*href="\([^"]*\).*/\1/p')
IMAGE=$(echo $LINKS | \
grep -o "linux-image[^ ]\+-generic[^ ]\+${ARCH}.deb" | head -1)
[ -z "${IMAGE}" ] && return 1
HDR_GEN=$(echo $LINKS | grep -o "linux-headers[^ ]\+_all.deb" | head -1)
[ -z "${HDR_GEN}" ] && return 1
HDR_ARCH=$(echo $LINKS | \
grep -o "linux-headers[^ ]\+-generic[^ ]\+${ARCH}.deb" | head -1)
[ -z "${HDR_ARCH}" ] && return 1
DEB_URL=${BASE_URL}/${KDIR}/${IMAGE}
HDR_GEN_URL=${BASE_URL}/${KDIR}/${HDR_GEN}
HDR_ARCH_URL=${BASE_URL}/${KDIR}/${HDR_ARCH}
echo "Trying to fetch ${VERSION} from ${DEB_URL}"
docker build -t ${REPO}:${VERSION} -f Dockerfile.deb --no-cache \
--build-arg DEB_URLS="${DEB_URL} ${HDR_GEN_URL} ${HDR_ARCH_URL}" .
}
LINKS=$(curl -s ${BASE_URL}/ | sed -n 's/.*href="\([^"]*\).*/\1/p')
# Extract all kernel versions (drop RCs, ckt(?) and other links)
VERSIONS=$(echo $LINKS | grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+[^ ]*" | \
grep -ve '-rc' | grep -ve '-ckt' | uniq)
# Extract 3.16.x and 4.x.x
THREES=$(echo $VERSIONS | grep -o "v3\.16\.[0-9]\+[^ ]*")
FOURS=$(echo $VERSIONS | grep -o "v4\.[0-9]\+\.[0-9]\+[^ ]*")
KDIRS="${THREES} ${FOURS}"
for KDIR in $KDIRS; do
# Strip the Ubuntu release name for the tag and also the 'v' like with
# the other kernel packages
VERSION=$(echo $KDIR | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+")
DOCKER_CONTENT_TRUST=1 docker pull ${REPO}:${VERSION} && continue
build_image ${VERSION} ${KDIR} && \
DOCKER_CONTENT_TRUST=1 docker push ${REPO}:${VERSION}
done