Compare commits
2 Commits
87ea4186d1
...
f9d58f334f
Author | SHA1 | Date | |
---|---|---|---|
f9d58f334f | |||
32c7ec2912 |
38
micobu.sh
38
micobu.sh
@ -4,12 +4,15 @@
|
||||
# ArchLinux root via pacstrap, configured with build tools
|
||||
# User: builduser 1000
|
||||
|
||||
BUILD_BASE='/opt/micobu/rootfs/home/builduser/base'
|
||||
ROOTFS_BASE='/opt/micobu/rootfs'
|
||||
ROOTFS_DIR='/home/builduser/base' # in rootfs
|
||||
ARTEFACT_BASE='/opt/micobu/rootfs/home/builduser/artefacts'
|
||||
BUILD_TIMEOUT='600'
|
||||
API_KEY='mykey'
|
||||
SERVER_PIPE='/var/tmp/micobu_pipe'
|
||||
|
||||
BUILD_BASE=$ROOTFS_BASE$ROOTFS_DIR
|
||||
|
||||
function build() {
|
||||
NAME="$1"
|
||||
REPO="$2"
|
||||
@ -17,7 +20,7 @@ function build() {
|
||||
|
||||
BUILD_DIR="$BUILD_BASE/$NAME"
|
||||
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
|
||||
echo "$NAME revision $HASH has already been built."
|
||||
@ -42,34 +45,22 @@ function build() {
|
||||
git reset --hard
|
||||
git checkout $HASH
|
||||
|
||||
DESCRIPTION="`git describe --all`"
|
||||
DESCRIPTION="`git describe --all --always`"
|
||||
|
||||
mkdir -p $BUILD_BASE/$MICOBU_TEMP_NAME
|
||||
cat <<EOF > $BUILD_BASE/micobu_run.sh
|
||||
#!/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
|
||||
mkdir -p $ARTEFACT_DIR
|
||||
|
||||
echo "[sec] Creating jail"
|
||||
META_DATE_START="`date '+%s'`"
|
||||
set +e
|
||||
set -o pipefail
|
||||
firejail --noprofile --chroot=/opt/micobu-rootfs --net=none --read-write="$BUILD_DIR" env -i HOME=/home/builduser 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=$?
|
||||
set +o pipefail
|
||||
set -e
|
||||
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",
|
||||
"url" : "$REPO",
|
||||
@ -81,11 +72,16 @@ EOF
|
||||
}
|
||||
EOF
|
||||
|
||||
mkdir -p $ARTEFACT_DIR
|
||||
mv -T $BUILD_BASE/$MICOBU_TEMP_NAME $ARTEFACT_DIR
|
||||
cd $BUILD_BASE/$MICOBU_TEMP_NAME
|
||||
if [ "`ls`" == "" ]; then
|
||||
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
|
||||
|
||||
echo ""
|
||||
|
Loading…
Reference in New Issue
Block a user