aboutsummaryrefslogtreecommitdiff
path: root/node/build
blob: 181d9464126a382d68688ae73e0a75d5e8eb7d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

###############################################################################
# Copyright (c) 2011 Linaro
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
###############################################################################

set -xe

umount build/out || true
umount build || true
rm -rf build
mkdir build

ROOT=$(readlink "$(dirname "${0}")")

mem_total=`cat /proc/meminfo | grep MemTotal | sed -s 's/[^0-9]*\([0-9]*\) kB/\1/'`
if [ "14680064" \< "$mem_total" ]
then
  echo using 10G tmpfs for build
  mount -t tmpfs -o size=10G tmpfs build
elif [ "10485760" \< "$mem_total" ]
then
  echo using 6G tmpfs for build/out
  mkdir build/out
  mount -t tmpfs -o size=6G tmpfs build/out
else
  mkdir build/out
fi

chown jenkins-build:nogroup build
cd build
sudo -H -u jenkins-build bash -xes "${ROOT}" "$@" <<\EOF
ROOT="${1}"
shift
SCRIPT_NAME="$(echo "${2}" | base64 -id | sed -n -e 's%SCRIPT_NAME=\([^/]\+\)%\1%p')"
if [ -z "${SCRIPT_NAME}" ]; then
  SCRIPT_NAME=build-android
fi
exec bash -xe "${ROOT}/${SCRIPT_NAME}" "$@"
EOF