# Update the X font indexes:
if [ -x /usr/bin/fc-cache ]; then
  /usr/bin/fc-cache -f
fi
# else we'll catch it later with setup.fontconfig :-)

# With fontconfig-2.15.0 we use the default of /usr/share/fontconfig/conf.avail
# so if we find any of "our" files in the old location, it's possible that they
# rode the old symlink there prior to this package being installed. Let's make
# sure that they get home OK.
if [ -d etc/fonts/conf.avail ]; then
  grep usr/share/fontconfig/conf.avail/ var/lib/pkgtools/packages/* | cut -f 2 -d : | sort | uniq | grep -v "/$" | while read conf ; do
    etcconf="etc/fonts/$(echo $conf | cut -f 4- -d /)"
    if [ ! -r $conf -a -r $etcconf ]; then
      mv $etcconf $conf
    else
      rm -f $etcconf
    fi
  done
fi
# If we can, get rid of this. Could be held by third-party packages though.
rmdir etc/fonts/conf.avail 2> /dev/null
( cd etc/fonts/conf.d ; rm -rf 10-scale-bitmap-fonts.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/10-scale-bitmap-fonts.conf 10-scale-bitmap-fonts.conf )
( cd etc/fonts/conf.d ; rm -rf 10-yes-antialias.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/10-yes-antialias.conf 10-yes-antialias.conf )
( cd etc/fonts/conf.d ; rm -rf 20-unhint-small-vera.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/20-unhint-small-vera.conf 20-unhint-small-vera.conf )
( cd etc/fonts/conf.d ; rm -rf 30-metric-aliases.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/30-metric-aliases.conf 30-metric-aliases.conf )
( cd etc/fonts/conf.d ; rm -rf 40-nonlatin.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/40-nonlatin.conf 40-nonlatin.conf )
( cd etc/fonts/conf.d ; rm -rf 45-generic.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/45-generic.conf 45-generic.conf )
( cd etc/fonts/conf.d ; rm -rf 45-latin.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/45-latin.conf 45-latin.conf )
( cd etc/fonts/conf.d ; rm -rf 48-spacing.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/48-spacing.conf 48-spacing.conf )
( cd etc/fonts/conf.d ; rm -rf 49-sansserif.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/49-sansserif.conf 49-sansserif.conf )
( cd etc/fonts/conf.d ; rm -rf 50-user.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/50-user.conf 50-user.conf )
( cd etc/fonts/conf.d ; rm -rf 51-local.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/51-local.conf 51-local.conf )
( cd etc/fonts/conf.d ; rm -rf 60-generic.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/60-generic.conf 60-generic.conf )
( cd etc/fonts/conf.d ; rm -rf 60-latin.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/60-latin.conf 60-latin.conf )
( cd etc/fonts/conf.d ; rm -rf 65-fonts-persian.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/65-fonts-persian.conf 65-fonts-persian.conf )
( cd etc/fonts/conf.d ; rm -rf 65-nonlatin.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/65-nonlatin.conf 65-nonlatin.conf )
( cd etc/fonts/conf.d ; rm -rf 69-unifont.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/69-unifont.conf 69-unifont.conf )
( cd etc/fonts/conf.d ; rm -rf 80-delicious.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/80-delicious.conf 80-delicious.conf )
( cd etc/fonts/conf.d ; rm -rf 90-synthetic.conf )
( cd etc/fonts/conf.d ; ln -sf ../../../usr/share/fontconfig/conf.avail/90-synthetic.conf 90-synthetic.conf )
( cd usr/lib ; rm -rf libfontconfig.so )
( cd usr/lib ; ln -sf libfontconfig.so.1 libfontconfig.so )
( cd usr/lib ; rm -rf libfontconfig.so.1 )
( cd usr/lib ; ln -sf libfontconfig.so.1.15.0 libfontconfig.so.1 )
