|
| 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