Use squashfs+overlayfs rootfs

Signed-off-by: Richard Weinberger <richard@nod.at>
diff --git a/init.sh b/init.sh
index 24bae99..4b39832 100755
--- a/init.sh
+++ b/init.sh
@@ -16,4 +16,8 @@
 SSTATE_DIR = "${BASE}/sstate"
 CMDLINE_SERIAL = "console=serial0,115200"
 RPI_EXTRA_CONFIG = "dtoverlay=disable-bt\n"
+WKS_FILE = "sdimage-its.wks"
+IMAGE_BOOT_FILES = "${BOOTFILES_DIR_NAME}/* \
+                 ${@make_dtb_boot_files(d)} \
+                 Image-initramfs-${MACHINE}.bin;kernel8.img"
 EOF
diff --git a/meta-itsyndikat/recipes-its/images/its-image.bb b/meta-itsyndikat/recipes-its/images/its-image.bb
index 7257dd7..24b3f25 100644
--- a/meta-itsyndikat/recipes-its/images/its-image.bb
+++ b/meta-itsyndikat/recipes-its/images/its-image.bb
@@ -1,4 +1,5 @@
 DESCRIPTION = "itsyndikat image"
+IMAGE_FSTYPES = "squashfs wic.bz2"
 
 require recipes-core/images/core-image-minimal.bb
 
diff --git a/meta-itsyndikat/recipes-its/images/its-initramfs.bb b/meta-itsyndikat/recipes-its/images/its-initramfs.bb
new file mode 100644
index 0000000..a820344
--- /dev/null
+++ b/meta-itsyndikat/recipes-its/images/its-initramfs.bb
@@ -0,0 +1,13 @@
+PACKAGE_INSTALL = "\
+	busybox \
+	rpi-initramfs-init \
+"
+
+IMAGE_FEATURES = ""
+IMAGE_LINGUAS = ""
+
+IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
+inherit core-image
+
+IMAGE_ROOTFS_SIZE = "8192"
+IMAGE_ROOTFS_EXTRA_SPACE = "0"
diff --git a/meta-itsyndikat/recipes-its/rpi-initramfs-init/files/init.sh b/meta-itsyndikat/recipes-its/rpi-initramfs-init/files/init.sh
new file mode 100644
index 0000000..8639d81
--- /dev/null
+++ b/meta-itsyndikat/recipes-its/rpi-initramfs-init/files/init.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+mkdir -p /proc
+mkdir -p /ro
+mkdir -p /rw
+mkdir -p /new_root
+
+mount -t proc none /proc
+mount -t devtmpfs none /dev
+
+sqfs="/dev/mmcblk0p2"
+rwfs="/dev/mmcblk0p3"
+
+while [ ! -e ${rwfs} ]; do
+        echo "Waiting for ${rwfs}"
+        sleep 1
+done
+
+mount -t ext4 ${rwfs} /rw
+
+# Insert update concept here
+if [ -r /rw/root.sfs ] ; then
+	mount -t squashfs -o loop /rw/root.sfs /ro
+else
+	mount -t squashfs ${sqfs} /ro
+fi
+
+mkdir -p /rw/overlay
+mkdir -p /rw/overlay_work
+
+mount -t overlay overlay -o lowerdir=/ro,upperdir=/rw/overlay,workdir=/rw/overlay_work /new_root/
+
+exec switch_root /new_root /sbin/init
diff --git a/meta-itsyndikat/recipes-its/rpi-initramfs-init/rpi-initramfs-init.bb b/meta-itsyndikat/recipes-its/rpi-initramfs-init/rpi-initramfs-init.bb
new file mode 100644
index 0000000..545d8e3
--- /dev/null
+++ b/meta-itsyndikat/recipes-its/rpi-initramfs-init/rpi-initramfs-init.bb
@@ -0,0 +1,13 @@
+SUMMARY = "init for its initramfs"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+SRC_URI = "file://init.sh"
+S = "${WORKDIR}"
+
+FILES_${PN} = "/init /dev"
+
+do_install () {
+        install -m 0755 ${WORKDIR}/init.sh ${D}/init
+        install -d ${D}/dev
+        mknod -m 622 ${D}/dev/console c 5 1
+}
diff --git a/meta-itsyndikat/recipes-kernel/linux-raspberrypi/linux-raspberrypi_%.bbappend b/meta-itsyndikat/recipes-kernel/linux-raspberrypi/linux-raspberrypi_%.bbappend
new file mode 100644
index 0000000..b909853
--- /dev/null
+++ b/meta-itsyndikat/recipes-kernel/linux-raspberrypi/linux-raspberrypi_%.bbappend
@@ -0,0 +1,2 @@
+INITRAMFS_IMAGE = "its-initramfs"
+INITRAMFS_IMAGE_BUNDLE = "1"
diff --git a/meta-itsyndikat/wic/sdimage-its.wks b/meta-itsyndikat/wic/sdimage-its.wks
new file mode 100644
index 0000000..7ed27ac
--- /dev/null
+++ b/meta-itsyndikat/wic/sdimage-its.wks
@@ -0,0 +1,3 @@
+part /boot --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot --active --align 4096 --size 20
+part /sfs_root --source rootfs --ondisk mmcblk0 --fstype=squashfs --align 4096 --fixed-size 256 --fsoptions "noauto"
+part /data --ondisk mmcblk0 --fstype=ext4 --label data --align 4096 --size 512