mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-10-14 08:24:45 +00:00
foreign-kernels: Rewrite scripts to only build one local image
The scripts used to scrape the various repositories to build and push package for all foreign kernels. They were designed to be run periodically and provide "official" foreign kernel packages. Needless to say we did not run them periodically and the linuxkit packages became out-dated quickly. Now, we just provide users who are interested in using foreign kernels the means to build their own package from specific vendor kernels. Each script uses slightly different command line arguments as the location and naming of the kernel packages differ wildly. The help message provide a working example which has been tested with a minimal LinuxKit YAML file. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
This commit is contained in:
@@ -1,57 +1,31 @@
|
||||
#! /bin/sh
|
||||
|
||||
REPO="linuxkit/kernel-mainline"
|
||||
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}"
|
||||
|
||||
TAGS=$(curl --silent -f -lSL https://registry.hub.docker.com/v1/repositories/${REPO}/tags)
|
||||
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"
|
||||
|
||||
build_image() {
|
||||
VERSION=$1
|
||||
KDIR=$2
|
||||
ARCH=amd64
|
||||
DEB_URLS="${KERNEL_DEB} ${HEADERS_DEB} ${HEADERS_ALL_DEB}"
|
||||
|
||||
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]\+")
|
||||
if echo $TAGS | grep -q "\"${VERSION}\""; then
|
||||
echo "${REPO}:${VERSION} exists"
|
||||
continue
|
||||
fi
|
||||
build_image ${VERSION} ${KDIR} && \
|
||||
DOCKER_CONTENT_TRUST=1 docker push ${REPO}:${VERSION}
|
||||
|
||||
docker rmi ${REPO}:${VERSION}
|
||||
docker system prune -f
|
||||
done
|
||||
docker build -t "${REPO}:${KVER}" -f Dockerfile.deb --no-cache --build-arg DEB_URLS="${DEB_URLS}" .
|
||||
|
Reference in New Issue
Block a user