mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2026-01-27 18:22:13 +00:00
Initial simple autobuilder.
This commit is contained in:
81
tools/autobuild/build.sh
Executable file
81
tools/autobuild/build.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
############################################################
|
||||
set -e
|
||||
|
||||
AUTOBUILD_SCRIPT="$(realpath ${BASH_SOURCE[0]})"
|
||||
ONL="$(realpath $(dirname $AUTOBUILD_SCRIPT)/../../)"
|
||||
|
||||
|
||||
# Default build branch
|
||||
BUILD_BRANCH=master
|
||||
|
||||
while getopts ":b:v78" opt; do
|
||||
case $opt in
|
||||
7)
|
||||
ONLB_OPTIONS=--7
|
||||
if [ -z "$DOCKER_IMAGE" ]; then
|
||||
echo "Selecting Debian 7 build..."
|
||||
fi
|
||||
;;
|
||||
8)
|
||||
ONLB_OPTIONS=--8
|
||||
if [ -z "$DOCKER_IMAGE" ]; then
|
||||
echo "Selecting Debian 8 build..."
|
||||
fi
|
||||
;;
|
||||
b)
|
||||
BUILD_BRANCH=$OPTARG
|
||||
;;
|
||||
v)
|
||||
set -x
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$ONLB_OPTIONS" ]; then
|
||||
# Build both suites
|
||||
$AUTOBUILD_SCRIPT --7 $@
|
||||
$AUTOBUILD_SCRIPT --8 $@
|
||||
exit $?
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Restart under correct builder environment.
|
||||
#
|
||||
if [ -z "$DOCKER_IMAGE" ]; then
|
||||
# Execute ourselves under the builder
|
||||
ONLB=/usr/local/bin/onlbuilder
|
||||
if [ -x $ONLB ]; then
|
||||
$ONLB $ONLB_OPTIONS --isolate $ONL --non-interactive -c $AUTOBUILD_SCRIPT $@
|
||||
exit $?
|
||||
else
|
||||
echo "Not running in a docker workspace and the onlbuilder script is not available."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Now running under $DOCKER_IMAGE..."
|
||||
|
||||
|
||||
# The expectation is that we will already be on the required branch.
|
||||
# This is to normalize environments where the checkout might instead
|
||||
# be in a detached head (like jenkins)
|
||||
echo "Switching to branch $BUILD_BRANCH..."
|
||||
cd $ONL && git checkout $BUILD_BRANCH
|
||||
|
||||
|
||||
#
|
||||
# Full build
|
||||
#
|
||||
cd $ONL
|
||||
. setup.env
|
||||
|
||||
if false && make all; then
|
||||
echo Build Failed.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo Build Succeeded.
|
||||
86
tools/autobuild/install.sh
Executable file
86
tools/autobuild/install.sh
Executable file
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
############################################################
|
||||
set -e
|
||||
|
||||
ONL="$(realpath $(dirname $BASH_SOURCE[0])/../../)"
|
||||
|
||||
BUILD_BRANCH=${BUILD_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}
|
||||
|
||||
#
|
||||
# Release artifacts can be automatically installed on a remote server
|
||||
# after the build is completed.
|
||||
#
|
||||
|
||||
# Remote server name
|
||||
REMOTE_SERVER=
|
||||
|
||||
# Path on the remote server for builds.
|
||||
# The final build artifacts will reside in $INSTALL_BASE_DIR/$BUILD_BRANCH/$BUILD_ID
|
||||
REMOTE_BASE_DIR=
|
||||
|
||||
# The remote user for RSYNC
|
||||
REMOTE_USER=
|
||||
|
||||
# The remote password for RSYNC
|
||||
REMOTE_PASS=
|
||||
|
||||
while getopts ":s:d:u:p:b:t:v" opt; do
|
||||
case $opt in
|
||||
s)
|
||||
REMOTE_SERVER=$OPTARG
|
||||
;;
|
||||
d)
|
||||
REMOTE_BASE_DIR=$OPTARG
|
||||
;;
|
||||
u)
|
||||
REMOTE_USER=$OPTARG
|
||||
;;
|
||||
p)
|
||||
REMOTE_PASS=$OPTARG
|
||||
;;
|
||||
b)
|
||||
BUILD_BRANCH=$OPTARG
|
||||
;;
|
||||
v)
|
||||
set -x
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
if [ -z "$REMOTE_SERVER" ]; then
|
||||
echo "Remote instlallation requires a server (-s)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$REMOTE_BASE_DIR" ]; then
|
||||
echo "Remote installation requires a branch directory (-d)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$REMOTE_USER" ]; then
|
||||
echo "Remote installation requires a remote user (-u)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$REMOTE_PASS" ]; then
|
||||
echo "Remote installation requires a remote password (-p)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
. $ONL/make/version-onl.sh
|
||||
REMOTE_DIR="$REMOTE_BASE_DIR/$BUILD_BRANCH/$FNAME_BUILD_ID"
|
||||
|
||||
|
||||
RSYNC=rsync
|
||||
RSYNC_OPTS=" -v --copy-links --delete -a"
|
||||
|
||||
_rsync() {
|
||||
$RSYNC $RSYNC_OPTS --rsh="sshpass -p $REMOTE_PASS ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l $REMOTE_USER" $1 $2
|
||||
}
|
||||
|
||||
sshpass -p $REMOTE_PASS ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l $REMOTE_USER $REMOTE_SERVER mkdir -p $REMOTE_DIR
|
||||
_rsync $ONL/RELEASE/* $REMOTE_SERVER:$REMOTE_DIR
|
||||
|
||||
make -C $ONL/REPO build-clean
|
||||
_rsync $ONL/REPO $REMOTE_SERVER:$REMOTE_DIR
|
||||
9
tools/autobuild/run.sh
Executable file
9
tools/autobuild/run.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
############################################################
|
||||
set -e
|
||||
|
||||
PARENT_DIR="$(realpath $(dirname $BASH_SOURCE[0]))"
|
||||
cd $PARENT_DIR
|
||||
|
||||
./build.sh $@
|
||||
./install.sh $@
|
||||
Reference in New Issue
Block a user