mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-19 07:06:30 +00:00
initial import build-scripts
This commit is contained in:
parent
65b124f99e
commit
17dd76a8d0
23
build-scripts/README.md
Normal file
23
build-scripts/README.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Build Server
|
||||||
|
|
||||||
|
You need a linux with [AUFS](https://docs.docker.com/engine/userguide/storagedriver/aufs-driver/) and docker support. You need to have the build user in docker group for he can run docker. It is not possible to run this process as root! You need also install `jq`
|
||||||
|
|
||||||
|
## Create a server
|
||||||
|
|
||||||
|
First install ubuntu server 16.04.
|
||||||
|
|
||||||
|
Follow install instruction from docker to install it:
|
||||||
|
https://docs.docker.com/engine/installation/linux/ubuntu/
|
||||||
|
|
||||||
|
After that move the `builder` user into docker group.
|
||||||
|
```
|
||||||
|
sudo groupadd docker
|
||||||
|
sudo gpasswd -a ${USER} docker
|
||||||
|
sudo service docker restart
|
||||||
|
newgrp docker
|
||||||
|
```
|
||||||
|
|
||||||
|
Other software:
|
||||||
|
```
|
||||||
|
sudo apt-get install jq
|
||||||
|
```
|
29
build-scripts/yocto-build-env/Dockerfile
Normal file
29
build-scripts/yocto-build-env/Dockerfile
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
# Install the following utilities (required by poky)
|
||||||
|
RUN apt-get update && apt-get install -y build-essential chrpath curl diffstat gcc-multilib gawk git-core libsdl1.2-dev texinfo unzip wget xterm cpio file python3 && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Set the locale to UTF-8 for bulding with poky morty
|
||||||
|
RUN locale-gen en_US.UTF-8
|
||||||
|
ENV LANG en_US.UTF-8
|
||||||
|
|
||||||
|
# Additional host packages required by resin
|
||||||
|
RUN apt-get update && apt-get install -y apt-transport-https && rm -rf /var/lib/apt/lists/*
|
||||||
|
RUN curl --silent https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
|
||||||
|
ENV NODE_VERSION node_4.x
|
||||||
|
ENV DISTRO vivid
|
||||||
|
RUN echo "deb https://deb.nodesource.com/$NODE_VERSION $DISTRO main" | tee /etc/apt/sources.list.d/nodesource.list &&\
|
||||||
|
echo "deb-src https://deb.nodesource.com/$NODE_VERSION $DISTRO main" | tee -a /etc/apt/sources.list.d/nodesource.list
|
||||||
|
RUN apt-get update && apt-get install -y jq nodejs sudo && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install docker
|
||||||
|
# https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository
|
||||||
|
RUN apt-get update && apt-get install -y apt-transport-https ca-certificates curl software-properties-common && rm -rf /var/lib/apt/lists/*
|
||||||
|
VOLUME /var/lib/docker
|
||||||
|
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
||||||
|
RUN add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
||||||
|
RUN apt-get update && apt-get install -y docker-ce && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY run-resinos.sh /
|
||||||
|
|
||||||
|
WORKDIR /yocto/resin-board
|
23
build-scripts/yocto-build-env/create-build-env.sh
Normal file
23
build-scripts/yocto-build-env/create-build-env.sh
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -ev
|
||||||
|
|
||||||
|
# Get the absolute script location
|
||||||
|
pushd `dirname $0` > /dev/null 2>&1
|
||||||
|
SCRIPTPATH=`pwd`
|
||||||
|
popd > /dev/null 2>&1
|
||||||
|
|
||||||
|
if [ -z "${REVISION}" ]; then
|
||||||
|
echo "[ERROR] No revision specified."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build
|
||||||
|
docker build --pull --tag pvizeli/yocto-build-env:${REVISION} -f ${SCRIPTPATH}/Dockerfile ${SCRIPTPATH}
|
||||||
|
|
||||||
|
# Tag
|
||||||
|
docker tag -f pvizeli/yocto-build-env:${REVISION} resin/yocto-build-env:latest
|
||||||
|
|
||||||
|
# Push
|
||||||
|
docker push pvizeli/yocto-build-env:${REVISION}
|
||||||
|
docker push pvizeli/yocto-build-env:latest
|
68
build-scripts/yocto-build-env/run-resinos.sh
Normal file
68
build-scripts/yocto-build-env/run-resinos.sh
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
DOCKER_TIMEOUT=20 # Wait 20 seconds for docker to start
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
echo "[INFO] Running cleanup..."
|
||||||
|
|
||||||
|
# Stop docker gracefully
|
||||||
|
echo "[INFO] Stopping in container docker..."
|
||||||
|
DOCKERPIDFILE=/var/run/docker.pid
|
||||||
|
if [ -f $DOCKERPIDFILE ] && [ -s $DOCKERPIDFILE ] && ps $(cat $DOCKERPIDFILE) | grep -q docker; then
|
||||||
|
kill $(cat $DOCKERPIDFILE)
|
||||||
|
# Now wait for it to die
|
||||||
|
STARTTIME=$(date +%s)
|
||||||
|
ENDTIME=$(date +%s)
|
||||||
|
while [ -f $DOCKERPIDFILE ] && [ -s $DOCKERPIDFILE ] && ps $(cat $DOCKERPIDFILE) | grep -q docker; do
|
||||||
|
if [ $(($ENDTIME - $STARTTIME)) -le $DOCKER_TIMEOUT ]; then
|
||||||
|
sleep 1
|
||||||
|
ENDTIME=$(date +%s)
|
||||||
|
else
|
||||||
|
echo "[ERROR] Timeout while waiting for in container docker to die."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "[WARN] Can't stop docker container."
|
||||||
|
echo "[WARN] Your host might have been left with unreleased resources (ex. loop devices)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "fail" ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap 'cleanup fail' SIGINT SIGTERM
|
||||||
|
|
||||||
|
# Create the normal user to be used for bitbake (barys)
|
||||||
|
echo "[INFO] Creating and setting builder user $BUILDER_UID:$BUILDER_GID."
|
||||||
|
groupadd -g $BUILDER_GID builder
|
||||||
|
groupadd docker || true
|
||||||
|
useradd -m -u $BUILDER_UID -g $BUILDER_GID -G docker builder
|
||||||
|
|
||||||
|
# Start docker
|
||||||
|
echo "[INFO] Starting docker."
|
||||||
|
dockerd 2> /dev/null &
|
||||||
|
echo "[INFO] Waiting for docker to initialize..."
|
||||||
|
STARTTIME=$(date +%s)
|
||||||
|
ENDTIME=$(date +%s)
|
||||||
|
until docker info >/dev/null 2>&1; do
|
||||||
|
if [ $(($ENDTIME - $STARTTIME)) -le $DOCKER_TIMEOUT ]; then
|
||||||
|
sleep 1
|
||||||
|
ENDTIME=$(date +%s)
|
||||||
|
else
|
||||||
|
echo "[ERROR] Timeout while waiting for docker to come up."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "[INFO] Docker was initialized."
|
||||||
|
|
||||||
|
# Start barys with all the arguments requested
|
||||||
|
echo "[INFO] Running build as builder user..."
|
||||||
|
sudo -H -u builder /yocto/resin-board/resin-yocto-scripts/build/barys $@ &
|
||||||
|
barys_pid=$!
|
||||||
|
wait $barys_pid || true
|
||||||
|
|
||||||
|
cleanup
|
||||||
|
exit 0
|
Loading…
x
Reference in New Issue
Block a user