Leopold Schabel | dca59d9 | 2021-04-01 19:02:53 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 2 | set -euo pipefail |
| 3 | |
| 4 | # Our local user needs write access to /dev/kvm (best accomplished by |
| 5 | # adding your user to the kvm group). |
| 6 | if ! touch /dev/kvm; then |
| 7 | echo "Cannot write to /dev/kvm - please verify permissions." |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
| 11 | # The KVM module needs to be loaded, since our container is unprivileged |
| 12 | # and won't be able to do it itself. |
| 13 | if ! [[ -d /sys/module/kvm ]]; then |
| 14 | echo "kvm module not loaded - please modprobe kvm" |
| 15 | exit 1 |
| 16 | fi |
| 17 | |
| 18 | # Rebuild base image |
Serge Bazanski | 5aa494f | 2021-05-18 18:57:10 +0200 | [diff] [blame] | 19 | podman build -t monogon-builder build/ci |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 20 | |
Leopold Schabel | 052af2d | 2019-11-06 02:21:53 +0000 | [diff] [blame] | 21 | # Keep this in sync with ci.sh: |
| 22 | |
Serge Bazanski | febf0b0 | 2021-01-07 16:34:28 +0100 | [diff] [blame] | 23 | podman pod create --name monogon |
Hendrik Hofstadt | 3e6018f | 2019-10-28 21:29:42 +0100 | [diff] [blame] | 24 | |
Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 25 | # Mount bazel root to identical paths inside and outside the container. |
| 26 | # This caches build state even if the container is destroyed, and |
Serge Bazanski | acae1ef | 2021-05-19 11:31:40 +0200 | [diff] [blame] | 27 | BAZEL_ROOT=${HOME}/.cache/bazel-monogon |
Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 28 | mkdir -p ${BAZEL_ROOT} |
| 29 | |
Leopold Schabel | 399fe83 | 2019-11-15 21:15:30 +0100 | [diff] [blame] | 30 | # The Bazel plugin injects a Bazel repository into the sync command line, |
| 31 | # We need to copy the aspect repository and apply a custom patch. |
Leopold Schabel | 58ec09e | 2021-04-01 18:34:19 +0200 | [diff] [blame] | 32 | |
| 33 | # TODO(leo): the IntelliJ path changed to ~/.config on new setups, we should look for that as well |
| 34 | |
Leopold Schabel | 8cc81f6 | 2020-01-06 17:04:54 +0100 | [diff] [blame] | 35 | IJ_HOME=$(echo ${HOME}/.IntelliJIdea* | tr ' ' '\n' | sort | tail -n 1) |
| 36 | ASPECT_ORIG=${IJ_HOME}/config/plugins/ijwb/aspect |
Leopold Schabel | 399fe83 | 2019-11-15 21:15:30 +0100 | [diff] [blame] | 37 | ASPECT_PATH=${BAZEL_ROOT}/ijwb_aspect |
Leopold Schabel | 58ec09e | 2021-04-01 18:34:19 +0200 | [diff] [blame] | 38 | |
| 39 | if [[ -d "$IJ_HOME" ]]; then |
| 40 | echo "IntelliJ found, copying aspect file to Bazel root" |
| 41 | rm -rf "$ASPECT_PATH" |
| 42 | cp -r "$ASPECT_ORIG" "$ASPECT_PATH" |
| 43 | patch -d "$ASPECT_PATH" -p1 < scripts/patches/bazel_intellij_aspect_filter.patch |
| 44 | fi |
Leopold Schabel | 399fe83 | 2019-11-15 21:15:30 +0100 | [diff] [blame] | 45 | |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 46 | podman run -it -d \ |
Leopold Schabel | 58ec09e | 2021-04-01 18:34:19 +0200 | [diff] [blame] | 47 | -v $(pwd):$(pwd):z \ |
Leopold Schabel | 8b9c055 | 2019-11-15 14:07:45 +0100 | [diff] [blame] | 48 | -w $(pwd) \ |
| 49 | --volume=${BAZEL_ROOT}:${BAZEL_ROOT} \ |
Leopold Schabel | 2983d72 | 2019-10-23 12:16:42 +0200 | [diff] [blame] | 50 | --device /dev/kvm \ |
Leopold Schabel | 7afd390 | 2019-10-23 12:16:57 +0200 | [diff] [blame] | 51 | --privileged \ |
Serge Bazanski | febf0b0 | 2021-01-07 16:34:28 +0100 | [diff] [blame] | 52 | --pod monogon \ |
| 53 | --name=monogon-dev \ |
Leopold Schabel | 980d003 | 2020-06-03 14:44:49 +0200 | [diff] [blame] | 54 | --net=host \ |
Serge Bazanski | febf0b0 | 2021-01-07 16:34:28 +0100 | [diff] [blame] | 55 | monogon-builder |