kernels: Add script to convert CentOS kernels

We only convert CentOS 7 kernels for now. CentOS 6 is too
old for most of our purposes.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer 2017-04-29 13:36:22 +01:00
parent 4ff7be375e
commit eeb8ee058c
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,25 @@
FROM alpine:3.5 AS extract
ARG RPM_URLS
RUN apk add --no-cache curl rpm tar && true
WORKDIR /rpm
RUN mkdir extract
RUN for url in ${RPM_URLS}; do \
echo "Extracting: $url"; \
curl -fsSL -o dl.rpm $url && \
rpm2cpio dl.rpm | cpio -idm ;\
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
RUN tar cf /out/kernel.tar lib
RUN tar cf /out/kernel-dev.tar usr || true
FROM linuxkit/toybox-media:d7e82a7d19ccc84c9071fa7a88ecaa58ae958f7c@sha256:4c7d25f2be2429cd08417c36e04161cb924e46f3e419ee33a0aa9ff3a0942e02
WORKDIR /
ENTRYPOINT []
CMD []
COPY --from=extract /out/* /

44
scripts/kernels/centos.sh Executable file
View File

@ -0,0 +1,44 @@
#! /bin/sh
REPO="linuxkit/kernel-centos"
BASE_URL=http://mirror.centos.org/centos/
TAGS=$(curl --silent -f -lSL https://registry.hub.docker.com/v1/repositories/${REPO}/tags)
LINKS=$(curl -s ${BASE_URL}/ | sed -n 's/.*href="\([^"]*\).*/\1/p')
# Just get names for Centos 7
RELEASES=$(echo $LINKS | grep -o "7\.[^ ]*")
RELEASES="7/ $RELEASES"
# Add updates
URLS=""
for RELEASE in $RELEASES; do
URLS="$URLS ${BASE_URL}/${RELEASE}/os/x86_64/Packages/"
done
URLS="$URLS ${BASE_URL}/7/updates/x86_64/Packages/"
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\.]\+\.el[0-9]\+")
if echo $TAGS | grep -q "\"${VERSION}\""; then
echo "${REPO}:${VERSION} exists"
continue
fi
# 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}
done
done