Refactor to reusable chunks to allow sharing into real rootfs

Signed-off-by: David Greaves <david.greaves@jollamobile.com>