Update moby tool and qemu fixes

- no longer uses several of the `mkimage-*` tools in favour of dogfooding
with `linuxkit` and using the `mkimage` package.
- fix the qemu docker container fallbacks to work better when multiple
paths are used for disks and the image.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack
2017-06-02 16:41:36 +01:00
parent 62cb96dec1
commit e782a469d5
14 changed files with 60 additions and 286 deletions

View File

@@ -1,5 +0,0 @@
FROM linuxkit/guestfs:2657580764d5791e103647237dac5a0276533e2e@sha256:8f99eba6720df17bce8893052d7ca9a07cdc9cd09b335a5a9c57ebd5a44934be
COPY . .
ENTRYPOINT [ "/make-gcp" ]

View File

@@ -1,27 +0,0 @@
.PHONY: tag push
IMAGE=mkimage-gcp
default: push
hash: Dockerfile make-gcp
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --entrypoint sh --rm $(IMAGE):build -c "(cat $^; apt list --installed 2>/dev/null) | sha1sum" | sed 's/ .*//' > hash
push: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \
docker push linuxkit/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -f hash
.DELETE_ON_ERROR:

View File

@@ -1,55 +0,0 @@
#!/bin/sh
set -e
mkdir -p /tmp/image
cd /tmp/image
# input is a tarball of kernel and initrd.img on stdin
# output is a compressed tarball of a raw disk image on stdout
mkdir -p files
cd files
# extract. As guestfs base is currently Debian, no compression support
# only if stdin is a tty, if so need files volume mounted...
[ -t 0 ] || tar xf -
INITRD="$(find . -name '*.img')"
KERNEL="$(find . -name kernel -or -name bzImage)"
CMDLINE="$*"
[ "$KERNEL" = "./kernel" ] || mv "$KERNEL" kernel
[ "$INITRD" = "./initrd.img" ] || mv "$INITRD" initrd.img
# clean up subdirectories
find . -mindepth 1 -maxdepth 1 -type d | xargs rm -rf
# should be externally provided as GCP specific
GCP_CONFIG="earlyprintk=ttyS0,115200 console=ttyS0,115200 vsyscall=emulate page_poison=1"
CFG="DEFAULT linux
LABEL linux
KERNEL /kernel
INITRD /initrd.img
APPEND ${CMDLINE}
"
printf "$CFG" > syslinux.cfg
cd ..
tar cf files.tar -C files .
virt-make-fs --size=1G --type=ext4 --partition files.tar disk.raw
guestfish -a disk.raw -m /dev/sda1 <<EOF
upload /usr/lib/SYSLINUX/mbr.bin /mbr.bin
copy-file-to-device /mbr.bin /dev/sda size:440
rm /mbr.bin
extlinux /
part-set-bootable /dev/sda 1 true
EOF
tar cf - disk.raw | gzip -9

View File

@@ -1,5 +0,0 @@
FROM linuxkit/guestfs:2657580764d5791e103647237dac5a0276533e2e@sha256:8f99eba6720df17bce8893052d7ca9a07cdc9cd09b335a5a9c57ebd5a44934be
COPY . .
ENTRYPOINT [ "/make-img-gz" ]

View File

@@ -1,27 +0,0 @@
.PHONY: tag push
IMAGE=mkimage-img-gz
default: push
hash: Dockerfile make-img-gz
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --entrypoint sh --rm $(IMAGE):build -c "(cat $^; apt list --installed 2>/dev/null) | sha1sum" | sed 's/ .*//' > hash
push: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \
docker push linuxkit/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -f hash
.DELETE_ON_ERROR:

View File

@@ -1,56 +0,0 @@
#!/bin/sh
set -e
SIZE="$1"
[ -z "$SIZE" ] && SIZE=1G
mkdir -p /tmp/image
cd /tmp/image
# input is a tarball of kernel and initrd.img on stdin
# output is a compressed raw disk image on stdout
mkdir -p files
cd files
# extract. As guestfs base is currently Debian, no compression support
# only if stdin is a tty, if so need files volume mounted...
[ -t 0 ] || tar xf -
INITRD="$(find . -name '*.img')"
KERNEL="$(find . -name kernel -or -name bzImage)"
CMDLINE_FILE="$(find . -name cmdline)"
CMDLINE="$(cat $CMDLINE_FILE)"
[ "$KERNEL" = "./kernel" ] || mv "$KERNEL" kernel
[ "$INITRD" = "./initrd.img" ] || mv "$INITRD" initrd.img
# clean up subdirectories
find . -mindepth 1 -maxdepth 1 -type d | xargs rm -rf
CFG="DEFAULT linux
LABEL linux
KERNEL /kernel
INITRD /initrd.img
APPEND ${CMDLINE}
"
printf "$CFG" > syslinux.cfg
cd ..
tar cf files.tar -C files .
virt-make-fs --size=${SIZE} --type=ext4 --partition files.tar disk.raw
guestfish -a disk.raw -m /dev/sda1 <<EOF
upload /usr/lib/SYSLINUX/mbr.bin /mbr.bin
copy-file-to-device /mbr.bin /dev/sda size:440
rm /mbr.bin
extlinux /
part-set-bootable /dev/sda 1 true
EOF
cat disk.raw | gzip -9

View File

@@ -1,5 +0,0 @@
FROM linuxkit/guestfs:2657580764d5791e103647237dac5a0276533e2e@sha256:8f99eba6720df17bce8893052d7ca9a07cdc9cd09b335a5a9c57ebd5a44934be
COPY . .
ENTRYPOINT [ "/make-qcow" ]

View File

@@ -1,27 +0,0 @@
.PHONY: tag push
IMAGE=mkimage-qcow
default: push
hash: Dockerfile make-qcow
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --entrypoint sh --rm $(IMAGE):build -c "(cat $^; apt list --installed 2>/dev/null) | sha1sum" | sed 's/ .*//' > hash
push: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash) && \
docker push linuxkit/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash
docker pull linuxkit/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build linuxkit/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -f hash
.DELETE_ON_ERROR:

View File

@@ -1,55 +0,0 @@
#!/bin/sh
set -e
mkdir -p /tmp/image
cd /tmp/image
# input is a tarball of kernel and initrd.img on stdin
# output is a qcow2 on stdout
mkdir -p files
cd files
# extract. As guestfs base is currently Debian, no compression support
# only if stdin is a tty, if so need files volume mounted...
[ -t 0 ] || tar xf -
INITRD="$(find . -name '*.img')"
KERNEL="$(find . -name kernel -or -name '*bzImage')"
CMDLINE="$*"
[ "$KERNEL" = "./kernel" ] || mv "$KERNEL" kernel
[ "$INITRD" = "./initrd.img" ] || mv "$INITRD" initrd.img
# clean up subdirectories
find . -mindepth 1 -maxdepth 1 -type d | xargs rm -rf
CFG="DEFAULT linux
LABEL linux
KERNEL /kernel
INITRD /initrd.img
APPEND ${CMDLINE}
"
printf "$CFG" > syslinux.cfg
cd ..
tar cf files.tar -C files .
virt-make-fs --size=1G --type=ext4 --partition files.tar --format=qcow2 disk.qcow
guestfish -a disk.qcow -m /dev/sda1 <<EOF
upload /usr/lib/SYSLINUX/mbr.bin /mbr.bin
copy-file-to-device /mbr.bin /dev/sda size:440
rm /mbr.bin
extlinux /
part-set-bootable /dev/sda 1 true
EOF
# compress qcow
qemu-img convert -f qcow2 -O qcow2 -c disk.qcow disk.qcow2 1>&2
cat disk.qcow2