#!/bin/sh
# hook for adding overlay modules

set -e

# initramfs-tools header

PREREQ=""
prereqs()
{
	echo "${PREREQ}"
}

case "${1}" in
	prereqs)
		prereqs
		exit 0
		;;
esac

. /usr/share/initramfs-tools/hook-functions

manual_add_modules overlay

if [ -f /usr/bin/deepin-immutable-mount-root ]; then
	copy_file script /usr/bin/deepin-immutable-mount-root
fi

# The cp in busybox is different from the cp in the system
if [ -f /usr/bin/cp ]; then
	copy_exec /usr/bin/cp /usr/bin/cp.fix
fi

if [ -f /usr/bin/deepin-immutable-writable ]; then
	copy_exec /usr/bin/deepin-immutable-writable /usr/bin/
	ln -s deepin-immutable-writable "$DESTDIR/usr/bin/deepin-immutable-init"
fi

# create an empty ostree-auto file to indicate this initrd could handle
# ostree automatically
touch /tmp/ostree-auto
if [ -f /tmp/ostree-auto ]; then
	copy_file config /tmp/ostree-auto /usr/share/deepin-immutable-boot/ostree-auto
fi

exit 0