Skip to content

Commit 91b8b1d

Browse files
author
Raphael Kubo da Costa
committed
[Packaging] Introduce gbp-flat-tree.sh to simplify the Tizen build process.
TL;DR: one can simply do the following to build an RPM: cd /path/to/src/xwalk gbs build -A i586 We can get rid of the need for a separate git tree and the generate-flat-tree.sh script by relying on the hooks provided by git-buildpackage: the postexport hook that we use is called right after the git repository's sources have been exported with `git archive`. In this hook, we execute a new script, `gbp-flat-tree.sh`. It does pretty much the same thing as generate-flat-script.sh, but automatically. That is, it removes the tarball generated by `git archive` (since gbs build should be called from xwalk/, it would only contain Crosswalk's contents anyway) and replaces it with a new one with the contents of src/. Since it is called at a stage in the whole build process that immediately precedes the call to `/usr/bin/build`, we do not need to keep a separate flat git tree with all our sources anymore; we are effectively bypassing git-buildpackage's default export mechanism. The downside of this approach (which is shared by the previous one with `generate-flat-tree.sh`, anyway) is that all files in src/ are archived, even if they are not part of any commit. In other words, we end up acting as if "--include-all" was always passed to `gbs build`. (Fun fact: the whole dance of calling `gclient recursive` twice with different arguments and everything was unnecessary; one of the entries reported by those calls is src/ itself, so we always ended up archiving everything under it)
1 parent 38ba561 commit 91b8b1d

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.gbp.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# For more information about this file, see git-buildpackage's documentation.
2+
# It is used by gbs in order to build Crosswalk packages for Tizen.
3+
4+
[DEFAULT]
5+
# This postexport hook is used to replace the default crosswalk.tar file
6+
# generated with `git archive' (and which only contains the contents of
7+
# crosswalk.git) with a full-blown tar file that contains all source code
8+
# required to build Crosswalk. Additionally, the new tar file's members all
9+
# contain their original mtimes, which is helpful if one wants to try an
10+
# incremental Tizen build. The script is run from the temporary directory
11+
# containing the contents of packaging/ that are used by git-buildpackage.
12+
postexport = ./gbp-flat-tree.sh

packaging/gbp-flat-tree.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) 2013 Intel Corporation. All rights reserved.
4+
# Use of this source code is governed by a BSD-style license that can be
5+
# found in the LICENSE file.
6+
7+
# This script is expected to be run by `git-buildpackage' (called by `gbs
8+
# build') as a postexport hook. Its purpose is to remove the tar file generated
9+
# by `gbs export' with `git archive' and create a new archive with tar itself.
10+
#
11+
# It is helpful in two ways:
12+
# - It automates the generation of a proper archive for RPM builds so that one
13+
# does not need to create a separate git tree with all sources for `gbs
14+
# build' to work.
15+
# - Since tar is used, the archive's members all have their actual mtimes as
16+
# opposed to the time of the git tree-ish passed to `git archive'. This is
17+
# part of the solution for incremental builds in Tizen: since we use actual
18+
# file mtimes, they are not rebuilt by `make'.
19+
#
20+
# As a postexport hook, there are two additional environment variables
21+
# available: GBP_GIT_DIR is /path/to/src/xwalk/.git, and GBP_TMP_DIR is the
22+
# temporary directory containing everything in /path/to/src/xwalk/packaging
23+
# that will be copied to $GBSROOT/local/sources and used by `rpmbuild' to build
24+
# an RPM package.
25+
#
26+
# The script is run from GBP_TMP_DIR.
27+
28+
# Fail early to avoid bigger problems later in the process.
29+
set -e
30+
31+
VERSION_NUMBER=`awk '/^Version:/ { print $2 }' crosswalk.spec`
32+
TAR_FILE="${GBP_TMP_DIR}/crosswalk-${VERSION_NUMBER}.tar"
33+
34+
if [ ! -f "${TAR_FILE}" ]; then
35+
echo "${TAR_FILE} does not exist. Aborting."
36+
exit 1
37+
fi
38+
39+
# The top-level directory that _contains_ src/.
40+
BASE_SRC_DIR=`readlink -f "${GBP_GIT_DIR}/../../.."`
41+
if [ $? -ne 0 ]; then
42+
echo "${GBP_GIT_DIR}/../../.. does not seem to be a valid path. Aborting."
43+
exit 1
44+
fi
45+
46+
# Erase the archive generated with `git archive'.
47+
rm -v "${TAR_FILE}"
48+
49+
echo "Creating a new ${TAR_FILE} from ${BASE_SRC_DIR}/src"
50+
51+
# The --transform parameter is used to prepend all archive members with
52+
# crosswalk/ so they all share a common root. Note it is crosswalk/, without
53+
# any version numbers, so that any build files in an external directory
54+
# referring to a source file does not need to be updated just because of a
55+
# version bump.
56+
tar --update --file "${TAR_FILE}" \
57+
--exclude-vcs --exclude=native_client --exclude=LayoutTests \
58+
--exclude=src/out --directory="${BASE_SRC_DIR}" \
59+
--transform="s:^:crosswalk-${VERSION_NUMBER}/:S" \
60+
src

0 commit comments

Comments
 (0)