File chromium.spec of Package chromium

# Thanks to malcolmlewis for help with this script
# Thanks to Tom "spot" Callaway for much of the patchwork
# Thanks to jhaygood for most of the icu patch

# norootforbuild

%define svn_rev 61684
%define v8_ver 2.4.8.0

Name:           chromium
Summary:        Google's opens source browser project
Version:        7.0.548.0
Release:        1
License:        BSD
Group:          Productivity/Networking/Web/Browsers
Source0:        %{name}.%{version}.svn%{svn_rev}.tar.lzma
## The following are included for source reasons only
# Custom build tools for chromium, hammer is a fancy front-end for scons
Source1:        http://src.chromium.org/svn/trunk/tools/depot_tools.tar.gz
# Script used to create the tar.lzma archive from the daily tarball downloadable at http://build.chromium.org/buildbot/archives/
Source2:        repack_chromium_archive.sh
# Script used to create the tar.lzma archive from a checked out source
Source3:        pack_chromium_source.sh
#Source10:       chromium.desktop
# Patch template which adds vendor to user agent
Source20:       chromium-vendor.patch.in
Source30:       master_preferences
Source31:       default_bookmarks.html
Source99:       chrome-wrapper
Source100:      chromium-browser.sh
Source101:      chromium-browser.desktop
Source102:      chromium-browser.xml
Source103:      chromium-browser-rpmlintrc
Provides:       chromium-browser = %{version}
Provides:	chromium-based-browser
Obsoletes:      chromium-browser < %{version}

## Start Patches
# Many changes to the gyp system so we can use system libraries
# My first ever patch set.  I hope I did well.
Patch3:         chromium-gyp-system-icu.patch
Patch4:         chromium-no-sqlite-debug.patch
Patch5:         chromium-gyp-system-04-nss-nspr.patch
Patch7:         chromium-codechanges-nss-nspr.patch
Patch8:         chromium-codechanges-zlib.patch
Patch12:        chromium-no-test-sources.patch
Patch13:        chromium-no-courgette.patch
Patch14:	chromium-master-prefs-path.patch
Patch17:        chromium-system-glew.patch
Patch18:        chromium-system-expat.patch
Patch19:        chromium-system-zlib.patch
Patch20:        chromium-noffmpeg.patch
Patch21:        chromium-system-old-ffmpeg-way.patch
%ifarch %ix86
Patch23:        chromium-disable-mmx.patch
%endif
Patch25:        tcmalloc-factory.patch
Patch26:        chromium-remoting-build-fix.diff
# Shared Library patches
Patch60:	chromium-sharedlibfixes.patch
Patch61:        chromium-shared-chromiumthreading.patch
Patch62:        chromium-norpath.patch
Patch63:        chromium-6.0.406.0-system-gyp-v8.patch
# Patches for MeeGo Netbook
Patch80:        chromium-browser-window-focus.patch
Patch81:        chromium-20100319-default-browser-setting.patch
Patch82:        chromium-20100506-expose-chromium-browser-api.patch
Patch83:        chromium-fix-toolbar-icon-size.patch

BuildRequires:  gcc gcc-c++ libstdc++ libstdc++-devel libevent openssl-devel
BuildRequires:  pkg-config python python-xml perl bison flex gperf wdiff update-desktop-files lzma
BuildRequires:  mozilla-nss-devel alsa-devel gtk2-devel glib2-devel cairo-devel >= 1.6 
BuildRequires:  mozilla-nspr-devel gconf2-devel freetype2-devel dbus-1-devel libxslt-devel libxml2-devel 
BuildRequires:  libjpeg-devel zlib-devel libbz2-devel cups-devel
BuildRequires:  fdupes libexpat-devel
BuildRequires:  Mesa-devel hunspell-devel
BuildRequires:  libpng-devel sqlite3-devel libgnutls-devel
BuildRequires:  desktop-file-utils
BuildRequires:  v8-devel = %{v8_ver}
BuildRequires:  libvpx-devel
%if 0%{?suse_version} > 1120
BuildRequires:  libgnome-keyring-devel
%else
BuildRequires:  gnome-keyring-devel
%endif
%if 0%{?suse_version} > 1130
BuildRequires:  python-devel
%endif

%if 0%{?suse_version} >= 1110
BuildRequires:  libicu-devel >= 4.0 libevent-devel
%endif

