Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jan 18th, 2011  |  syntax: Bash  |  size: 2.94 KB  |  hits: 99  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/sh
  2.  
  3. ### NOTE: Here you (can) choose whether you are trying to 'fix' google-chrome(-beta/-dev), chromium-browser or iron
  4.  
  5. ## Google-chrome(-beta/-dev) users select this one (default):
  6. _destdir=/opt/google-chrome && _exec=${_destdir}/google-chrome
  7.  
  8. ## Chromium-browser users (uncomment this & comment the Google-chrome one (in case you use chromium-browser)):
  9. #_destdir=/opt/chromium-browser && _exec=/usr/bin/chromium-browser
  10.  
  11. ## Iron users (same thing):
  12. # _destdir=/opt/iron && _exec=/usr/bin/iron
  13.  
  14. # For the wget (download) section (to get the correct file)
  15. _arch='i386'
  16. [[ `uname -m` = "x86_64" ]] && _arch='amd64'
  17.  
  18. # Make sure only root can run our script
  19. if [[ $EUID -ne 0 ]]; then
  20.    echo "This script must be run as root" 1>&2
  21.    exit 1
  22. fi
  23.  
  24. # If the .cache file was not found (meaning this was the first time doing this), we do all the other stuff too
  25. if [[ ! -f ${_destdir}/loaders.cache ]]; then
  26.   # Create our custom dir for doing this (and cd there)
  27.   mkdir ~/chrome-libjpeg6
  28.   cd ~/chrome-libjpeg6
  29.   # Fetch the .deb and extract the archives
  30.   wget http://mirrors.easynews.com/linux/ubuntu/pool/main/g/gtk+2.0/libgtk2.0-0_2.18.3-1_${_arch}.deb
  31.   ar -xv libgtk2.0-0_2.18.3-1_${_arch}.deb
  32.   tar -xvf data.tar.gz
  33.   # Cd to where sh*t is going down (the install dir)
  34.   cd ${_destdir}
  35.   # Move the jpeg-loader file (t)here
  36.   mv ~/chrome-libjpeg6/usr/lib/gtk-2.0/2.10.0/loaders/libpixbufloader-jpeg.so .
  37.   # Create the .cache file and modify the jpeg-loader pointer line there (this changes all the other pointer lines too but no matter)
  38.   gdk-pixbuf-query-loaders > loaders.cache
  39.   sed -i "s|/usr/lib/gdk-pixbuf-2.0/2.10.0/loaders|${_destdir}|" loaders.cache
  40.   # Done. We can now remove our custom dir
  41.   rm -r ~/chrome-libjpeg6
  42. fi
  43.  
  44. # Check whether this script was already run (or done manually). If not, put a line (and a comment) to our main
  45. # chrome/chromium/iron script to read the generated .cache file. With all these browsers this needs to be done
  46. # differently (hence the whole "if - then" query section)
  47. if [[ `cat ${_exec} | grep GDK` = "" ]]; then
  48.    if [[ "${_destdir}" = "/opt/google-chrome" ]]; then
  49.       sed -i '/^exec/i\# Read our loaders.cache (to fix .jpg/.jpeg crashes)\nexport GDK_PIXBUF_MODULE_FILE=${_destdir}/loaders.cache\n' ${_exec}
  50.    elif [[ "${_destdir}" = "/opt/chromium-browser" ]]; then
  51.       sed -i '/^done/a\\n# Read our loaders.cache (to fix .jpg/.jpeg crashes)\nexport GDK_PIXBUF_MODULE_FILE=${_destdir}/loaders.cache' ${_exec}
  52.    elif [[ "${_destdir}" = "/opt/iron" ]]; then
  53.       echo -e "\n# Read our loaders.cache (to fix .jpg/.jpeg crashes)\nexport GDK_PIXBUF_MODULE_FILE=${_destdir}/loaders.cache" >> ${_exec}
  54.    fi
  55.    echo; echo All done! # Say "done" here to make sure that people who had already done this before (and just updated chrome/
  56. else                    # chromium/iron) don't wonder the script completing so fast (because there was only this sed'ing to do)
  57.    echo Nothing to be done.
  58. fi