#! /bin/sh

set -e

if [ -n "$DEB_MAINT_PARAMS" ]; then
    eval set -- "$DEB_MAINT_PARAMS"
    if [ -z "$1" ] || [ "$1" != "configure" ]; then
        exit 0;
    fi
fi

# copy rk3399_rock_pi_4c.dtb to /media/boot/ in case it exists
if [ -f /boot/rk3399_rock_pi_4c.dtb ]; then
        if [ -d /media/boot ]; then
                cp /boot/rk3399_rock_pi_4c.dtb /media/boot/
        fi
fi

# copy rk3399-rock-pi-4c.dtb to /media/boot/ in case it exists
if [ -f /boot/rk3399-rock-pi-4c.dtb ]; then
        if [ -d /media/boot ]; then
                cp /boot/rk3399-rock-*.dtb /media/boot/
        fi
fi

if [ -f /media/boot/rk3399-rock-pi-4c.dtb ]; then
	mkdir -p /media/boot/dtb/rockchip/
	cp /media/boot/rk3399-rock-*.dtb /media/boot/dtb/rockchip/
fi

# copy rk3399-rock-pi-4c-linux.dtb to /media/boot/ in case it exists
if [ -f /boot/rk3399-rock-pi-4c-linux.dtb ]; then
        if [ -d /media/boot ]; then
                cp /boot/rk3399-rock-pi-4c-linux.dtb /media/boot/
        fi
fi

if [ -f /media/boot/rk3399-rock-pi-4c-linux.dtb ]; then
	mkdir -p /media/boot/dtb/rockchip/
	cp /media/boot/rk3399-rock-pi-4c-linux.dtb /media/boot/dtb/rockchip/
fi

