#! /bin/sh

set -e

#DEBHELPER#

# same test as udev postinst...
chrooted() {
  if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ];
  then
    # the devicenumber/inode pair of / is the same as that of /sbin/init's
    # root, so we're *not* in a chroot and hence return false.
    return 1
  fi
  return 0
}

if [ "$1" = "configure" ]; then
  if ! chrooted ; then
    # try to update udev now
    udevadm control --reload-rules || true ;
  fi
# begin-remove-after: released:forky
  # protective diversion of files moved from / to /usr, to avoid file loss.
  # Only for upgrades.
    # At this point, the package will have installed the same file in */usr*.
    dpkg-divert --package usr-is-merged --no-rename \
        --divert /lib/udev/rules.d/60-libairspy0.rules.usr-is-merged \
        --remove /lib/udev/rules.d/60-libairspy0.rules
# end-remove-after

fi

exit 0
