# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Report bugs to [email protected]
# $Header: $

EAPI="2"
inherit eutils

DESCRIPTION="Binary version of Chromium, taken from Ubuntu PPA"
HOMEPAGE="http://code.google.com:80/chromium/"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86"

IUSE="+plugins-symlink +ffmpeg +default-browser restricted inspector"

DEPEND="
 >=dev-lang/python-2.4
 >=dev-libs/nss-3.12
 x11-libs/gtk+:2
 media-fonts/corefonts
 media-libs/jpeg:62
"
RDEPEND="${DEPEND}"

S="${WORKDIR}/${PN}"

QA_EXECSTACK="opt/chromium/chromium-browser/chromium-browser"
QA_PRESTRIPPED="opt/chromium/chromium-browser/chromium-browser-sandbox"
QA_PRESTRIPPED="opt/chromium/chromium-browser/libffmpegsumo.so"

src_unpack() {
 LV=`curl --silent https://launchpad.net/~chromium-daily/+archive/ppa/+packages | grep 'chromium-browser - ' -m 1 | cut -d " " -f 11`
 elog "Latest version is ${LV}"
 wget -c http://ppa.launchpad.net/chromium-daily/ppa/ubuntu/pool/main/c/chromium-browser/${PN}_${LV}_i386.deb -O ${PN}-${LV}.deb
 ar vx "${PN}-${LV}.deb"
 lzma -cvd data.tar.lzma | tar vx

 if use restricted; then
  mkdir chrome && cd chrome
  wget http://dl.google.com/dl/linux/direct/google-chrome-beta_current_i386.deb
  ar vx google-chrome-beta_current_i386.deb
  lzma -cvd data.tar.lzma | tar vx
 fi
}

src_install() {
 declare CHROMIUM_HOME=/opt/chromium

 dodir ${CHROMIUM_HOME}

 mv ${WORKDIR}/usr/lib/${PN} "${D}"${CHROMIUM_HOME}

 if use default-browser; then
  dodir /usr/share/gnome-control-center/default-apps
  insinto /usr/share/gnome-control-center/default-apps
  doins ${WORKDIR}/usr/share/gnome-control-center/default-apps/${PN}.xml
 fi

 #create symlinks for plugins and some libs
 if use plugins-symlink; then
  dosym /usr/lib/nsbrowser/plugins ${CHROMIUM_HOME}/${PN}/plugins
 fi
 
 if use ffmpeg; then
  dosym /usr/lib/libavcodec.so.52 ${CHROMIUM_HOME}/${PN}/libavcodec.so.52
  dosym /usr/lib/libavformat.so.52 ${CHROMIUM_HOME}/${PN}/libavformat.so.52
  dosym /usr/lib/libavutil.so.50 ${CHROMIUM_HOME}/${PN}/libavutil.so.50
 fi

 if use restricted; then
  insinto ${CHROMIUM_HOME}/${PN}
  doins ${WORKDIR}/chrome/opt/google/chrome/libffmpegsumo.so 
 fi

 if use inspector; then
  mv ${WORKDIR}/chrome/opt/google/chrome/resources/inspector "${D}"${CHROMIUM_HOME}/${PN}/resources/
 fi

 # Create /usr/bin/chromium-bin
 cd ${WORKDIR}/usr/bin
 sed 's|/usr/lib/chromium-browser|/opt/chromium/chromium-browser}|g' ${PN} > chb
 rm ${PN}
 mv chb ${PN}
 insinto /usr/bin
 doins ${PN}

 fperms 0755 "/usr/bin/${PN}"
 newicon ${WORKDIR}/usr/share/icons/hicolor/256x256/apps/${PN}.png ${PN}.png
 make_desktop_entry ${PN} "Chromium Browser" ${PN} "Network;WebBrowser"
  mv "${D}"/usr/share/applications/${PN}-${PN}.desktop "${D}"/usr/share/applications/${PN}.desktop
}

Add a code snippet to your website: www.paste.org