( cd usr/bin ; rm -rf xulrunner )
( cd usr/bin ; ln -sf /usr/lib64/xulrunner-1.9.0.13/xulrunner xulrunner )
( cd usr/lib64/pkgconfig ; rm -rf xulrunner-plugin.pc )
( cd usr/lib64/pkgconfig ; ln -sf mozilla-plugin.pc xulrunner-plugin.pc )
( cd usr/lib64/xulrunner-devel-1.9.0.13 ; rm -rf lib )
( cd usr/lib64/xulrunner-devel-1.9.0.13 ; ln -sf /usr/lib64/xulrunner-devel-1.9.0.13/sdk/lib lib )
( cd usr/lib64/xulrunner-devel-1.9.0.13 ; rm -rf bin )
( cd usr/lib64/xulrunner-devel-1.9.0.13 ; ln -sf /usr/lib64/xulrunner-1.9.0.13 bin )
( cd usr/lib64/xulrunner-devel-1.9.0.13/sdk ; rm -rf include )
( cd usr/lib64/xulrunner-devel-1.9.0.13/sdk ; ln -sf /usr/include/xulrunner-1.9.0.13/stable include )
( cd usr/lib64/xulrunner-devel-1.9.0.13/sdk ; rm -rf idl )
( cd usr/lib64/xulrunner-devel-1.9.0.13/sdk ; ln -sf /usr/share/idl/xulrunner-1.9.0.13/stable idl )
( cd usr/lib64/xulrunner-devel-1.9.0.13 ; rm -rf include )
( cd usr/lib64/xulrunner-devel-1.9.0.13 ; ln -sf /usr/include/xulrunner-1.9.0.13/unstable include )
( cd usr/lib64/xulrunner-devel-1.9.0.13 ; rm -rf idl )
( cd usr/lib64/xulrunner-devel-1.9.0.13 ; ln -sf /usr/share/idl/xulrunner-1.9.0.13/unstable idl )

# Clean up previous softlinks
if [ -r usr/lib64/xulrunner ]; then
  chroot . rm -rf usr/lib64/xulrunner ;
fi;
if [ -r usr/lib64/xulrunner-devel ]; then
  chroot . rm -rf usr/lib64/xulrunner-devel ;
fi;

# Make our softlinks
if [ -d usr/lib64/xulrunner-1.9.0.13 ]; then
  (cd usr/lib64 ; ln -sf xulrunner-1.9.0.13 xulrunner );
fi;
if [ -d usr/lib64/xulrunner-devel-1.9.0.13 ]; then
  (cd usr/lib64 ; ln -sf xulrunner-devel-1.9.0.13 xulrunner-devel );
fi;

# Set up java plugins for xulrunner if java installed
if [ ! -h usr/lib64/mozilla/plugins/libjavaplugin_oji.so ]; then
  if [ -e usr/lib64/java/plugin/i386/ns7/libjavaplugin_oji.so ]; then
    mkdir -p usr/lib64/mozilla/plugins ;
    ( cd usr/lib64/mozilla/plugins ; ln -sf /usr/lib64/java/plugin/i386/ns7/libjavaplugin_oji.so libjavaplugin_oji.so )
  elif [ -e usr/lib64/java/jre/plugin/i386/ns7/libjavaplugin_oji.so ]; then
    ( cd usr/lib64/mozilla/plugins ; ln -sf /usr/lib64/java/jre/plugin/i386/ns7/libjavaplugin_oji.so libjavaplugin_oji.so )
  fi
fi

# Add xulrunner to ld.so.conf
if grep "xulrunner" etc/ld.so.conf 1> /dev/null 2> /dev/null ; then
  true
else
  echo "/usr/lib64/xulrunner" >> etc/ld.so.conf
fi
ldconfig -r . 
