Merge pull request #1949 from justincormack/mkimage-tardisk

Update mkimage to use a tarball as source for files
This commit is contained in:
Justin Cormack 2017-06-01 15:42:34 +01:00 committed by GitHub
commit 1d003717db
4 changed files with 20 additions and 14 deletions

View File

@ -20,4 +20,4 @@ WORKDIR /
COPY --from=mirror /out/ /
COPY mkimage.sh /usr/bin/
CMD ["mkimage.sh"]
LABEL org.mobyproject.config='{"readonly": true, "capabilities": ["CAP_SYS_ADMIN", "CAP_MKNOD"], "binds": ["/dev:/dev", "/data:/data"]}'
LABEL org.mobyproject.config='{"readonly": true, "capabilities": ["CAP_SYS_ADMIN", "CAP_MKNOD"], "binds": ["/dev:/dev"]}'

View File

@ -27,10 +27,13 @@ do_mkfs()
}
DEV="$(find /dev -maxdepth 1 -type b ! -name 'loop*' | grep -v '[0-9]$' | sed 's@.*/dev/@@' | sort | head -1 )"
DEV2="$(find /dev -maxdepth 1 -type b ! -name 'loop*' | grep -v '[0-9]$' | sed 's@.*/dev/@@' | sort | head -2 | tail -1)"
[ -z "${DEV}" ] && exit 1
[ -z "${DEV2}" ] && exit 1
DRIVE="/dev/${DEV}"
DRIVE2="/dev/${DEV2}"
# format
do_mkfs "$DRIVE"
@ -40,11 +43,20 @@ PARTITION="${DRIVE}1"
# mount
mount "$PARTITION" /mnt
# copy kernel, initrd
cp -a /data/kernel /data/initrd.img /mnt/
# copy kernel, initrd from tarball on second disk
tar xf "${DRIVE2}" -C /mnt
# rename if they do not have canonical names
(
cd /mnt
[ -f kernel ] || mv *-kernel kernel
[ -f initrd.img ] || mv *-initrd.img initrd.img
[ -f cmdline ] || mv *-cmdline cmdline
)
# create syslinux.cfg
CMDLINE="$(cat /data/cmdline)"
CMDLINE="$(cat /mnt/cmdline)"
rm -f /mnt/cmdline
CFG="DEFAULT linux
LABEL linux

View File

@ -7,16 +7,9 @@ init:
- linuxkit/containerd:deaf5bf838bf7f131c2287ecff3ed9835b0497e2
onboot:
- name: mkimage
image: "linuxkit/mkimage:a3fd615543b84733ac8ba6f7e1927727665ef404"
image: "linuxkit/mkimage:f4bf0c24261f7d120c8674892805ab3054eb8ac3"
- name: poweroff
image: "linuxkit/poweroff:7404cf2295df89ccfa2dda41997a28307a90cf28"
files:
- path: data/kernel
source: run-kernel
- path: data/initrd.img
source: run-initrd.img
- path: data/cmdline
source: run-cmdline
trust:
org:
- linuxkit

View File

@ -12,14 +12,15 @@ set -e
clean_up() {
find . -iname "run*" -not -iname "*.yml" -exec rm -rf {} \;
find . -iname "mkimage*" -not -iname "*.yml" -exec rm -rf {} \;
rm -f disk.qcow2
rm -f disk.qcow2 tarball.img
}
trap clean_up EXIT
# Test code goes here
moby build -output kernel+initrd run.yml
moby build -output kernel+initrd mkimage.yml
linuxkit run qemu -disk disk.qcow2,size=200M,format=qcow2 -kernel mkimage
tar cf tarball.img run-kernel run-initrd.img run-cmdline
linuxkit run qemu -disk disk.qcow2,size=200M,format=qcow2 -disk tarball.img,format=raw -kernel mkimage
linuxkit run qemu disk.qcow2
exit 0