# up_trigger everything on major version updates

if spell_ok $SPELL; then
  local OLD_SPELL_VERSION="$(installed_version $SPELL)" &&

  if test "${VERSION%.?}" != "${OLD_SPELL_VERSION%.?}"; then
    message "${MESSAGE_COLOR}This is a possibly incompatible update of $SPELL..." &&
    message "Figuring out what spells need to be recast, this may take a while.${DEFAULT_COLOR}" &&

    local dependees="$(show_up_depends $SPELL 1)" &&

    # LDFLAGS are taken from /usr/lib/pkgconfig/libxml-2.0.pc
    if spell_ok libxml2 && is_depends_enabled libxml2 icu; then
      dependees="`echo -e "$(show_up_depends libxml2 1)\n$dependees" | sort | uniq`"
    fi &&

    # LDFLAGS are taken from /usr/lib/pkgconfig/raptor2.pc
    if spell_ok raptor && is_depends_enabled raptor icu; then
      dependees="`echo -e "$(show_up_depends raptor 1)\n$dependees" | sort | uniq`"
    fi &&

    for each in $dependees; do
      if gaze install $each | xargs readelf -d 2> /dev/null |
         grep -q "NEEDED.*\(libicuuc\|libicuio\|libicudata\|libicui18n\)\.so"; then
           up_trigger $each cast_self
      fi
    done
  fi
fi