Requires:       alsa xdg-utils
Requires:       chromium-libs = %{version}-%{release}
# shouldn't be required to name all dependencies
# Requires:       mozilla-nss mozilla-nspr gtk2 glib2 cairo >= 1.6 freetype2 dbus-1 alsa v8 >= 1.3.15
# Recommends the ffmpeg libraries (available from packman)
Recommends:     libavcodec52 libavformat52 libavutil50

%if 0%{?suse_version} < 1120
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%endif

%description
Chromium is the open-source project behind Google Chrome. We invite you to join us in our effort to help build a safer, faster, and more stable way for all Internet users to experience the web, and to create a powerful platform for developing a new generation of web applications.

%package libs
Summary:        Shared libraries for chromium
Group:          System/Libraries
Requires:       v8 = %{v8_ver}

%description libs
This package contains the shared libraries that chromium depends on. Some of
these libraries are unique to chromium, others are forked versions of system
libraries.

%package devel
Summary:        Header file for chromium browser
Group:          Development/Libraries
Requires:       chromium-libs = %{version}-%{release}

%description devel
This package contains the header files and pc file of chromium browser for
applications which will use chromium browser APIs.


%prep
lzma -cd %{SOURCE0} | tar xf -
%setup -D -T -n %{name}

%patch60 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch80 -p1
%patch81 -p1
%patch82 -p1
%patch83 -p1

# use system libicu only if >= 4.0
%if 0%{?suse_version} >= 1110
%patch3 -p1
%endif

%patch4 -p1
%patch5 -p1
%patch7 -p1
%patch8 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%if %suse_version > 1120
%patch25 -p1
%endif
%ifarch %ix86
%patch23 -p1
%endif
%patch26 -p1


# apply vendor patch after substitution
sed "s:RPM_VERSION:%{version}:" %{SOURCE20} | patch -p0

%build

## create make files

PARSED_OPT_FLAGS=`echo \'$RPM_OPT_FLAGS -DUSE_SYSTEM_LIBEVENT -fPIC -fno-ipa-cp -fno-strict-aliasing \' | sed "s/ /',/g" | sed "s/',/', '/g"`
for i in src/build/common.gypi; do
        sed -i "s|'-march=pentium4',||g" $i
        sed -i "s|'-msse2',||g" $i
        sed -i "s|'-mfpmath=sse',||g" $i
        sed -i "s|'-O<(debug_optimize)',||g" $i
        sed -i "s|'-m32',||g" $i
        sed -i "s|'-fno-exceptions',|$PARSED_OPT_FLAGS|g" $i
        sed -i "s|'-Werror'|'-Wno-error'|g" $i
done
# '

pushd src

./build/gyp_chromium -f make build/all.gyp \
-Dlinux_sandbox_path=%{_libdir}/chromium/chrome-sandbox \
-Dlinux_sandbox_chrome_path=%{_libdir}/chromium/chromium-browser \
-Duse_system_ffmpeg=1 \
-Duse_system_zlib=1 \
-Duse_system_libpng=1 \
-Duse_system_bzip2=1 \
-Duse_system_libbz2=1 \
-Duse_system_libjpeg=1 \
-Duse_system_libxml=1 \
-Duse_system_libxslt=1 \
-Duse_system_libevent=1 \
-Duse_system_vpx=1 \
-Dproprietary_codecs=1 \
-Dlibrary=shared_library \
-Dlinux_fpic=1 \
%ifarch %ix86
-Ddisable_sse2=1 \
%endif
%if 0%{?suse_version} > 1110
-Duse_system_icu=1 \
%endif
%ifarch x86_64
-Dtarget_arch=x64 \
%endif
%if 0%{?suse_version} > 1110
-Dno_strict_aliasing=1 -Dgcc_version=44 \
%endif
-Drelease_extra_cflags=-fPIC

make -r %{?jobs:-j%jobs} chrome BUILDTYPE=Release
#make -r -j5 chrome BUILDTYPE=Release 

popd

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
install -m 755 %{SOURCE100} %{buildroot}%{_bindir}/chromium
# x86_64 capable systems need this
sed -i "s|/usr/lib/chromium|%{_libdir}/chromium|g" %{buildroot}%{_bindir}/chromium
mkdir -p %{buildroot}%{_libdir}/chromium/
mkdir -p %{buildroot}%{_mandir}/man1/
pushd src/out/Release
cp -a chrome.pak locales resources xdg-settings %{buildroot}%{_libdir}/chromium/
cp -a resources.pak %{buildroot}%{_libdir}/chromium/
cp -a chrome %{buildroot}%{_libdir}/chromium/chromium
cp -a lib.target/lib*.so %{buildroot}%{_libdir}/chromium/
cp -a lib.host/lib*.so %{buildroot}%{_libdir}/chromium/
#cp -a chrome_sandbox %{buildroot}%{_libdir}/chromium/chrome-sandbox
cp -a chrome.1 %{buildroot}%{_mandir}/man1/chrome.1
cp -a chrome.1 %{buildroot}%{_mandir}/man1/chromium.1
%fdupes %{buildroot}%{_mandir}/man1/
popd

