#!/bin/sh

set -eu

#
# deal with .py[co] files that are left overs from pre-pycompile switch
# since we drop regexp etc files

case "$1" in
  configure|reconfigure)

  old_version=$2

  if [ -n "$old_version" ] && dpkg --compare-versions "$old_version" lt "3.4.0+dfsg-2"; then
    find /usr/lib/calibre -name \*.pyc -o -name \*.pyo | while read file ; do
      rm "${file}"
    done
    # regex directory was there but disappeared, try to remove it
    # now that all the pyc files should be gone.
    if [ -d /usr/lib/calibre/regex ] ; then
      rmdir /usr/lib/calibre/regex
    fi
  fi
  ;;
esac


if which py3compile >/dev/null 2>&1; then
	py3compile -p calibre /usr/lib/calibre -V 3.7-
fi
if which pypy3compile >/dev/null 2>&1; then
	pypy3compile -p calibre /usr/lib/calibre -V 3.7- || true
fi

# Automatically added by dh_installdeb/12.10ubuntu1
dpkg-maintscript-helper symlink_to_dir /usr/share/calibre/mathjax ../javascript/mathjax 4.3.0\+dfsg-2\~ calibre -- "$@"
# End automatically added section

