contrib: Move scripts for foreign kernels to contrib

Also adjust the kernel docs to point to the new location.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
Rolf Neugebauer
2018-01-19 11:32:03 +00:00
parent 79a076d90c
commit f43b62a35b
13 changed files with 2 additions and 2 deletions

View File

@@ -1,27 +0,0 @@
FROM alpine:3.7 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 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
RUN tar cf /out/kernel.tar lib
RUN tar cf /out/kernel-dev.tar usr || true
FROM scratch
WORKDIR /
ENTRYPOINT []
CMD []
COPY --from=extract /out/* /

View File

@@ -1,28 +0,0 @@
FROM alpine:3.7 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 for d in lib/modules/*; do depmod -b . $(basename $d); done
RUN mkdir /out
# 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
FROM scratch
WORKDIR /
ENTRYPOINT []
CMD []
COPY --from=extract /out/* /

View File

@@ -1,31 +0,0 @@
# Using "foreign" kernels
This directory contains a number of scripts to re-package other
distributions kernels into a LinuxKit kernel package. The scripts
download the relevant `rpm`s or `deb`s and create a local docker image
which can be used in LinuxKit. You can optionally push the package to
hub, if you like.
All scripts take slightly different command line arguments (which
could be improved) as each distribution uses different naming
conventions and repository layouts.
## Example
To build a package using the `4.14.11` from the mainline [ppa
repository](http://kernel.ubuntu.com/~kernel-ppa/mainline), first
build the package:
```sh
./mainline.sh foobar/kernel-mainline v4.14.11 041411 201801022143
```
Here `v4.14.11` is the sub-directory of the [ppa
repository](http://kernel.ubuntu.com/~kernel-ppa/mainline), `041411`
seems to be another version used in the name of the `deb`s, and
`201801022143` is the date. You can find the names by browsing the
[ppa repository](http://kernel.ubuntu.com/~kernel-ppa/mainline).
The result is a local image `foobar/kernel-mainline:4.14.11`, which
can be used in a YAML file like a normal LinuxKit kernel image.

View File

@@ -1,25 +0,0 @@
#! /bin/sh
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <org/repo> <base url> <kernel version>"
echo
echo "Example:"
echo "$0 foobar/kernel-centos http://mirror.centos.org/centos/7/os/x86_64/Packages 3.10.0-693.el7"
echo
echo "This will create a local LinuxKit kernel package:"
echo "foobar/kernel-centos:3.10.0-693.el7"
echo "which you can then push to hub or just use locally"
exit 1
fi
REPO=$1
URL=$2
VER=$3
ARCH=x86_64
KERNEL_RPM="$URL/kernel-$VER.$ARCH.rpm"
HEADERS_RPM="$URL/kernel-headers-$VER.$ARCH.rpm"
RPM_URLS="$KERNEL_RPM $HEADERS_RPM"
docker build -t "$REPO:$VER" -f Dockerfile.rpm --no-cache --build-arg RPM_URLS="$RPM_URLS" .

View File

@@ -1,30 +0,0 @@
#! /bin/sh
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <org/repo> <ABI version> <kernel version>"
echo
echo "Example:"
echo "$0 foobar/kernel-debian 4.14.0-2 4.14.7-1"
echo
echo "This will create a local LinuxKit kernel package:"
echo "foobar/kernel-debian:4.14.7-1"
echo "which you can then push to hub or just use locally"
exit 1
fi
# List all available kernels with:
# curl -s http://mirrors.kernel.org/debian/pool/main/l/linux/ | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep -o "linux-image-[0-9]\.[0-9]\+\.[0-9]\+-[0-9]\+-amd64[^ ]\+_amd64\.deb
REPO=$1
VER1=$2
VER2=$3
URL=http://mirrors.kernel.org/debian/pool/main/l/linux
ARCH=amd64
KERNEL_DEB="${URL}/linux-image-${VER1}-${ARCH}_${VER2}_${ARCH}.deb"
HEADERS_DEB="${URL}/linux-headers-${VER1}-${ARCH}_${VER2}_${ARCH}.deb"
HEADERS_ALL_DEB="${URL}/linux-headers-${VER1}-all_${VER2}_${ARCH}.deb"
DEB_URLS="${KERNEL_DEB} ${HEADERS_DEB} ${HEADERS_ALL_DEB}"
docker build -t "${REPO}:${VER2}" -f Dockerfile.deb --no-cache --build-arg DEB_URLS="${DEB_URLS}" .

View File

@@ -1,28 +0,0 @@
#! /bin/sh
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <org/repo> <base url> <kernel version>"
echo
echo "Example:"
echo "$0 foobar/kernel-fedora http://mirrors.kernel.org/fedora/releases/27/Everything/x86_64/os/Packages/k/ 4.13.9-300.fc27"
echo
echo "This will create a local LinuxKit kernel package:"
echo "foobar/kernel-fedora:4.13.9-300.fc27"
echo "which you can then push to hub or just use locally"
exit 1
fi
REPO=$1
URL=$2
VER=$3
ARCH=x86_64
KERNEL_RPM="$URL/kernel-$VER.$ARCH.rpm"
CORE_RPM="$URL/kernel-core-$VER.$ARCH.rpm"
MOD_RPM="$URL/kernel-modules-$VER.$ARCH.rpm"
MOD_EXTRA_RPM="$URL/kernel-modules-extra-$VER.$ARCH.rpm"
HEADERS_RPM="$URL/kernel-headers-$VER.$ARCH.rpm"
RPM_URLS="$KERNEL_RPM $CORE_RPM $MOD_RPM $MOD_EXTRA_RPM $HEADERS_RPM"
docker build -t "$REPO:$VER" -f Dockerfile.rpm --no-cache --build-arg RPM_URLS="$RPM_URLS" .

View File

@@ -1,31 +0,0 @@
#! /bin/sh
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <org/repo> <base url> <kernel version> <version> <date>"
echo
echo "Example:"
echo "$0 foobar/kernel-mainline v4.14.11 041411 201801022143"
echo
echo "This will create a local LinuxKit kernel package:"
echo "foobar/kernel-mainline:4.14.11"
echo "which you can then push to hub or just use locally"
exit 1
fi
REPO=$1
VER=$2
VER1=$3
DATE=$4
BASE_URL=http://kernel.ubuntu.com/~kernel-ppa/mainline
ARCH=amd64
# Strip leading 'v'
KVER=${VER:1}
URL="${BASE_URL}/${VER}"
KERNEL_DEB="${URL}/linux-image-${KVER}-${VER1}-generic_${KVER}-${VER1}.${DATE}_${ARCH}.deb"
HEADERS_DEB="${URL}/linux-headers-${KVER}-${VER1}-generic_${KVER}-${VER1}.${DATE}_${ARCH}.deb"
HEADERS_ALL_DEB="${URL}/linux-headers-${KVER}-${VER1}_${KVER}-${VER1}.${DATE}_all.deb"
DEB_URLS="${KERNEL_DEB} ${HEADERS_DEB} ${HEADERS_ALL_DEB}"
docker build -t "${REPO}:${KVER}" -f Dockerfile.deb --no-cache --build-arg DEB_URLS="${DEB_URLS}" .

View File

@@ -1,31 +0,0 @@
#! /bin/sh
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <org/repo> <kernel version> <sub version>"
echo
echo "Example:"
echo "$0 foobar/kernel-ubuntu 4.14.0-13 15"
echo
echo "This will create a local LinuxKit kernel package:"
echo "foobar/kernel-ubuntu:4.14.0-13.15"
echo "which you can then push to hub or just use locally"
exit 1
fi
# List all available kernels with:
# curl -s http://mirrors.kernel.org/ubuntu/pool/main/l/linux/ | sed -n 's/.*href="\([^"]*\).*/\1/p' | grep -o "linux-image-[0-9]\.[0-9]\+\.[0-9]\+-[0-9]\+-generic_[^ ]\+amd64\.deb"
REPO=$1
VER1=$2
VER2=$3
URL=http://mirrors.kernel.org/ubuntu/pool/main/l/linux
ARCH=amd64
KERNEL_DEB="${URL}/linux-image-${VER1}-generic_${VER1}.${VER2}_${ARCH}.deb"
KERNEL_EXTRA_DEB="${URL}/linux-image-extra-${VER1}-generic_${VER1}.${VER2}_${ARCH}.deb"
HEADERS_DEB="${URL}/linux-headers-${VER1}-generic_${VER1}.${VER2}_${ARCH}.deb"
HEADERS_ALL_DEB="${URL}/linux-headers-${VER1}_${VER1}.${VER2}_all.deb"
DEB_URLS="${KERNEL_DEB} ${KERNEL_EXTRA_DEB} ${HEADERS_DEB} ${HEADERS_ALL_DEB}"
docker build -t "${REPO}:${VER1}.${VER2}" -f Dockerfile.deb --no-cache --build-arg DEB_URLS="${DEB_URLS}" .