_message() {
  cat <<END

>>> Remove any manual tweaks made to /boot/config.txt particulary a line such
    as gpu_mem=xxx.  Driver setup for Kodi is stored in /boot/kodi.config.txt

    Manually append the following to /boot/config.txt to make them active:
    [all]
    include kodi.config.txt

    A reboot will be required to activate them if this is a fresh install.

END
}

pre_upgrade() {
  _ver() { local v=${1#*.*.}; echo ${v%%.*}; }
  if (( $(_ver $2) < 70755 )); then
    userdel kodi 2>/dev/null || true
  fi
}

post_install() {
  _config=/boot/config.txt
  if [ -f "$_config" ]; then
    if ! grep -q 'include kodi.config.txt' "$_config"; then
    _message
    fi
  fi
}

post_upgrade() {
  post_install
}

post_remove() {
  echo "==> Optionally remove /var/lib/kodi/"
}
