Clean up GCE image build

In line with the others, support any file names on input.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2017-01-30 22:04:34 +00:00
parent 38b6847669
commit 699560aaad
5 changed files with 37 additions and 18 deletions

View File

@ -28,8 +28,8 @@ TAR2INITRD_IMAGE=mobylinux/tar2initrd@sha256:58d377e65845f91400e173ce9fca93462f2
# Tag: d56cde1558e3080e59a32e3cd7c7141baa601811
TARTAR2INITRD_IMAGE=mobylinux/tartar2initrd@sha256:e1ad4522ff906d339da5f250b9ef6bffa5a70b4dec7d2cf7f7dbd0447b79352f
# Tag: 77bc577875fb3a80ac2d14b70d1daa885bbf199c
GCE_IMAGE=mobylinux/mkimage-gce@sha256:f9abf2eae20984b7dd3c1afb700b2c9c41e39e6e7c688c78348a51d0780d74cc
# Tag: 83158ebe303a970a3131c3d02ef2ba00ca5e4a14
GCE_IMAGE=mobylinux/mkimage-gce@sha256:51c30fbf946ca9967688a411e7bf69769a22987cd47ad03428491dd1556fcf63
moby.img: Dockerfile mkinitrd.sh init $(ETCFILES)
$(MAKE) -j -C packages
@ -96,9 +96,8 @@ mobylinux-bios.iso: initrd.img kernel/x86_64/vmlinuz64
gce: gce.img.tar.gz
gce.img.tar.gz: common
tar cf - initrd.img -C kernel/x86_64 vmlinuz64 | \
docker run --rm --net=none --log-driver=none -i $(GCE_IMAGE) >$@
gce.img.tar.gz: initrd.img kernel/x86_64/vmlinuz64
tar cf - $^ | docker run --rm --net=none --log-driver=none -i $(GCE_IMAGE) >$@
gce-upload:
ifeq ($(FORCE_GSUTIL_AUTH),1)

View File

@ -1,10 +1,6 @@
# Tag: 8719f0f33b3cf9d59a62be64a42220978ac96486
FROM mobylinux/guestfs@sha256:c7229f01c1a54270d2bc3597c30121628c18db211ed32fb7202823b6eaa4f853
WORKDIR /tmp/image
COPY . .
COPY make-gce /usr/bin
CMD [ "/usr/bin/make-gce" ]
CMD [ "/make-gce" ]

View File

@ -4,7 +4,7 @@ IMAGE=mkimage-gce
default: push
hash: Dockerfile make-gce syslinux.cfg
hash: Dockerfile make-gce
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --rm $(IMAGE):build sh -c "(cat $^; apt list --installed 2>/dev/null) | sha1sum" | sed 's/ .*//' > hash

View File

@ -2,13 +2,42 @@
set -e
mkdir -p /tmp/image
cd /tmp/image
# input is a tarball of vmlinuz64 and initrd.img on stdin
# output is a compressed tarball of a raw disk image on stdout
mkdir -p files
tar xf - -C files
cp syslinux.cfg 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 vmlinuz64 -or -name bzImage)"
[ "$KERNEL" = "./vmlinuz64" ] || mv "$KERNEL" vmlinuz64
[ "$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 GCE specific
GCE_CONFIG="earlyprintk=ttyS0,115200 console=ttyS0,115200 mobyplatform=gcp vsyscall=emulate"
CFG="DEFAULT linux
LABEL linux
KERNEL /vmlinuz64
INITRD /initrd.img
APPEND $GCE_CONFIG $*
"
printf "$CFG" > syslinux.cfg
cd ..
tar cf files.tar -C files .

View File

@ -1,5 +0,0 @@
DEFAULT linux
LABEL linux
KERNEL /vmlinuz64
INITRD /initrd.img
APPEND earlyprintk=ttyS0,115200 console=ttyS0,115200 mobyplatform=gcp vsyscall=emulate