aboutsummaryrefslogtreecommitdiffstats
path: root/ci/build.sh
blob: 38be2547b17868e36a6eccce0b443a0abccaaddd (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
45
46
47
48
49
50
51
#!/bin/bash
# Copyright (c) 2016 Enea Software AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0

error_exit() {
    echo "$@" >&2
    exit 1
}

write_gitinfo() {
    git_url=$(git config --get remote.origin.url)
    git_rev=$(git rev-parse HEAD)
    echo "$git_url: $git_rev"
}

if [ $# -eq 0 ]; then
    OUTPUT_DIR=$(pwd)
else
    OUTPUT_DIR=$(readlink -f $1)
    shift
fi

mkdir -p $OUTPUT_DIR || error_exit "Could not create directory $OUTPUT_DIR"

echo "Building armband, output dir: $OUTPUT_DIR"
cd ..

SCRIPT_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
BUILD_BASE="${SCRIPT_DIR}/upstream/fuel/build"
RESULT_DIR="${BUILD_BASE}/release"

make REVSTATE="${OPNFV_ARTIFACT_VERSION}" release ||
    error_exit "Make release failed"

write_gitinfo >> ${BUILD_BASE}/gitinfo_armband.txt

echo "Copying results to $OUTPUT_DIR"
sort ${BUILD_BASE}/gitinfo*.txt > ${OUTPUT_DIR}/gitinfo.txt
cp ${RESULT_DIR}/*.iso ${OUTPUT_DIR}/
cp ${RESULT_DIR}/*.iso.txt ${OUTPUT_DIR}/

# We need to build our own ODL plugin, and when this happens, fuel
# renames the iso to unofficial-opnfv-${REVSTATE}.iso, so here we remove
# the prefix:
pushd ${OUTPUT_DIR} > /dev/null
rename 's/^unofficial-//' *.iso
rename 's/^unofficial-//' *.iso.txt
popd > /dev/null