post_install() {
if [ "$1" = 'configure' ] || [ "$1" = 'abort-upgrade' ] || [ "$1" = 'abort-deconfigure' ] || [ "$1" = 'abort-remove' ] || [ "pacman" = 'pacman' ]; then
  if [ -x "/data/data/com.termux/files/usr/bin/update-alternatives" ]; then
    # lua
    update-alternatives \
      --install "/data/data/com.termux/files/usr/bin/lua" "lua" "/data/data/com.termux/files/usr/bin/lua5.1" 110 \
      --slave "/data/data/com.termux/files/usr/share/man/man1/lua.1.gz" "lua.1.gz" "/data/data/com.termux/files/usr/share/man/man1/lua5.1.1.gz"
    # luac
    update-alternatives \
      --install "/data/data/com.termux/files/usr/bin/luac" "luac" "/data/data/com.termux/files/usr/bin/luac5.1" 110 \
      --slave "/data/data/com.termux/files/usr/share/man/man1/luac.1.gz" "luac.1.gz" "/data/data/com.termux/files/usr/share/man/man1/luac5.1.1.gz"
  fi
fi
}
pre_remove() {
if [ "$1" = 'remove' ] || [ "$1" != 'upgrade' ] || [ "pacman" = 'pacman' ]; then
  if [ -x "/data/data/com.termux/files/usr/bin/update-alternatives" ]; then
    update-alternatives --remove "lua" "/data/data/com.termux/files/usr/bin/lua5.1"
    update-alternatives --remove "luac" "/data/data/com.termux/files/usr/bin/luac5.1"
  fi
fi
}
