From 82c7118de9e56f908cdd0f1974de2d8ff80d64ec Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Mon, 24 Apr 2017 14:50:12 +0100 Subject: [PATCH 1/3] 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 --- scripts/kernels/Dockerfile.deb | 24 +++++++++++++++++ scripts/kernels/mainline.sh | 49 ++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 scripts/kernels/Dockerfile.deb create mode 100755 scripts/kernels/mainline.sh diff --git a/scripts/kernels/Dockerfile.deb b/scripts/kernels/Dockerfile.deb new file mode 100644 index 000000000..e5ba75a67 --- /dev/null +++ b/scripts/kernels/Dockerfile.deb @@ -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/* / diff --git a/scripts/kernels/mainline.sh b/scripts/kernels/mainline.sh new file mode 100755 index 000000000..d93d9d55a --- /dev/null +++ b/scripts/kernels/mainline.sh @@ -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 From 5b28cfafb245fb1e012a6bda91968d4b33297889 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Fri, 28 Apr 2017 15:28:38 +0100 Subject: [PATCH 2/3] kernels: Add support for creating ubuntu kernel packages This only covers the 4.x Ubuntu kernels and for now does not include the headers to build modules against. Signed-off-by: Rolf Neugebauer --- scripts/kernels/ubuntu.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 scripts/kernels/ubuntu.sh diff --git a/scripts/kernels/ubuntu.sh b/scripts/kernels/ubuntu.sh new file mode 100755 index 000000000..2609af237 --- /dev/null +++ b/scripts/kernels/ubuntu.sh @@ -0,0 +1,34 @@ +#! /bin/sh + +REPO="linuxkit/kernel-ubuntu" +BASE_URL=http://mirrors.kernel.org/ubuntu/pool/main/l/linux/ + +ARCH=amd64 +LINKS=$(curl -s ${BASE_URL}/ | sed -n 's/.*href="\([^"]*\).*/\1/p') +# Just get names for 4.x kernels +KERNELS=$(echo $LINKS | \ + grep -o "linux-image-4\.[0-9]\+\.[0-9]\+-[0-9]\+-generic_[^ ]\+${ARCH}\.deb") + +for KERN_DEB in $KERNELS; do + VERSION=$(echo $KERN_DEB | \ + grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+" | head -1) + + echo "$VERSION -> $KERN_DEB" + DOCKER_CONTENT_TRUST=1 docker pull ${REPO}:${VERSION} && continue + + EXTRA_DEB=$(echo $LINKS | \ + grep -o "linux-image-extra-${VERSION}-generic_[^ ]\+${ARCH}\.deb") + + # Don't pull in the headers. This is mostly for testing + # HDR_DEB=$(echo $LINKS | \ + # grep -o "linux-headers-${VERSION}_[^ ]\+_all\.deb") + # HDR_ARCH_DEB=$(echo $LINKS | \ + # grep -o "linux-headers-${VERSION}-generic_[^ ]\+_${ARCH}\.deb") + + URLS="${BASE_URL}/${KERN_DEB} ${BASE_URL}/${EXTRA_DEB} ${BASE_URL}/${HDR_DEB} ${BASE_URL}/${HDR_ARCH_DEB}" + + # Doesn't exist build and push + docker build -t ${REPO}:${VERSION} -f Dockerfile.deb --no-cache \ + --build-arg DEB_URLS="${URLS}" . && + DOCKER_CONTENT_TRUST=1 docker push ${REPO}:${VERSION}) +done From 4f5c5aca7a94c75dde24f3fef34eb7ee41243ddf Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Fri, 28 Apr 2017 16:50:27 +0100 Subject: [PATCH 3/3] kernels: Add support for creating Debian kernel packages This only pulls in 4.x kernels and does not include the headers to build modules against. Signed-off-by: Rolf Neugebauer --- scripts/kernels/debian.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 scripts/kernels/debian.sh diff --git a/scripts/kernels/debian.sh b/scripts/kernels/debian.sh new file mode 100755 index 000000000..2b2501490 --- /dev/null +++ b/scripts/kernels/debian.sh @@ -0,0 +1,25 @@ +#! /bin/sh + +REPO="linuxkit/kernel-debian" +BASE_URL=http://mirrors.kernel.org/debian/pool/main/l/linux/ + +ARCH=amd64 +LINKS=$(curl -s ${BASE_URL}/ | sed -n 's/.*href="\([^"]*\).*/\1/p') +# Just get names for 4.x kernels +KERNELS=$(echo $LINKS | \ + grep -o "linux-image-4\.[0-9]\+\.[0-9]\+-[0-9]\+-${ARCH}[^ ]\+_${ARCH}\.deb") + +for KERN_DEB in $KERNELS; do + VERSION=$(echo $KERN_DEB | \ + grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+" | head -1) + + echo "$VERSION -> $KERN_DEB" + DOCKER_CONTENT_TRUST=1 docker pull ${REPO}:${VERSION} && continue + + URLS="${BASE_URL}/${KERN_DEB}" + + # Doesn't exist build and push + docker build -t ${REPO}:${VERSION} -f Dockerfile.deb --no-cache \ + --build-arg DEB_URLS="${URLS}" . && + DOCKER_CONTENT_TRUST=1 docker push ${REPO}:${VERSION}) +done