#!/bin/sh # # Copyright 2015 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -eu # This script bootstraps building a Bazel binary without Bazel then # use this compiled Bazel to bootstrap Bazel itself. It can also # be provided with a previous version of Bazel to bootstrap Bazel # itself. global WORKDIR := $[pwd] global OUT := $1 global EMBEDDED_TOOLS := $2 global DEPLOY_JAR := $3 global INSTALL_BASE_KEY := $4 shift 4 global TMP_DIR := $(TMPDIR:-/tmp) global PACKAGE_DIR := $[mktemp -d $(TMP_DIR%%/)/bazel.XXXXXXXX] mkdir -p $(PACKAGE_DIR) trap "rm -fr $(PACKAGE_DIR)" EXIT cp $ifsjoin(Argv) $(PACKAGE_DIR) cp $(DEPLOY_JAR) $(PACKAGE_DIR)/A-server.jar cp $(INSTALL_BASE_KEY) $(PACKAGE_DIR)/install_base_key # The timestamp of embedded tools should already be zeroed out in the input zip touch -t 198001010000.00 $(PACKAGE_DIR)/* if test -n $(EMBEDDED_TOOLS) { mkdir $(PACKAGE_DIR)/embedded_tools shell {cd $(PACKAGE_DIR)/embedded_tools && unzip -q $(WORKDIR)/$(EMBEDDED_TOOLS)} } shell {cd $(PACKAGE_DIR) && find . -type f | sort | zip -qDX@ $(WORKDIR)/$(OUT)} (CommandList children: [ (C {(set)} {(-eu)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:WORKDIR) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [65 67] ) } spids: [64] ) ] spids: [64] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:OUT) op:Equal rhs:{($ VSub_Number "$1")} spids:[69])] spids: [69] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:EMBEDDED_TOOLS) op: Equal rhs: {($ VSub_Number "$2")} spids: [72] ) ] spids: [72] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DEPLOY_JAR) op: Equal rhs: {($ VSub_Number "$3")} spids: [75] ) ] spids: [75] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:INSTALL_BASE_KEY) op: Equal rhs: {($ VSub_Number "$4")} spids: [78] ) ] spids: [78] ) (C {(shift)} {(4)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TMP_DIR) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VTest_ColonHyphen arg_word:{(Lit_Slash /) (tmp)}) spids: [87 92] ) } spids: [86] ) ] spids: [86] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PACKAGE_DIR) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(mktemp)} {(-d)} { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_DPercent arg_word:{(Lit_Slash /)}) spids: [101 105] ) (/bazel.XXXXXXXX) } ) ] ) left_token: spids: [96 107] ) ) } spids: [94] ) ] spids: [94] ) (C {(mkdir)} {(-p)} {(DQ (${ VSub_Name PACKAGE_DIR))}) (C {(trap)} {(DQ ("rm -fr ") (${ VSub_Name PACKAGE_DIR))} {(EXIT)}) (C {(cp)} {($ VSub_Star "$*")} {(${ VSub_Name PACKAGE_DIR)}) (C {(cp)} {(${ VSub_Name DEPLOY_JAR)} {(${ VSub_Name PACKAGE_DIR) (/A-server.jar)}) (C {(cp)} {(${ VSub_Name INSTALL_BASE_KEY)} {(${ VSub_Name PACKAGE_DIR) (/install_base_key)}) (C {(touch)} {(-t)} {(198001010000.00)} {(${ VSub_Name PACKAGE_DIR) (/) (Lit_Other "*")}) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(-n)} {(DQ (${ VSub_Name EMBEDDED_TOOLS))} {(Lit_Other "]")}) terminator: ) ] action: [ (C {(mkdir)} {(${ VSub_Name PACKAGE_DIR) (/embedded_tools)}) (Subshell child: (AndOr children: [ (C {(cd)} {(${ VSub_Name PACKAGE_DIR) (/embedded_tools)}) (C {(unzip)} {(-q)} {(${ VSub_Name WORKDIR) (/) (${ VSub_Name EMBEDDED_TOOLS)}) ] op_id: Op_DAmp ) spids: [204 225] ) ] spids: [-1 193] ) ] spids: [-1 227] ) (Subshell child: (AndOr children: [ (C {(cd)} {(${ VSub_Name PACKAGE_DIR)}) (Pipeline children: [ (C {(find)} {(.)} {(-type)} {(f)}) (C {(sort)}) (C {(zip)} {(-qDX) (Lit_Other "@")} {(${ VSub_Name WORKDIR) (/) (${ VSub_Name OUT)}) ] negated: False ) ] op_id: Op_DAmp ) spids: [230 265] ) ] )