kernels: Add script to convert Fedora kernels

We only convert kernels from Fedora 2* as they have 4.x kernels.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-04-30 11:32:04 +01:00
parent 4defc9f134
commit 83201bacbe
2 changed files with 59 additions and 3 deletions

View File

@ -14,9 +14,10 @@ RUN for url in ${RPM_URLS}; do \
RUN for d in lib/modules/*; do depmod -b . $(basename $d); done
RUN mkdir /out
RUN cp -a boot/vmlinuz-* /out/kernel
RUN cp -a boot/config-* /out/kernel_config
RUN cp -a boot/System.map-* /out/System.map
# With some fedora rpms, the kernel and system map are in modules directory
RUN cp -a boot/vmlinuz-* /out/kernel || mv lib/modules/*/vmlinuz /out/kernel
RUN cp -a boot/config-* /out/kernel_config || mv lib/modules/*/config /out/kernel_config
RUN cp -a boot/System.map-* /out/System.map || mv lib/modules/*/System.map /out/System.map
RUN tar cf /out/kernel.tar lib
RUN tar cf /out/kernel-dev.tar usr || true

55
scripts/kernels/fedora.sh Executable file
View File

@ -0,0 +1,55 @@
#! /bin/sh
REPO="linuxkit/kernel-fedora"
BASE_URL=http://mirrors.kernel.org/fedora/
TAGS=$(curl --silent -f -lSL https://registry.hub.docker.com/v1/repositories/${REPO}/tags)
LINKS=$(curl -s ${BASE_URL}/releases/ | sed -n 's/.*href="\([^"]*\).*/\1/p')
# Just get releases 20+
RELEASES=$(echo $LINKS | grep -o "2[0-9]")
ARCH=x86_64
URLS=""
for RELEASE in $RELEASES; do
URLS="$URLS ${BASE_URL}/releases/${RELEASE}/Everything/${ARCH}/os/Packages/k/"
URLS="$URLS ${BASE_URL}/updates/${RELEASE}/${ARCH}/k/"
done
for URL in $URLS; do
PACKAGES=$(curl -s ${URL}/ | sed -n 's/.*href="\([^"]*\).*/\1/p')
KERNEL_RPMS=$(echo $PACKAGES | \
grep -o "kernel-[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9]\+\.[^ ]\+\.rpm")
for KERNEL_RPM in $KERNEL_RPMS; do
RPM_URLS="${URL}/${KERNEL_RPM}"
VERSION=$(echo $KERNEL_RPM | \
grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+-[0-9\.]\+\.fc[0-9]\+")
if echo $TAGS | grep -q "\"${VERSION}\""; then
echo "${REPO}:${VERSION} exists"
continue
fi
CORE_RPM="kernel-core-${VERSION}.${ARCH}.rpm"
RPM_URLS="${RPM_URLS} ${URL}/${CORE_RPM}"
MOD_RPM="kernel-modules-${VERSION}.${ARCH}.rpm"
RPM_URLS="${RPM_URLS} ${URL}/${MOD_RPM}"
MOD_EXTRA_RPM="kernel-modules-extra-${VERSION}.${ARCH}.rpm"
RPM_URLS="${RPM_URLS} ${URL}/${MOD_EXTRA_RPM}"
# Don't pull in the headers. This is mostly for testing
# HEADERS_RPM="kernel-headers-${VERSION}.x86_64.rpm"
# RPM_URLS="${RPM_URLS} ${URL}/${HEADERS_RPM}"
docker build -t ${REPO}:${VERSION} -f Dockerfile.rpm --no-cache \
--build-arg RPM_URLS="${RPM_URLS}" . &&
DOCKER_CONTENT_TRUST=1 docker push ${REPO}:${VERSION}
docker rmi ${REPO}:${VERSION}
docker system prune -f
done
done