sh: Execute micobu.sh instead of generating own script
This commit is contained in:
parent
32c7ec2912
commit
f9d58f334f
38
micobu.sh
38
micobu.sh
@ -6,12 +6,13 @@
|
|||||||
|
|
||||||
ROOTFS_BASE='/opt/micobu/rootfs'
|
ROOTFS_BASE='/opt/micobu/rootfs'
|
||||||
ROOTFS_DIR='/home/builduser/base' # in rootfs
|
ROOTFS_DIR='/home/builduser/base' # in rootfs
|
||||||
BUILD_BASE=$ROOTFS_BASE$ROOTFS_DIR
|
|
||||||
ARTEFACT_BASE='/opt/micobu/rootfs/home/builduser/artefacts'
|
ARTEFACT_BASE='/opt/micobu/rootfs/home/builduser/artefacts'
|
||||||
BUILD_TIMEOUT='600'
|
BUILD_TIMEOUT='600'
|
||||||
API_KEY='mykey'
|
API_KEY='mykey'
|
||||||
SERVER_PIPE='/var/tmp/micobu_pipe'
|
SERVER_PIPE='/var/tmp/micobu_pipe'
|
||||||
|
|
||||||
|
BUILD_BASE=$ROOTFS_BASE$ROOTFS_DIR
|
||||||
|
|
||||||
function build() {
|
function build() {
|
||||||
NAME="$1"
|
NAME="$1"
|
||||||
REPO="$2"
|
REPO="$2"
|
||||||
@ -19,7 +20,7 @@ function build() {
|
|||||||
|
|
||||||
BUILD_DIR="$BUILD_BASE/$NAME"
|
BUILD_DIR="$BUILD_BASE/$NAME"
|
||||||
ARTEFACT_DIR="$ARTEFACT_BASE/$NAME/$HASH"
|
ARTEFACT_DIR="$ARTEFACT_BASE/$NAME/$HASH"
|
||||||
MICOBU_TEMP_NAME="micobu_$NAME_$HASH" # Relative to $BUILD_BASE
|
MICOBU_TEMP_NAME="$NAME/micobu_$HASH" # Relative to $BUILD_BASE
|
||||||
|
|
||||||
if [ -d "$ARTEFACT_DIR" ]; then
|
if [ -d "$ARTEFACT_DIR" ]; then
|
||||||
echo "$NAME revision $HASH has already been built."
|
echo "$NAME revision $HASH has already been built."
|
||||||
@ -44,34 +45,22 @@ function build() {
|
|||||||
git reset --hard
|
git reset --hard
|
||||||
git checkout $HASH
|
git checkout $HASH
|
||||||
|
|
||||||
DESCRIPTION="`git describe --all`"
|
DESCRIPTION="`git describe --all --always`"
|
||||||
|
|
||||||
mkdir -p $BUILD_BASE/$MICOBU_TEMP_NAME
|
mkdir -p $BUILD_BASE/$MICOBU_TEMP_NAME
|
||||||
cat <<EOF > $BUILD_BASE/micobu_run.sh
|
mkdir -p $ARTEFACT_DIR
|
||||||
#!/bin/bash
|
|
||||||
cd ~/$NAME
|
|
||||||
./run.py --no-color
|
|
||||||
RET=\$?
|
|
||||||
|
|
||||||
cd vunit_out/test_output
|
|
||||||
tar cvJf ~/$MICOBU_TEMP_NAME/artefacts.tar.xz *
|
|
||||||
|
|
||||||
exit \$RET
|
|
||||||
EOF
|
|
||||||
chmod +x $BUILD_BASE/micobu_run.sh
|
|
||||||
|
|
||||||
echo "[sec] Creating jail"
|
echo "[sec] Creating jail"
|
||||||
META_DATE_START="`date '+%s'`"
|
META_DATE_START="`date '+%s'`"
|
||||||
set +e
|
set +e
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
firejail --noprofile --chroot=$ROOTFS_BASE --net=none --read-write="$BUILD_BASE" env -i HOME=$ROOTFS_DIR PATH=/bin:/usr/bin "bash" "-c" "timeout $BUILD_TIMEOUT ~/micobu_run.sh" | tee $BUILD_BASE/$MICOBU_TEMP_NAME/log.txt
|
firejail --noprofile --chroot=$ROOTFS_BASE --net=none --read-write="$BUILD_BASE/" env -i HOME=$ROOTFS_DIR/$NAME PATH=/bin:/usr/bin MCB_NAME=$NAME MCB_ARTEFACTS=$ROOTFS_DIR/$MICOBU_TEMP_NAME "bash" "-c" "cd ~; timeout $BUILD_TIMEOUT ~/micobu.sh" | tee $ARTEFACT_DIR/log.txt
|
||||||
RET=$?
|
RET=$?
|
||||||
set +o pipefail
|
set +o pipefail
|
||||||
set -e
|
set -e
|
||||||
META_DATE_STOP="`date '+%s'`"
|
META_DATE_STOP="`date '+%s'`"
|
||||||
rm $BUILD_BASE/micobu_run.sh
|
|
||||||
|
|
||||||
cat <<EOF > $BUILD_BASE/$MICOBU_TEMP_NAME/meta.json
|
cat <<EOF > $ARTEFACT_DIR/meta.json
|
||||||
{
|
{
|
||||||
"name" : "$NAME",
|
"name" : "$NAME",
|
||||||
"url" : "$REPO",
|
"url" : "$REPO",
|
||||||
@ -83,11 +72,16 @@ EOF
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mkdir -p $ARTEFACT_DIR
|
cd $BUILD_BASE/$MICOBU_TEMP_NAME
|
||||||
mv -T $BUILD_BASE/$MICOBU_TEMP_NAME $ARTEFACT_DIR
|
if [ "`ls`" == "" ]; then
|
||||||
echo "Stored artefacts in $ARTEFACT_DIR"
|
echo "No artefacts generated."
|
||||||
|
else
|
||||||
|
tar cvJf $ARTEFACT_DIR/artefacts.tar.xz *
|
||||||
|
echo "Stored artefacts in $ARTEFACT_DIR"
|
||||||
|
find $ARTEFACT_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
find $ARTEFACT_BASE
|
cd $ARTEFACT_DIR
|
||||||
cat $ARTEFACT_DIR/meta.json
|
cat $ARTEFACT_DIR/meta.json
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
Loading…
Reference in New Issue
Block a user