build.sh: do not use readlink for unexisting dir
[armband.git] / ci / build.sh
1 #!/bin/bash
2 # Copyright (c) 2016 Enea Software AB
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
7
8 error_exit() {
9     echo "$@" >&2
10     exit 1
11 }
12
13 if [ $# -eq 0 ]; then
14     OUTPUT_DIR=$(pwd)
15 else
16     OUTPUT_DIR=$(readlink -f $1)
17     shift
18 fi
19
20 mkdir -p $OUTPUT_DIR || error_exit "Could not create directory $OUTPUT_DIR"
21
22 echo "Building armband, output dir: $OUTPUT_DIR"
23 cd ..
24
25 SCRIPT_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
26 BUILD_BASE="${SCRIPT_DIR}/upstream/fuel/build/"
27 RESULT_DIR="${BUILD_BASE}/release"
28
29 make release || error_exit "Make release failed"
30
31 echo "Copying results to $OUTPUT_DIR"
32 sort ${BUILD_BASE}/gitinfo*.txt > ${OUTPUT_DIR}/gitinfo.txt
33 cp ${RESULT_DIR}/*.iso ${OUTPUT_DIR}/
34 cp ${RESULT_DIR}/*.iso.txt ${OUTPUT_DIR}/