diff --git a/scripts/kernels/debian.sh b/scripts/kernels/debian.sh index ca0a5adc5..c3dcde3bb 100755 --- a/scripts/kernels/debian.sh +++ b/scripts/kernels/debian.sh @@ -3,6 +3,8 @@ REPO="linuxkit/kernel-debian" BASE_URL=http://mirrors.kernel.org/debian/pool/main/l/linux/ +TAGS=$(curl --silent -f -lSL https://registry.hub.docker.com/v1/repositories/${REPO}/tags) + ARCH=amd64 LINKS=$(curl -s ${BASE_URL}/ | sed -n 's/.*href="\([^"]*\).*/\1/p') # Just get names for 4.x kernels @@ -13,8 +15,10 @@ 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 + if echo $TAGS | grep -q "\"${VERSION}\""; then + echo "${REPO}:${VERSION} exists" + continue + fi URLS="${BASE_URL}/${KERN_DEB}" diff --git a/scripts/kernels/mainline.sh b/scripts/kernels/mainline.sh index d93d9d55a..a3a916fe6 100755 --- a/scripts/kernels/mainline.sh +++ b/scripts/kernels/mainline.sh @@ -3,6 +3,8 @@ REPO="linuxkit/kernel-mainline" BASE_URL=http://kernel.ubuntu.com/~kernel-ppa/mainline +TAGS=$(curl --silent -f -lSL https://registry.hub.docker.com/v1/repositories/${REPO}/tags) + build_image() { VERSION=$1 KDIR=$2 @@ -43,7 +45,10 @@ 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 + 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} done diff --git a/scripts/kernels/ubuntu.sh b/scripts/kernels/ubuntu.sh index ea285cd47..47de1ae18 100755 --- a/scripts/kernels/ubuntu.sh +++ b/scripts/kernels/ubuntu.sh @@ -3,6 +3,8 @@ REPO="linuxkit/kernel-ubuntu" BASE_URL=http://mirrors.kernel.org/ubuntu/pool/main/l/linux/ +TAGS=$(curl --silent -f -lSL https://registry.hub.docker.com/v1/repositories/${REPO}/tags) + ARCH=amd64 LINKS=$(curl -s ${BASE_URL}/ | sed -n 's/.*href="\([^"]*\).*/\1/p') # Just get names for 4.x kernels @@ -13,8 +15,10 @@ 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 + if echo $TAGS | grep -q "\"${VERSION}\""; then + echo "${REPO}:${VERSION} exists" + continue + fi EXTRA_DEB=$(echo $LINKS | \ grep -o "linux-image-extra-${VERSION}-generic_[^ ]\+${ARCH}\.deb") @@ -27,7 +31,6 @@ for KERN_DEB in $KERNELS; do URLS="${BASE_URL}/${KERN_DEB} ${BASE_URL}/${EXTRA_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}