#!/bin/sh
# Warn the user if ZFS is to be used on i386.

case "$(udpkg --print-architecture)" in
	"kfreebsd-i386")
	;;
	*)
		exit 0
	;;
esac

. /lib/partman/lib/base.sh

for dev in $DEVICES/*; do
	[ -d "$dev" ] || continue
	cd $dev
	open_dialog PARTITIONS
	while { read_line num id size type fs path name; [ "$id" ]; }; do
		[ "$fs" != free ] || continue
		[ -f $id/method ] || continue
		[ -f $id/acting_filesystem ] || continue
		[ -f $id/mountpoint ] || continue
		filesystem=$(cat $id/acting_filesystem)
		if [ "$filesystem" = zfs ]; then
			found_zfs=true
		fi
	done
	close_dialog
done

# Warn if ZFS is to be used.
if [ "$found_zfs" = true ]; then
	db_set partman-zfs/i386 true
	db_input critical partman-zfs/i386 || true
	db_go || true
	db_get partman-zfs/i386
	if [ "$RET" = true ]; then
		exit 1
	fi
fi

