From 5ab5b324138f959ab4a770fa7192f8688c56e766 Mon Sep 17 00:00:00 2001 From: Justin Cormack Date: Tue, 7 Mar 2017 11:59:30 +0000 Subject: [PATCH] Cleanup after merge - update README - script to start qemu - fixes to hyperkit Signed-off-by: Justin Cormack --- Makefile | 16 +++++++--------- README.md | 17 +++++++---------- scripts/qemu.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 19 deletions(-) create mode 100755 scripts/qemu.sh diff --git a/Makefile b/Makefile index b0c09f4d9..657d3d145 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ .PHONY: default all -default: bin/moby +default: bin/moby moby-initrd.img all: default GO_COMPILE=mobylinux/go-compile:236629d9fc0779db9e7573ceb8b0e92f08f553be@sha256:16020c2d90cecb1f1d2d731187e947535c23f38b62319dd386ae642b4b32e1fb @@ -14,8 +14,6 @@ endif bin/moby: $(MOBY_DEPS) | bin tar cf - $(MOBY_DEPS) | docker run --rm --net=none --log-driver=none -i $(CROSS) $(GO_COMPILE) --package github.com/docker/moby -o $@ | tar xf - -QEMU_IMAGE=mobylinux/qemu:156d2160c2ccf4d5118221bc2708f6c0981d54cc@sha256:e1345ba0400d6c45bf3bdf4f4ed425c3d7596d11e6553b83f17f5893dfc49f7b - moby-initrd.img: bin/moby moby.yaml $^ @@ -28,11 +26,11 @@ test-bzImage: test-initrd.img # interactive versions need to use volume mounts .PHONY: qemu qemu-iso -qemu: moby-initrd.img - docker run -it --rm -v $(CURDIR)/moby-initrd.img:/tmp/initrd.img -v $(CURDIR)/moby-bzImage:/tmp/vmlinuz64 $(QEMU_IMAGE) +qemu: moby-initrd.img moby-bzImage + ./scripts/qemu.sh $^ qemu-iso: alpine/mobylinux-bios.iso - docker run -it --rm -v $(CURDIR)/mobylinux-bios.iso:/tmp/mobylinux-bios.iso $(QEMU_IMAGE) + ./scripts/qemu.sh $^ bin: mkdir -p $@ @@ -58,8 +56,8 @@ else endif .PHONY: hyperkit hyperkit-test -hyperkit: scripts/hyperkit.sh bin/com.docker.hyperkit bin/vpnkit alpine/initrd.img kernel/x86_64/vmlinuz64 - ./scripts/hyperkit.sh +hyperkit: scripts/hyperkit.sh bin/com.docker.hyperkit bin/vpnkit moby-initrd.img moby-bzImage + ./scripts/hyperkit.sh moby define check_test_log @cat $1 |grep -q 'Moby test suite PASSED' @@ -72,7 +70,7 @@ hyperkit-test: scripts/hyperkit.sh bin/com.docker.hyperkit bin/vpnkit test-initr .PHONY: test test: test-initrd.img test-bzImage - tar cf - $^ | docker run --rm -i $(QEMU_IMAGE) 2>&1 | tee test.log + tar cf - $^ | ./scripts/qemu.sh 2>&1 | tee test.log $(call check_test_log, test.log) .PHONY: ebpf diff --git a/README.md b/README.md index 9941e0276..3f996f42a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,11 @@ -Moby, the Linux distro for Docker editions +Moby, a toolkit for custom Linux distributions -Simple build instructions: use `make` to build. `make qemu` will boot up in qemu in a container. +Simple build instructions: use `make` to build. -Requires GNU `make`, GNU `tar` (not Busybox tar), Docker to build. +`make qemu` will boot up a sample in qemu in a container; on OSX `make hyperkit` will +boot up in hyperkit. `make test` or `make hyperkit-test` will run the test suite. -- 1.12.x branch for Desktop stable 1.12 edition -- 1.13.x branch for Desktop and Cloud 1.13; also supports 1.12 CS. -- master for 1.14 development +Requires GNU `make`, GNU or BSD `tar` (not Busybox tar) and Docker to build. -Several kernel variants are supported: -- default -- `make LTS4.4=1` 4.4 LTS series -- `make AUFS=1` supports AUFS (deprecated) +To customise, copy or modify the `moby.yaml` and then run `./bin/moby file.yaml` to +generate. You can run the output with `./scripts/qemu.sh` or `./scripts/hyperkit.sh`. diff --git a/scripts/qemu.sh b/scripts/qemu.sh new file mode 100755 index 000000000..d4d4ed6d4 --- /dev/null +++ b/scripts/qemu.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +QEMU_IMAGE=mobylinux/qemu:156d2160c2ccf4d5118221bc2708f6c0981d54cc@sha256:e1345ba0400d6c45bf3bdf4f4ed425c3d7596d11e6553b83f17f5893dfc49f7b + +# if not interactive +if [ ! -t 0 -a -z "$1" ] +then + # non interactive, tarball input + docker run -i --rm "$QEMU_IMAGE" + exit $? +fi + +FILE=$1 +FILE2=$2 +[ -z "$FILE" ] && FILE="$PWD/moby" + +BASE=$(basename "$FILE") +DIR=$(dirname "$FILE") +if [ ! -f "$FILE" -a -f $DIR/$BASE-initrd.img -a -f $DIR/$BASE-bzImage ] +then + FILE=$DIR/$BASE-initrd.img + FILE2=$DIR/$BASE-bzImage +fi + +echo "$FILE" | grep -q '^/' || FILE="$PWD/$FILE" +if [ ! -z "$FILE2" ] +then + echo "$FILE2" | grep -q '^/' || FILE2="$PWD/$FILE2" +fi + +BASE=$(basename "$FILE") +MOUNTS="-v $FILE:/tmp/$BASE" +BASE2=$(basename "$FILE2") +[ ! -z "$FILE2" ] && MOUNTS="$MOUNTS -v $FILE2:/tmp/$BASE2" +docker run -it --rm $MOUNTS "$QEMU_IMAGE"