Compare commits
No commits in common. "f9d58f334f1201fb25d05e2fe0ec738063a432c2" and "87ea4186d189e9612b2e4b9c868e3ca4fbe8dcbd" have entirely different histories.
f9d58f334f
...
87ea4186d1
38
micobu.sh
38
micobu.sh
@ -4,15 +4,12 @@
|
|||||||
# ArchLinux root via pacstrap, configured with build tools
|
# ArchLinux root via pacstrap, configured with build tools
|
||||||
# User: builduser 1000
|
# User: builduser 1000
|
||||||
|
|
||||||
ROOTFS_BASE='/opt/micobu/rootfs'
|
BUILD_BASE='/opt/micobu/rootfs/home/builduser/base'
|
||||||
ROOTFS_DIR='/home/builduser/base' # in rootfs
|
|
||||||
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"
|
||||||
@ -20,7 +17,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="$NAME/micobu_$HASH" # Relative to $BUILD_BASE
|
MICOBU_TEMP_NAME="micobu_$NAME_$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."
|
||||||
@ -45,22 +42,34 @@ function build() {
|
|||||||
git reset --hard
|
git reset --hard
|
||||||
git checkout $HASH
|
git checkout $HASH
|
||||||
|
|
||||||
DESCRIPTION="`git describe --all --always`"
|
DESCRIPTION="`git describe --all`"
|
||||||
|
|
||||||
mkdir -p $BUILD_BASE/$MICOBU_TEMP_NAME
|
mkdir -p $BUILD_BASE/$MICOBU_TEMP_NAME
|
||||||
mkdir -p $ARTEFACT_DIR
|
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
|
||||||
|
|
||||||
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/$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
|
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
|
||||||
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 > $ARTEFACT_DIR/meta.json
|
cat <<EOF > $BUILD_BASE/$MICOBU_TEMP_NAME/meta.json
|
||||||
{
|
{
|
||||||
"name" : "$NAME",
|
"name" : "$NAME",
|
||||||
"url" : "$REPO",
|
"url" : "$REPO",
|
||||||
@ -72,16 +81,11 @@ function build() {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cd $BUILD_BASE/$MICOBU_TEMP_NAME
|
mkdir -p $ARTEFACT_DIR
|
||||||
if [ "`ls`" == "" ]; then
|
mv -T $BUILD_BASE/$MICOBU_TEMP_NAME $ARTEFACT_DIR
|
||||||
echo "No artefacts generated."
|
|
||||||
else
|
|
||||||
tar cvJf $ARTEFACT_DIR/artefacts.tar.xz *
|
|
||||||
echo "Stored artefacts in $ARTEFACT_DIR"
|
echo "Stored artefacts in $ARTEFACT_DIR"
|
||||||
find $ARTEFACT_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd $ARTEFACT_DIR
|
find $ARTEFACT_BASE
|
||||||
cat $ARTEFACT_DIR/meta.json
|
cat $ARTEFACT_DIR/meta.json
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
Loading…
Reference in New Issue
Block a user