blob: 9a10f0cd41e1eaeed4f9cca02ab15aae05e16de6 [file] [log] [blame]
Philipp Wollermanna5afe952016-06-21 14:58:09 +00001#!/bin/sh
Lukacs Berkieb851fe2015-10-19 10:52:31 +00002#
3# Copyright 2015 The Bazel Authors. All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Philipp Wollermanna5afe952016-06-21 14:58:09 +000017set -eu
18
Lukacs Berkieb851fe2015-10-19 10:52:31 +000019# This script bootstraps building a Bazel binary without Bazel then
20# use this compiled Bazel to bootstrap Bazel itself. It can also
21# be provided with a previous version of Bazel to bootstrap Bazel
22# itself.
23
24WORKDIR=$(pwd)
25OUT=$1
26EMBEDDED_TOOLS=$2
27DEPLOY_JAR=$3
28INSTALL_BASE_KEY=$4
29shift 4
30
31TMP_DIR=${TMPDIR:-/tmp}
32PACKAGE_DIR="$(mktemp -d ${TMP_DIR%%/}/bazel.XXXXXXXX)"
33mkdir -p "${PACKAGE_DIR}"
34trap "rm -fr ${PACKAGE_DIR}" EXIT
35
36cp $* ${PACKAGE_DIR}
37cp ${DEPLOY_JAR} ${PACKAGE_DIR}/A-server.jar
38cp ${INSTALL_BASE_KEY} ${PACKAGE_DIR}/install_base_key
39# The timestamp of embedded tools should already be zeroed out in the input zip
40touch -t 198001010000.00 ${PACKAGE_DIR}/*
41
Klaus Aehlig25719822016-06-14 08:45:44 +000042if [ -n "${EMBEDDED_TOOLS}" ]; then
Lukacs Berkieb851fe2015-10-19 10:52:31 +000043 mkdir ${PACKAGE_DIR}/embedded_tools
44 (cd ${PACKAGE_DIR}/embedded_tools && unzip -q ${WORKDIR}/${EMBEDDED_TOOLS})
45fi
46
Lukacs Berkic4e74d12015-11-10 15:28:00 +000047(cd ${PACKAGE_DIR} && find . -type f | sort | zip -qDX@ ${WORKDIR}/${OUT})