Vitaly Shaburov
#!/bin/bash
BLD_PARALLEL="4"
WORKSPACE=/export/home/admin/du2
#STOP_ON_ERROR=1
STOP_ON_ERROR=0
#GCC_COMPILER="gcc-6"
GCC_COMPILER=""
# Build a component: $1 - component name, $2 - stop-on-error flag
function build_component {
local START_TIME
local END_TIME
local BLD_RESULT
BLD_RESULT="/data/repo/du/$1"
test -z "$1" && exit 1
test -d ${BLD_RESULT} && rm -rf ${BLD_RESULT}
DEB_BUILD_OPTIONS="nocheck notest parallel=${BLD_PARALLEL}"
export DEB_BUILD_OPTIONS
test -d ${WORKSPACE}/$1 && rm -rf ${WORKSPACE}/$1
mkdir -p ${WORKSPACE}/$1
cd ${WORKSPACE}/$1
START_TIME=$(date +%s)
echo "====================== $1 ======================" | tee berror.log
if [[ $2 -eq 0 ]]; then
apt-get build-dep -y $1 >> berror.log || return 0 2>&1
apt-get source --compile $1 >> berror.log || return 0 2>&1
else
apt-get build-dep -y $1 >> berror.log || return 1 2>&1
apt-get source --compile $1 >> berror.log || return 1 2>&1
fi
END_TIME=$(date +%s)
printf "%06d %s\n" $(($END_TIME - $START_TIME)) $1 >> ${WORKSPACE}/tmpbt.log
mkdir -p ${BLD_RESULT}
cp -ax *.deb ${BLD_RESULT}/ || exit 1
cp -ax *.changes ${BLD_RESULT}/ || exit 1
cp -ax *.buildinfo ${BLD_RESULT}/ || exit 1
}
if [[ "$GCC_COMPILER" != "" ]]; then
echo "====================== Building GCC ======================"
build_component $GCC_COMPILER 1
if [[ $? -eq 1 ]]; then
exit 1
fi
dpkg -i $WORKSPACE/$GCC_COMPILER/*.deb
fi
if [[ ! -f $WORKSPACE/build_components ]]; then
cp /data/repo/pkg/list_component $WORKSPACE/build_components
fi
rm -f tmpbt.log
while read COMP; do
if [[ "" == "$COMP" ]] || [[ "$GCC_COMPILER" == "$COMP" ]]; then
continue
fi
build_component $COMP $STOP_ON_ERROR
if [[ $? -eq 1 ]]; then
exit 1
fi
done < $WORKSPACE/build_components
sort tmpbt.log > build_components
sed -i 's/^[0-9]* //g' build_components
{"serverDuration": 10, "requestCorrelationId": "a5ceb4b9a7e849349c8cd76a23db09d7"}