# devel package install
mkdir -p %{buildroot}%{_libdir}/chromium/include
pushd src
find base -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find app -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find chrome -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find skia -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find build -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find googleurl -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find ipc -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find testing -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find net -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find third_party/skia -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find third_party/WebKit -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find webkit -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
find gfx -name "*.h" -exec cp --parents {} %{buildroot}%{_libdir}/chromium/include \;
popd
find %{buildroot}%{_libdir}/chromium/include -name "*.h" -exec chmod 644 {} \;
%fdupes %{buildroot}%{_libdir}/chromium/include

mkdir -p %{buildroot}/%_libdir/pkgconfig
cat <<! > %{buildroot}/%_libdir/pkgconfig/chromium-browser.pc
Name: Chromium browser
Description: Chromium browser development package
Version: 1.0.1
Libs: -L%{_libdir}/chromium -lapp_base -lappcache -lbase_i18n -lbase -lblob -lbrowser -lcacheinvalidation -lchrome_gpu -lchromoting_base -lchromoting_client -lchromoting_host -lchromoting_jingle_glue -lchromotocol_proto_lib -lcld -lcommon_constants -lcommon_net -lcommon -ldatabase -ldebugger -ldefault_plugin -ldynamic_annotations -lffmpeg -lfileapi -lgfx -lglue -lgoogleurl -lgtest -lharfbuzz_interface -lharfbuzz -lhttp_listen_socket -lhunspell -lil -linstaller_util -lipc -ljingle_p2p -ljingle -lmedia -lmodp_b64 -lnet_base -lnet -lnotifier -lomx_wrapper -lots -lpcre -lplugin -lprinting -lprofile_import -lprotobuf_lite -lprotobuf -lrenderer -lsandbox -lsdch -lservice -lskia_opts -lskia -lspeex -lsqlite3 -lsrtp -lssl -lsymbolize -lsyncapi -lsync_notifier -lsync -ltrace_proto_lib -lutility -lwebcore_bindings -lwebcore_platform -lwebcore_remaining -lwebcore_svg -lwebkit_user_agent -lworker -lwtf -lxdg_mime -lzlib
Cflags: -I%{_libdir}/chromium/include -I%{_libdir}/chromium/include/skia/config
!

mkdir -p %{buildroot}%{_datadir}/pixmaps/
cp -a src/chrome/app/theme/chromium/product_logo_48.png %{buildroot}%{_datadir}/pixmaps/chromium-browser.png

mkdir -p %{buildroot}%{_datadir}/applications/
desktop-file-install --dir %{buildroot}%{_datadir}/applications %{SOURCE101}

mkdir -p %{buildroot}%{_datadir}/gnome-control-center/default-apps/
cp -a %{SOURCE102} %{buildroot}%{_datadir}/gnome-control-center/default-apps/

# link to browser plugin path.  Plugin patch doesn't work. Why?
%{__mkdir_p} %{buildroot}%{_libdir}/browser-plugins
pushd %{buildroot}%{_libdir}/%{name}
%{__ln_s} %{_libdir}/browser-plugins plugins
touch %{buildroot}%{_libdir}/libavcodec.so.52
%{__ln_s} %{_libdir}/libavcodec.so.52 libavcodec.so.52
touch %{buildroot}%{_libdir}/libavformat.so.52
%{__ln_s} %{_libdir}/libavformat.so.52 libavformat.so.52
touch %{buildroot}%{_libdir}/libavutil.so.50
%{__ln_s} %{_libdir}/libavutil.so.50 libavutil.so.50
popd

# Install the master_preferences file
mkdir -p %{buildroot}%{_sysconfdir}/%{name}
install -m 0644 %{SOURCE30} %{buildroot}%{_sysconfdir}/%{name}
install -m 0644 %{SOURCE31} %{buildroot}%{_sysconfdir}/%{name}

%clean
%{__rm} -rf %{buildroot}

# Files!

