4f8aee5aa0c9570c2999487d39cf36afe0f0c2ae
[platform/framework/web/crosswalk.git] / src / xwalk / packaging / gbp-flat-tree.sh
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 TAR_FILE="${GBP_TMP_DIR}/crosswalk.tar"
32
33 if [ ! -f "${TAR_FILE}" ]; then
34     echo "${TAR_FILE} does not exist. Aborting."
35     exit 1
36 fi
37
38 # The top-level directory that _contains_ src/.
39 BASE_SRC_DIR=`readlink -f "${GBP_GIT_DIR}/../../.."`
40 if [ $? -ne 0 ]; then
41     echo "${GBP_GIT_DIR}/../../.. does not seem to be a valid path. Aborting."
42     exit 1
43 fi
44
45 # Erase the archive generated with `git archive'.
46 rm -v "${TAR_FILE}"
47
48 echo "Creating a new ${TAR_FILE} from ${BASE_SRC_DIR}/src"
49
50 # The --transform parameter is used to prepend all archive members with
51 # crosswalk/ so they all share a common root. Note it is crosswalk/, without
52 # any version numbers, so that any build files in an external directory
53 # referring to a source file does not need to be updated just because of a
54 # version bump.
55 tar --update --file "${TAR_FILE}" \
56     --exclude-vcs --exclude=LayoutTests \
57     --exclude=src/out --directory="${BASE_SRC_DIR}" \
58     --transform="s:^:crosswalk/:S" \
59     src