Skip to content
This repository has been archived by the owner on Aug 20, 2020. It is now read-only.

Commit

Permalink
Add support for RPM build
Browse files Browse the repository at this point in the history
This patch is based on Crosswalk RPM package files.
  • Loading branch information
Joone Hur authored and kalyankondapally committed Feb 20, 2014
1 parent a32c755 commit 35bbb13
Show file tree
Hide file tree
Showing 9 changed files with 438 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gbp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# For more information about this file, see git-buildpackage's documentation.
# It is used by gbs in order to build Chromium packages for Tizen.

[DEFAULT]
# This postexport hook is used to replace the default chromium.tar file
# generated with `git archive' (and which only contains the contents of
# chromium.git) with a full-blown tar file that contains all source code
# required to build Chromium. Additionally, the new tar file's members all
# contain their original mtimes, which is helpful if one wants to try an
# incremental Tizen build. The script is run from the temporary directory
# containing the contents of packaging/ that are used by git-buildpackage.
postexport = ./gbp-flat-tree.sh
82 changes: 82 additions & 0 deletions packaging/rpm/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
This directory contains a collection of tools and RPM-related files used to
build Chromium browser RPMs for Tizen IVI.

BUILD INSTRUCTIONS
------------------

In the simplest case, a call to `gbs build' from the ozone/ directory suffices.
It should create a Tizen chroot and launch a build from there, requiring no
further interaction and producing a few RPMs at the end of the process.

For more information on which other parameters one is normally expected to pass
to `gbs build' (including "-A" to specify the Tizen architecture) and also on
gbs' configuration file, please consult gbs' documentation.

A very important thing to notice is that, due to the way the integration with
gbs is implemented, _anything_ currently present in your source tree will be
built, regardless of whether "--include-all" is passed to `gbs build' or not.

INCREMENTAL BUILDS
------------------

By default, Chromium browser is built inside src/out/Release inside the Chromium's
directory. Also by default, each call to `gbs build' will erase the RPM build
root in the Tizen chroot, which means your previous build will be lost.

To avoid that, you need to specify a different build directory, one located
outside the build root. The new directory should be passed as a macro called
BUILDDIR_NAME:

$ cd /path/to/src/ozone
$ gbs build -A i586 --define 'BUILDDIR_NAME /var/tmp/chromium-build'

(Note `/var/tmp/chromium-build` is still a directory inside the chroot, so to
the host system this is actually something like
`/home/user/GBSROOT/local/BUILD-ROOTS/scratch.i586.0/var/tmp/chromium-build`).

In case the build gets broken somehow, one can then just remove whatever is
faulty in the build directory (or the whole directory).

It is important to note that depending on what the .spec file looks like, an
incremental build may still rebuild some files even if nothing has changed: for
example, if patches are applied as part of the %prep stage and they modify some
source files, these ones will always be rebuilt.

This method is not completely fail-proof, though, and a full rebuild may end up
being triggered if:

- Some problem happens in the `gbs build' call and the whole chroot (not only
the RPM build root) ends up being erased.

- You use `gbs chroot' to call `make' yourself, as a simple change in the
original CFLAGS or CXXFLAGS triggers a rebuild of all files.

- You change your source directory name for some reason. This is why
the generated source tarball does not contain a version number, for
example.

FURTHER DETAILS
---------------

gbs, the tool used to generate RPM packages for Tizen, expects a single git
tree with all the necessary sources available so that it can run `git archive',
produce a tarball, extract it into a chroot and build from there.

Chromium, on the other hand, is made of many independent git and Subversion
repositories put together in a single directory structure. Additionally,
Chromium is checked out as a subdirectory of Chromium itself. This all is
unusual and does not work with gbs by default.

The whole problem is worked around by having using git-buildpackage's hooks
mechanism: the original tarball generated by git-buildpackage's call to `git
archive' is replaced by a new one generated with the gbp-flat-tree.sh script
located in packaging/. This new tarball contains everything in src/, except for
a few files we exclude by default (version control files and directories, for
example).