%files
%defattr(-,root,root,-)
%config %{_sysconfdir}/%{name}
%dir /usr/share/gnome-control-center
%dir /usr/share/gnome-control-center/default-apps
%{_bindir}/chromium
%{_libdir}/chromium/chromium
# These unique permissions are intentional and necessary for the sandboxing
#%attr(4555, root, root) %{_libdir}/chromium/chrome-sandbox
%{_libdir}/chromium/plugins/
%{_libdir}/chromium/resources/
%{_libdir}/chromium/xdg-settings
%{_mandir}/man1/chrom*
%{_datadir}/pixmaps/chromium-browser.png
%{_datadir}/applications/*.desktop
%{_datadir}/gnome-control-center/default-apps/chromium-browser.xml
%{_libdir}/chromium/libavcodec.so.52
%{_libdir}/chromium/libavutil.so.50
%{_libdir}/chromium/libavformat.so.52
%exclude %{_libdir}/libavcodec.so.52
%exclude %{_libdir}/libavutil.so.50
%exclude %{_libdir}/libavformat.so.52

%files libs
%defattr(-,root,root,-)
%dir %{_libdir}/chromium/
%{_libdir}/chromium/chrome.pak
%{_libdir}/chromium/resources.pak
%{_libdir}/chromium/locales/
%{_libdir}/chromium/lib*.so

%files devel
%defattr(-,root,root,-)
%{_libdir}/chromium/include/
%_libdir/pkgconfig/chromium-browser.pc

%Changelog
* Sun Mar 07 2010 - tititatcoke@gmail.com - 5.0.347.0
- Update to 5.0.347
  + moved back to static binary again.
  + No longer depends on system v8
* Mon Feb 21 2010 - tititatcoke@gmail.com - 5.0.341.0
- Update to 5.0.341
  + remove courgette build and sources (patent issue)
  + Move to shared libraries build
  + Depends on system v8 again
* Sun Nov 29 2009 - tittiatcoke@gmail.com - 4.0.260.0
- Update to 4.0.260
* Fri Nov 27 2009 - tittiatcoke@gmail.com - 4.0.259.0
- Update to 4.0.259
* Thu Nov 26 2009 - tittiatcoke@gmail.com - 4.0.258.0
- Update to 4.0.258
* Tue Nov 24 2009 - tittatcoke@gmai.com - 4.0.257.0
- In order to complete prevent the wrong v8 version to be used, the Chromium build has been
  changed to having an built-in v8 
* Tue Nov 24 2009 - dbuck@example.com - 4.0.257.0
- Re-base patches.  Fixed a few patch errors.  Rename some patches to better correspond with function.  Removed some patches.
- Minor SPEC changes.  I changed the v8 requirement to be exact, instead of greater than a specific version.
* Sat Oct 24 2009 - Pavol Rusnak <prusnak@suse.cz> - 4.0.223.5
- don't create desktop files in wrapper, fix LD_LIBRARY_PATH (chromium-fix-wrapper.patch)
* Tue Oct 20 2009 - Raymond Wooninck >tittiatcoke@gmail.com> - 4.0.223.5
- update to newer svn snapshot
  + Obsoletes fwrite patch (included upstream)
* Fri Oct 16 2009 - Raymond Wooninck <tittiatcoke@gmail.com> - 4.0.223.2
- update to newer svn snapshot
  + Requires newer version of v8
* Thu Oct 15 2009 - Pavol Rusnak <prusnak@suse.cz> - 4.0.222.6
- do not force SSE on x86 (drop-sse.patch)
* Tue Oct 13 2009 - Raymond Wooninck <tittiatcoke@gmail.com> - 4.0.222.6
- Update to newer svn snapshot
- Fixed spec file in order to build
- Included patch to build with system zlib
* Mon Oct 12 2009 - Pavol Rusnak <prusnak@suse.cz> 4.0.222.2
- package renamed to chromium
- cleaned up spec file
* Tue Oct 6 2009 - dbuck <dbuck@example.com> - 4.0.222.2
- v8 is now built as a separate package, and is required
- included many patches to use system libraries: v8, icu, libxml2, libxslt, libjpeg, libpng, libevent, bzip2, zlib, nspr, nss
* Sun Oct 1 2009 - dbuck <dbuck@example.com> - 4.0.221.1
- included a newer DEP than is in svn, native_client@823.  So things should compile cleanly now
* Sun Aug 31 2009 - dbuck <dbuck@example.com> - 4.0.204.0
- initial build
openSUSE Build Service is sponsored by