diff --git a/docker/Dockerfile b/docker/Dockerfile index 8d63c0860..2b1e388e9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,9 @@ -FROM ubuntu:18.04 +FROM ubuntu:20.04 LABEL maintainer="Alexander.Richardson@cl.cam.ac.uk" +ARG DEBIAN_FRONTEND=noninteractive + RUN apt-get update && apt-get install -y \ make ninja-build \ gcc g++ \ @@ -9,7 +11,9 @@ RUN apt-get update && apt-get install -y \ python3-minimal \ lsb-release \ wget \ - samba + samba \ + texlive-base \ + texinfo # RUN git config --global http.sslVerify false # RUN cd /tmp && git clone https://github.com/arichardson/bmake && cd bmake \ @@ -20,18 +24,20 @@ COPY cheribuild.json /root/.config/cheribuild.json # deps to build QEMU+elftoolchain: RUN apt-get update && apt-get install -y \ - libtool pkg-config python-minimal autotools-dev automake autoconf libglib2.0-dev libpixman-1-dev \ + libtool pkg-config python2-minimal autotools-dev automake autoconf libglib2.0-dev libpixman-1-dev \ bison groff-base libarchive-dev flex -# INSTALL clang 8.0 +# INSTALL clang 10.0 RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - RUN echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" > /etc/apt/sources.list.d/llvm.list # RUN echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main" > /etc/apt/sources.list.d/r-toolchain.list # RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1E9377A2BA9EF27F -RUN apt-get update && apt-get install -y clang-8 lld-8 +RUN apt-get update && apt-get install -y clang-10 lld-10 RUN apt-get update && apt-get install -y cmake +RUN groupadd -g 12345 -r cheri && useradd -u 12345 --no-log-init -r -g cheri cheri + VOLUME ["/cheribuild", "/source", "/build", "/output"] ENV PATH /cheribuild:$PATH CMD bash diff --git a/pycheribuild/__main__.py b/pycheribuild/__main__.py index 7b374f46c..e5df0ad57 100644 --- a/pycheribuild/__main__.py +++ b/pycheribuild/__main__.py @@ -198,8 +198,12 @@ def real_main(): subprocess.check_call(start_cmd) docker_run_cmd = ["docker", "exec", cheri_config.docker_container] + cheribuild_args else: - docker_run_cmd = ["docker", "run", "--user", str(os.getuid()) + ":" + str(os.getgid()), - "--rm", "--interactive", "--tty"] + docker_dir_mappings + if cheri_config.docker_uid != "": + docker_run_cmd = ["docker", "run", "--user", cheri_config.docker_uid + ":" + cheri_config.docker_gid, + "--rm", "--interactive", "--tty"] + docker_dir_mappings + else: + docker_run_cmd = ["docker", "run", "--user", str(os.getuid()) + ":" + str(os.getgid()), + "--rm", "--interactive", "--tty"] + docker_dir_mappings docker_run_cmd += [cheri_config.docker_container] + cheribuild_args run_command(docker_run_cmd, config=cheri_config, give_tty_control=True) except subprocess.CalledProcessError as e: diff --git a/pycheribuild/config/chericonfig.py b/pycheribuild/config/chericonfig.py index 0e5b29e6d..05d675ac9 100644 --- a/pycheribuild/config/chericonfig.py +++ b/pycheribuild/config/chericonfig.py @@ -278,6 +278,8 @@ def __init__(self, loader, action_class): help="Attach to the same container again (note: " "docker-container option must be an id rather than " "a container name") + self.docker_uid = loader.add_option("docker-uid", help="UID to under Docker", default="", group=loader.docker_group) + self.docker_gid = loader.add_option("docker-gid", help="GID to under Docker", default="", group=loader.docker_group) # compilation db options: self.create_compilation_db = loader.add_commandline_only_bool_option( diff --git a/pycheribuild/projects/release.py b/pycheribuild/projects/release.py new file mode 100644 index 000000000..0ab88b343 --- /dev/null +++ b/pycheribuild/projects/release.py @@ -0,0 +1,162 @@ +# +# Copyright (c) 2021 George V. Neville-Neil +# +# This software was developed by SRI International and the University of +# Cambridge Computer Laboratory (Department of Computer Science and +# Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the +# DARPA SSITH research programme. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. 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. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. +# +import tempfile +from pathlib import Path +from typing import Optional + +from pycheribuild.processutils import run_command +from pycheribuild.utils import default_make_jobs_count +from .cherisim import BuildBeriCtl, BuildCheriSim +from .project import CheriConfig, SimpleProject +from ..config.compilation_targets import CompilationTargets + + +repos = ["cheribuild", "cheribsd", "gdb", + "morello-llvm-project", "morello-qemu", + "morello-trusted-firmware-a", "qemu"] + +class Tag(SimpleProject): + target = "tag" + + @classmethod + def setup_config_options(cls, **kwargs): + super().setup_config_options(**kwargs) + + cls.gittag = cls.add_config_option("gittag", help="Tag to apply") + + def __init__(self, config: CheriConfig): + super().__init__(config) + + def process(self): + source_root = self.config.source_root + for repo in repos: + run_command("git", "-C", repo, "tag", self.gittag, cwd=source_root) + +class UnTag(SimpleProject): + target = "untag" + + @classmethod + def setup_config_options(cls, **kwargs): + super().setup_config_options(**kwargs) + + cls.gittag = cls.add_config_option("gittag", help="Tag to apply") + + def __init__(self, config: CheriConfig): + super().__init__(config) + + def process(self): + source_root = self.config.source_root + for repo in repos: + run_command("git", "-C", repo, "tag", "-d", self.gittag, cwd=source_root) + +class Release(SimpleProject): + project_name = "release" + do_not_add_to_targets = True + + def __init__(self, config: CheriConfig): + super().__init__(config) + + def process(self): + source_root = self.config.source_root + + Path(source_root, "cheribuild/cheribuild.json").write_text("""{ + "source-root": "../../sources", + "build-root": "../../build", + "output-root": "../../output", + "skip-update": true +} + """) + + +class MorelloRelease(Release): + target = "morello-release" + dependencies = ["morello-llvm", "cheribsd-morello-purecap", + "gdb-native", + "gdb-morello-hybrid-for-purecap-rootfs", + "arm-none-eabi-toolchain", "morello-acpica", + "morello-scp-firmware", + "morello-trusted-firmware", + "morello-flash-images", + "disk-image-morello-purecap"] + def __init__(self, config: CheriConfig): + super().__init__(config) + + + def process(self): + super().process() + + root = self.config.output_root.parent + output_root = self.config.output_root + + install_script = Path(output_root, "install_and_run_fvp.sh") + install_script.write_text("""#!/bin/sh + dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) + exec "${dir}/cheribuild.py" install-morello-fvp run-fvp-morello-purecap "$@""") + install_script.chmod(0o755) + + run_command("bsdtar", "-cavf", output_root / "release-morello.tar.xz", + "-C", root, + "--options=xz:threads=" + str(default_make_jobs_count()), + "--options=compression-level=9", # reduce size a bit more + "--exclude=*.git", + "output/morello-sdk/firmware", + "output/cheribsd-morello-purecap.img", + "output/sdk", + "sources/cheribuild", + cwd="/") + + run_command("sha256sum", output_root / "release-morello.tar.xz") + +class RISCV64Release(Release): + target = "riscv64-release" + dependencies = ["gdb-native", "qemu", + "bbl-baremetal-riscv64-purecap", + "disk-image-riscv64-purecap"] + + def __init__(self, config: CheriConfig): + super().__init__(config) + + def process(self): + super().process() + root = self.config.output_root.parent + output_root = self.config.output_root + + run_command("bsdtar", "-cavf", output_root / "release-riscv64.tar.xz", + "-C", root, + "--options=xz:threads=" + str(default_make_jobs_count()), + #"--options=compression-level=9", # reduce size a bit more + "--exclude=*.git", + "output/cheribsd-riscv64-purecap.img", + "output/rootfs-riscv64-purecap", + "output/sdk", + "sources/cheribuild", + cwd="/") + + run_command("sha256sum", output_root / "release-riscv64.tar.xz")