The gbp-flat-tree.sh script also helps us with incremental builds: since the
new tarball is generated with `tar' itself, all the files in the archive have
their correct mtimes (which is not the case with `git archive'). This, together
with an external build directory, allows one to avoid rebuilding all files
every time, since the source files with the right modification times _and_ the
build directory are preserved across builds.
2 changes: 2 additions & 0 deletions packaging/rpm/chromium-browser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
/usr/lib/chromium/chrome --no-sandbox
22 changes: 22 additions & 0 deletions packaging/rpm/chromium-do-not-look-for-gtk2-when-using-aura.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Author: Raphael Kubo da Costa <[email protected]>

Since there is no GTK+2 package for Tizen 2.1 Mobile and we already use Aura
instead of GTK+2 directly, there should be no need to look for GTK+2 at all.

Upstreaming this patch depends on a hard GTK+2 dependency on
remoting/remoting.gyp being removed in chromium. It does not affect crosswalk
because we do not have any dependency on remoting.gyp.

Upstream patch: https://codereview.chromium.org/19531008
Depends on: https://code.google.com/p/chromium/issues/detail?id=247213
--- src/build/linux/system.gyp
+++ src/build/linux/system.gyp
@@ -18,7 +18,7 @@
'linux_link_libbrlapi%': 0,
},
'conditions': [
- [ 'chromeos==0', {
+ [ 'chromeos==0 and toolkit_uses_gtk==1', {
# Hide GTK and related dependencies for Chrome OS, so they won't get
# added back to Chrome OS. Don't try to use GTK on Chrome OS.
'targets': [
34 changes: 34 additions & 0 deletions packaging/rpm/chromium-do-not-run-gn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Author: Joone Hur <[email protected]>

Make is used to build chromium instead of ninja when creating rpm packages using gbs
because depot_tools needs to be copied manually to chroot environment. However,
gyp_chromium still runs GN even if we do not use ninja, which requires Gtk+2, but
Tizen IVI does not provide Gtk+2 packages.

This patch allows only to run GN when ninja is used.

For your information, GN is a meta-build system that generates ninja files.

--- src/build/gyp_chromium
+++ src/build/gyp_chromium
@@ -39,7 +39,8 @@ sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'liblouis'))
sys.path.insert(1, os.path.join(chrome_src, 'third_party', 'WebKit',
'Source', 'build', 'scripts'))

-import find_depot_tools
+if os.environ.get('GYP_GENERATORS') != 'make':
+ import find_depot_tools

# On Windows, Psyco shortens warm runs of build/gyp_chromium by about
# 20 seconds on a z600 machine with 12 GB of RAM, from 90 down to 70
@@ -475,8 +476,9 @@ if __name__ == '__main__':
args.append('--check')

supplemental_includes = GetSupplementalFiles()
- if not RunGN(supplemental_includes):
- sys.exit(1)
+ if os.environ.get('GYP_GENERATORS') != 'make':
+ if not RunGN(supplemental_includes):
+ sys.exit(1)
args.extend(
['-I' + i for i in additional_include_files(supplemental_includes, args)])
5 changes: 5 additions & 0 deletions packaging/rpm/chromium.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<manifest>
<request>
<domain name="_"/>
</request>
</manifest>
212 changes: 212 additions & 0 deletions packaging/rpm/chromium.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
Name: chromium
Version: 34.0.1829.0
Release: 0
Summary: Chromium ozone-wayland
License: BSD-3-Clause
Group: Web Framework/chromium
Url: https://01.org/ozone-wayland
Source: %{name}.tar
Source1: chromium-browser.sh
Source1001: chromium.manifest
Patch1: %{name}-do-not-look-for-gtk2-when-using-aura.patch
Patch2: %{name}-do-not-run-gn.patch

BuildRequires: bison
BuildRequires: bzip2-devel
BuildRequires: expat-devel
BuildRequires: flex
BuildRequires: gperf
BuildRequires: libcap-devel
BuildRequires: python
BuildRequires: python-xml
BuildRequires: perl
BuildRequires: which
BuildRequires: pkgconfig(alsa)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(audio-session-mgr)
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-location-manager)
BuildRequires: pkgconfig(dbus-1)
BuildRequires: pkgconfig(fontconfig)
BuildRequires: pkgconfig(freetype2)
BuildRequires: pkgconfig(gles20)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(haptic)
BuildRequires: pkgconfig(icu-i18n)
BuildRequires: pkgconfig(libdrm)
BuildRequires: pkgconfig(libexif)
BuildRequires: pkgconfig(libpci)
BuildRequires: pkgconfig(libpulse)
BuildRequires: pkgconfig(libudev)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(libxslt)
BuildRequires: pkgconfig(nss)
BuildRequires: pkgconfig(pango)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(pkgmgr-parser)
BuildRequires: pkgconfig(nspr)
BuildRequires: pkgconfig(sensor)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(wayland-client)
BuildRequires: pkgconfig(wayland-cursor)
BuildRequires: pkgconfig(wayland-egl)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(xcomposite)
BuildRequires: pkgconfig(xcursor)
BuildRequires: pkgconfig(xdamage)
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(xfixes)
BuildRequires: pkgconfig(xi)
BuildRequires: pkgconfig(xkbcommon)
BuildRequires: pkgconfig(xrandr)
BuildRequires: pkgconfig(xrender)
BuildRequires: pkgconfig(xscrnsaver)
BuildRequires: pkgconfig(xt)
BuildRequires: pkgconfig(xtst)

%description
# Ozone is a set of classes in Chromium for abstracting different window systems on Linux. It provides abstraction for the construction of accelerated surfaces underlying Aura UI framework, input devices assignment, and event handling.

%prep
%setup -q -n chromium

cp %{SOURCE1001} .

cp -a src/AUTHORS AUTHORS.chromium
cp -a src/LICENSE LICENSE.chromium
cp -a src/ozone/AUTHORS AUTHORS.ozone-wayland
cp -a src/ozone/LICENSE LICENSE.ozone-wayland

%patch1
%patch2

%build

# For ffmpeg on ia32. The original CFLAGS set by the gyp and config files in
# src/third_party/ffmpeg already pass -O2 -fomit-frame-pointer, but Tizen's
# CFLAGS end up appending -fno-omit-frame-pointer. See http://crbug.com/37246
export CFLAGS=`echo $CFLAGS | sed s,-fno-omit-frame-pointer,,g`

# Building the RPM in the GBS chroot fails with errors such as
# /usr/lib/gcc/i586-tizen-linux/4.7/../../../../i586-tizen-linux/bin/ld:
# failed to set dynamic section sizes: Memory exhausted
# For now, work around it by passing a GNU ld-specific flag that optimizes the
# linker for memory usage.
export LDFLAGS="${LDFLAGS} -Wl,--no-keep-memory"

# Support building in a non-standard directory, possibly outside %{_builddir}.
# Since the build root is erased every time a new build is performed, one way
# to avoid losing the build directory is to specify a location outside the
# build root to the BUILDDIR_NAME definition, such as "/var/tmp/chromium-build"
# (remember all paths are still inside the chroot):
# gbs build --define 'BUILDDIR_NAME /some/path'
#
# The --depth and --generator-output combo is used to put all the Makefiles
# inside the build directory, and (this is the important part) keep file lists
# (generatedwith <|() in gyp) in the build directory as well, otherwise they
# will be in the source directory, erased every time and trigger an almost full
# Blink rebuild (among other smaller targets).
# We cannot always pass those flags, though, because gyp's make generator does
# not work if the --generator-output is the top-level source directory.
BUILDDIR_NAME="%{?BUILDDIR_NAME}"
if [ -z "${BUILDDIR_NAME}" ]; then
BUILDDIR_NAME="."
else
GYP_EXTRA_FLAGS="--depth=. --generator-output=${BUILDDIR_NAME}"
fi

# Change src/ so that we can pass "." to --depth below, otherwise we would need
# to pass "src" to it, but this confuses the gyp make generator, that expects
# to be called from the root source directory.
cd src

# --no-parallel is added because chroot does not mount a /dev/shm, this will
# cause python multiprocessing.SemLock error.
#https://github.com/01org/ozone-wayland/issues/147

BUILD_TOOL="%{?BUILD_TOOL}"
if [ -z "${BUILD_TOOL}" ]; then
BUILD_TOOL="make"
else
BUILD_TOOL=${BUILD_TOOL}
PATH=$PATH:/home/abuild/depot_tools
fi

export GYP_GENERATORS=${BUILD_TOOL}
./build/gyp_chromium \
--no-parallel \
-Duse_ash=0 \
-Duse_ozone=1 \
-Dchromeos=0 \
-Ddisable_nacl=1 \
-Dpython_ver=2.7 \
-Duse_aura=1 \
-Duse_cups=0 \
-Duse_gconf=0 \
-Duse_kerberos=0 \
-Duse_system_bzip2=1 \
-Duse_system_icu=0 \
-Duse_system_libexif=1 \
-Duse_system_libxml=1 \
-Duse_system_nspr=1 \
-Denable_xi21_mt=1 \
-Duse_xi2_mt=0 \
-Dtarget_arch=ia32 \
-Duse_alsa=0 \
-Dlogging_like_official_build=1 \
-Dtracing_like_official_build=1 \
-Drelease_unwind_tables=0 \
-Dlinux_dump_symbols=1

%if "${BUILD_TOOL}" == "ninja"
ninja %{?_smp_mflags} -C "${BUILDDIR_NAME}" chrome
%else
make %{?_smp_mflags} -C "${BUILDDIR_NAME}" BUILDTYPE=Release chrome
%endif

%install
# Support building in a non-standard directory, possibly outside %{_builddir}.
# Since the build root is erased every time a new build is performed, one way
# to avoid losing the build directory is to specify a location outside the
# build root to the BUILDDIR_NAME definition, such as "/var/tmp/chromium-build"
# (remember all paths are still inside the chroot):
# gbs build --define 'BUILDDIR_NAME /some/path'
BUILDDIR_NAME="%{?BUILDDIR_NAME}"
if [ -z "${BUILDDIR_NAME}" ]; then
BUILDDIR_NAME="."
fi

# Since BUILDDIR_NAME can be either a relative path or an absolute one, we need
# to cd into src/ so that it means the same thing in the build and install
# stages: during the former, a relative location refers to a place inside src/,
# whereas during the latter a relative location by default would refer to a
# place one directory above src/. If BUILDDIR_NAME is an absolute path, this is
# irrelevant anyway.
cd src

# Binaries.
install -p -D %{SOURCE1} %{buildroot}%{_bindir}/chromium-browser
install -p -D ${BUILDDIR_NAME}/out/Release/chrome %{buildroot}%{_libdir}/chromium/chrome
cp -R ${BUILDDIR_NAME}/out/Release/locales %{buildroot}%{_libdir}/chromium/

# Workaround to avoid eu-strip error.
strip %{buildroot}%{_libdir}/chromium/chrome

# Supporting libraries and resources.
install -p -D ${BUILDDIR_NAME}/out/Release/libffmpegsumo.so %{buildroot}%{_libdir}/chromium/libffmpegsumo.so
strip %{buildroot}%{_libdir}/chromium/libffmpegsumo.so
install -p -D ${BUILDDIR_NAME}/out/Release/resources.pak %{buildroot}%{_libdir}/chromium/resources.pak
install -p -D ${BUILDDIR_NAME}/out/Release/chrome_100_percent.pak %{buildroot}%{_libdir}/chromium/chrome_100_percent.pak
install -p -D ${BUILDDIR_NAME}/out/Release/icudtl.dat %{buildroot}%{_libdir}/chromium/icudtl.dat

%files
%manifest %{name}.manifest
%license AUTHORS.chromium LICENSE.chromium AUTHORS.ozone-wayland LICENSE.ozone-wayland
%{_bindir}/chromium-browser
%{_libdir}/chromium/libffmpegsumo.so
%{_libdir}/chromium/chrome
%{_libdir}/chromium/resources.pak
%{_libdir}/chromium/chrome_100_percent.pak
%{_libdir}/chromium/icudtl.dat
%{_libdir}/chromium/locales/*
10 changes: 10 additions & 0 deletions packaging/rpm/chromium.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns="http://tizen.org/ns/packages" package="chromium" version="@VERSION@" install-location="internal-only">
<label>Chromium Browser</label>
<author href="https://01.org/ozone-wayland">Ozone Wayland Authors</author>
<description>Chromium Browser</description>
<ui-application appid="chromium-browser" exec="/usr/lib/chromium/chrome" nodisplay="false" multiple="false" type="capp" taskmanage="true">
<label>Chromium Browser</label>
<icon>chromium.png</icon>
</ui-application>
</manifest>
Loading

0 comments on commit 35bbb13

Please sign in to comment.