diff --git a/Dockerfile.dev b/Dockerfile.dev index 093c7131..afca7835 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,25 +1,30 @@ -# Copyright 2018 Shift Devices AG +# The MIT License (MIT) # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2019 Shift Cryptosecurity AG # -# http://www.apache.org/licenses/LICENSE-2.0 +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES +# OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. # # Run with Docker: # docker build --tag shift/mcu-base -f Dockerfile.dev . # FROM debian:stretch -ENV DEBIAN_FRONTEND noninteractive -WORKDIR /app -COPY . /app RUN apt update && apt-get install -y cmake git wget locales python python-pip RUN mkdir ~/Downloads && cd ~/Downloads && wget -O gcc.tar.bz2 https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2 @@ -30,5 +35,5 @@ RUN apt install -y libbz2-dev libbz2-dev libbz2-1.0 libncurses5 libz1 valgrind a RUN pip install --prefix /usr/local cpp-coveralls RUN locale-gen UTF-8 ENV CC gcc -RUN cd /app/ && mkdir docker-build && cd docker-build && cmake .. -DBUILD_TYPE=firmware -DUSE_SECP256K1_LIB=ON && make TEST=yes -RUN sha256sum docker-build/bin/* + +CMD ["bash"] diff --git a/Dockerfile.tests b/Dockerfile.tests index 77318be6..6de29038 100644 --- a/Dockerfile.tests +++ b/Dockerfile.tests @@ -1,16 +1,24 @@ -# Copyright 2018 Shift Devices AG +# The MIT License (MIT) # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2019 Shift Cryptosecurity AG # -# http://www.apache.org/licenses/LICENSE-2.0 +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: # -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES +# OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. # # Run with Docker: # docker build --tag shift/mcu-base-tests -f Dockerfile.tests . @@ -21,7 +29,6 @@ ENV DEBIAN_FRONTEND noninteractive WORKDIR /app COPY . /app - RUN gcc -v RUN clang -v ENV CC gcc diff --git a/dockerdev.sh b/dockerdev.sh new file mode 100755 index 00000000..2e51e259 --- /dev/null +++ b/dockerdev.sh @@ -0,0 +1,59 @@ +#!/bin/bash -e +# +# The MIT License (MIT) +# +# Copyright 2019 Shift Cryptosecurity AG +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES +# OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +dockerdev () { + local container_image=shift/mcu-base + local container_name=mcu-dev + + if ! docker images | grep -q $container_image; then + echo "No $container_image docker image found! Maybe you need to run 'docker build --tag $container_image -f Dockerfile.dev .'?" >&2 + exit 1 + fi + + # If already running, enter the container. + if docker ps | grep -q $container_name; then + docker exec -it $container_name bash + return + fi + + if docker ps -a | grep -q $container_name; then + docker rm $container_name + fi + + local repo_path="$DIR" + docker run \ + --detach \ + --privileged -v /dev/bus/usb:/dev/bus/usb \ + --interactive --tty \ + --name=$container_name \ + -v $repo_path:/app \ + $container_image bash + + # Call a second time to enter the container. + dockerdev +} + +dockerdev