#!/bin/bash -ex
# vi: ts=4 noexpandtab
#
# Generate a squashfs root and manifest

set -x
echo "030-root-squashfs.binary"

case $IMAGE_TARGETS in
	""|*squashfs*)
		;;
	*)
		echo "Skipping squashfs build"
		exit 0
		;;
esac

if [ -n "$SUBARCH" ]; then
	echo "Skipping rootfs build for subarch flavor build"
	exit 0
fi

. config/functions

mkdir binary/boot/squashfs.dir
cp -a chroot/* binary/boot/squashfs.dir

squashfs_f="${PWD}/livecd.${PROJECT}.squashfs"
squashfs_f_manifest="${squashfs_f}.manifest"

create_manifest "binary/boot/squashfs.dir" "${squashfs_f_manifest}"

(cd "binary/boot/squashfs.dir/" &&
      mksquashfs . ${squashfs_f} \
        -no-progress -xattrs -comp xz )