#!/bin/sh
# btrfs is unsupported with UCS (Docker)

. /lib/partman/lib/base.sh

btrfs=false
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
		case "$(cat "$id/acting_filesystem" )" in
		btrfs) btrfs=: ;;
		esac
	done
	close_dialog
done

if "$btrfs"
then
	db_input critical partman-btrfs/ucs-unsupported
	db_go || true
	db_get partman-btrfs/ucs-unsupported
	if [ "$RET" = true ]; then
		exit 1
	fi
fi

exit 0
