Merge "docs/install-instr: Fix git clone URL for HTTPS."
[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 write_gitinfo() {
14     git_url=$(git config --get remote.origin.url)
15     git_rev=$(git rev-parse HEAD)
16     echo "$git_url: $git_rev"
17 }
18
19 if [ $# -eq 0 ]; then
20     OUTPUT_DIR=$(pwd)
21 else
22     OUTPUT_DIR=$(readlink -f $1)
23     shift
24 fi
25
26 mkdir -p $OUTPUT_DIR || error_exit "Could not create directory $OUTPUT_DIR"
27
28 echo "Building armband, output dir: $OUTPUT_DIR"
29 cd ..
30
31 SCRIPT_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
32 BUILD_BASE="${SCRIPT_DIR}/upstream/fuel/build"
33 RESULT_DIR="${BUILD_BASE}/release"
34
35 make REVSTATE="${OPNFV_ARTIFACT_VERSION}" release ||
36     error_exit "Make release failed"
37
38 write_gitinfo >> ${BUILD_BASE}/gitinfo_armband.txt
39
40 echo "Moving results to $OUTPUT_DIR"
41 sort ${BUILD_BASE}/gitinfo*.txt > ${OUTPUT_DIR}/gitinfo.txt
42 mv ${RESULT_DIR}/*.iso ${OUTPUT_DIR}/
43 mv ${RESULT_DIR}/*.iso.txt ${OUTPUT_DIR}/
44
45 # We need to build our own ODL plugin, and when this happens, fuel
46 # renames the iso to unofficial-opnfv-${REVSTATE}.iso, so here we remove
47 # the prefix:
48 pushd ${OUTPUT_DIR} > /dev/null
49 rename 's/^unofficial-//' *.iso
50 rename 's/^unofficial-//' *.iso.txt
51 popd > /dev/null