diff --git a/hypervisor/.travis-dockerfiles/Dockerfile.centos7 b/hypervisor/.travis-dockerfiles/Dockerfile.centos7 new file mode 100644 index 000000000..c16deb1f6 --- /dev/null +++ b/hypervisor/.travis-dockerfiles/Dockerfile.centos7 @@ -0,0 +1,16 @@ +# Build container based on CentOS 7 +FROM centos:centos7 + +RUN yum -y update; yum clean all +RUN yum -y install gcc \ + git \ + make \ + vim \ + libuuid-devel \ + openssl-devel \ + libpciaccess-devel \ + gnu-efi-devel + +WORKDIR /root/acrn + +CMD ["/bin/bash"] diff --git a/hypervisor/.travis-dockerfiles/Dockerfile.clearlinux b/hypervisor/.travis-dockerfiles/Dockerfile.clearlinux new file mode 100644 index 000000000..d1f1518e6 --- /dev/null +++ b/hypervisor/.travis-dockerfiles/Dockerfile.clearlinux @@ -0,0 +1,8 @@ +# Build container based on Clearlinux +FROM clearlinux:base + +RUN swupd bundle-add os-core-dev dev-utils-dev + +WORKDIR /root/acrn + +CMD ["/bin/bash"] diff --git a/hypervisor/.travis-dockerfiles/Dockerfile.debian8 b/hypervisor/.travis-dockerfiles/Dockerfile.debian8 new file mode 100644 index 000000000..ed0eba941 --- /dev/null +++ b/hypervisor/.travis-dockerfiles/Dockerfile.debian8 @@ -0,0 +1,15 @@ +# Build container based on Debian 8 +FROM debian:8 + +# Install dependencies. +RUN apt-get update \ + && apt-get install -y gcc make vim git \ + gnu-efi \ + libssl-dev \ + libpciaccess-dev \ + uuid-dev \ + && apt-get clean + +WORKDIR /root/acrn + +CMD ["/bin/bash"] diff --git a/hypervisor/.travis-dockerfiles/Dockerfile.fedora26 b/hypervisor/.travis-dockerfiles/Dockerfile.fedora26 new file mode 100644 index 000000000..4b8a3f329 --- /dev/null +++ b/hypervisor/.travis-dockerfiles/Dockerfile.fedora26 @@ -0,0 +1,16 @@ +# Build container based on Fedora 26 +FROM fedora:26 + +RUN dnf -y update && dnf clean all +RUN dnf -y install gcc \ + git \ + make \ + vim \ + libuuid-devel \ + openssl-devel \ + libpciaccess-devel \ + gnu-efi-devel + +WORKDIR /root/acrn + +CMD ["/bin/bash"] diff --git a/hypervisor/.travis-dockerfiles/Dockerfile.fedora27 b/hypervisor/.travis-dockerfiles/Dockerfile.fedora27 new file mode 100644 index 000000000..1f7e698ba --- /dev/null +++ b/hypervisor/.travis-dockerfiles/Dockerfile.fedora27 @@ -0,0 +1,16 @@ +# Build container based on Fedora 27 +FROM fedora:27 + +RUN dnf -y update && dnf clean all +RUN dnf -y install gcc \ + git \ + make \ + vim \ + libuuid-devel \ + openssl-devel \ + libpciaccess-devel \ + gnu-efi-devel + +WORKDIR /root/acrn + +CMD ["/bin/bash"] diff --git a/hypervisor/.travis-dockerfiles/Dockerfile.ubuntu14.04 b/hypervisor/.travis-dockerfiles/Dockerfile.ubuntu14.04 new file mode 100644 index 000000000..adeeecf83 --- /dev/null +++ b/hypervisor/.travis-dockerfiles/Dockerfile.ubuntu14.04 @@ -0,0 +1,15 @@ +# Build container based on Ubuntu 14.04 +FROM ubuntu:14.04 + +# Install dependencies. +RUN apt-get update \ + && apt-get install -y gcc make vim git \ + gnu-efi \ + libssl-dev \ + libpciaccess-dev \ + uuid-dev \ + && apt-get clean + +WORKDIR /root/acrn + +CMD ["/bin/bash"] diff --git a/hypervisor/.travis-dockerfiles/Dockerfile.ubuntu16.04 b/hypervisor/.travis-dockerfiles/Dockerfile.ubuntu16.04 new file mode 100644 index 000000000..2856e4f28 --- /dev/null +++ b/hypervisor/.travis-dockerfiles/Dockerfile.ubuntu16.04 @@ -0,0 +1,15 @@ +# Build container based on Ubuntu 16.04 +FROM ubuntu:16.04 + +# Install dependencies. +RUN apt-get update \ + && apt-get install -y gcc make vim git \ + gnu-efi \ + libssl-dev \ + libpciaccess-dev \ + uuid-dev \ + && apt-get clean + +WORKDIR /root/acrn + +CMD ["/bin/bash"] diff --git a/hypervisor/.travis-dockerfiles/LICENSE b/hypervisor/.travis-dockerfiles/LICENSE new file mode 100644 index 000000000..07758b69a --- /dev/null +++ b/hypervisor/.travis-dockerfiles/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2018, Geoffroy Van Cutsem +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/hypervisor/.travis-dockerfiles/README.md b/hypervisor/.travis-dockerfiles/README.md new file mode 100644 index 000000000..88405db9e --- /dev/null +++ b/hypervisor/.travis-dockerfiles/README.md @@ -0,0 +1,80 @@ +# Build containers for Project ACRN + +## Introduction + +This repository contains a number of Dockerfile that include +all the build tools and dependencies to build the ACRN Project +components, i.e. the `acrn-hypervisor` and `acrn-devicemodel` + +The workflow is pretty simple and can be summarized in these few steps: + +1. Build the *build containers* based on your preferred OS +1. Clone the Project ACRN repositories +1. Start the build container and give it the repositories +1. Build the Project ACRN components + +The pre-requisite is that you have Docker installed on your machine. +Explaining how to install it on your system is beyond the scope of this +document, please visit https://www.docker.com for detailed instructions. + +## Build the *build containers* + +Each `Dockerfile` in this repo has an extension that tells what Linux +distribution it is based on. To build a container using any of those, +use this command: +``` +$ sudo docker build -t -f Dockerfile. . +``` + +As an example, to build a container based on CentOS 7, do: +``` +$ sudo docker build -t centos7 -f Dockerfile.centos7 . +``` + +## Clone Project ACRN + +Follow these simple steps to clone the Project ACRN repositories +``` +$ mkdir ~/acrn +$ cd ~/acrn +$ git clone https://github.com/projectacrn/acrn-hypervisor +$ git clone https://github.com/projectacrn/acrn-devicemodel +``` + +## Start the build container + +Use this `~/acrn` folder and pass it on to your build container: +``` +$ cd ~/acrn +$ sudo docker run -ti -v $PWD:/root/acrn +``` + +Using CentOS 7 again as an example, that gives us: +``` +$ cd ~/acrn +$ sudo docker run -ti -v $PWD:/root/acrn centos7 +``` + +**Note:** if you encounter permission issues within the container (as it +happens on a Fedora 27 host), try adding the `:z` parameter to the mount option. +This will unlock the permission restriction (that comes from SElinux). Your +command-line would then be: +``` +$ cd ~/acrn +$ sudo docker run -ti -v $PWD:/root/acrn:z centos7 +``` + +## Build the ACRN components + +The steps above place you inside the container and give you access to +the Project ACRN repositories you cloned earlier. You can now build any +of the components. Here is an example: +``` +# cd acrn-hypervisor +# make PLATFORM=uefi RELEASE=1 +``` + +You can do this for all build combinations and also try to build the `acrn-devicemodel`. +All the build dependencies and tools are pre-installed in the container as well as a +couple of useful tools (`git` and `vim`) so you can directly edit files to experiment +from within the container. diff --git a/hypervisor/.travis-dockerfiles/test_all_distros.sh b/hypervisor/.travis-dockerfiles/test_all_distros.sh new file mode 100755 index 000000000..fd944e4c5 --- /dev/null +++ b/hypervisor/.travis-dockerfiles/test_all_distros.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +DOCKER_BIN=`which docker` + +function usage { + echo "Usage: $0 " + echo " Where is the path to where you" + echo " have cloned the acrn repositories" + exit 1 +} + +if [ $# -eq 0 ]; +then + usage +fi + +build_container () { + var=$(sudo $DOCKER_BIN images --format '{{.Tag}}' | grep -c $distro) + echo $var +if [ $(sudo $DOCKER_BIN images --format '{{.Repository}}' | grep -c $distro) == '0' ]; +then + echo There is no build container for $distro yet. + echo Creating a build container for $distro... please be patient! + $DOCKER_BIN build -t $distro -f Dockerfile.$distro . +else + echo We already have a build container for $distro, attempting to use it... +fi +} + +for distro in `ls Dockerfile.*`; do + # Extract the name of the Linux distro. It assumes the Dockerfile name is built as "Dockerfile." + distro=${distro:11} + build_container + echo "Testing Linux distribion: $distro" + $DOCKER_BIN run -v $1:/root/acrn:z $distro make +done + diff --git a/hypervisor/.travis.yml b/hypervisor/.travis.yml index 4ee01a4e2..d3db74eac 100644 --- a/hypervisor/.travis.yml +++ b/hypervisor/.travis.yml @@ -2,11 +2,31 @@ sudo: required language: c +env: + global: + - OS_TESTED="clearlinux" + + matrix: + - RELEASE=0 + PLATFORM=sbl + + - RELEASE=1 + PLATFORM=sbl + + - RELEASE=0 + PLATFORM=uefi + + - RELEASE=1 + PLATFORM=uefi + services: - - docker + - docker before_install: - - docker ps -a + - docker build -t ${OS_TESTED} -f .travis-dockerfiles/Dockerfile.${OS_TESTED} . + - docker images + +install: true script: - - docker build -t shrmrf/acrn-hypervisor . + - docker run -v $PWD:/root/acrn ${OS_TESTED} /bin/bash -c "make clean && make PLATFORM=$PLATFORM RELEASE=$RELEASE" diff --git a/hypervisor/Dockerfile b/hypervisor/Dockerfile deleted file mode 100644 index cf4ff04c6..000000000 --- a/hypervisor/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM clearlinux:base - -MAINTAINER shrmrf "https://github.com/shrmrf" - -# Install packages for building acrn -# RUN swupd update -RUN swupd bundle-add os-core-dev - -RUN git config --global http.sslVerify false - -COPY . /root/acrn-hypervisor -RUN cd /root/acrn-hypervisor; make clean && make PLATFORM=uefi