blob: b9e4256812a878f20f7ab5fe3ea15629029d135b [file] [log] [blame]
Leopold7fbf1042023-01-06 19:57:37 +01001#!/usr/bin/env bash
2set -euo pipefail
3
4# Tell wrapper to not touch sandbox
5export MONOGON_SYSROOT_REBUILD=1
6
7# Packages to install. Make sure to document the reason for including each package.
8PKGS=(
9 # Common base toolchain used across the tree.
10 "binutils"
11 "gcc"
12 "python3"
13 "python-unversioned-command"
14 "glibc-static"
15
16 # Kernel build
17 "flex"
18 "bison"
19 "elfutils-libelf-devel"
20 "openssl-devel"
21 "diffutils"
22 "bc"
23 "perl"
24 "lz4"
25
26 # EDK2
27 "libuuid-devel"
28 "util-linux"
29 "nasm"
30 "acpica-tools"
31
32 # TPM emulator for testing
33 "swtpm-tools"
34
35 # Clang/LLVM (for EFI toolchain)
36 "clang"
37 "llvm"
38 "lld"
39
40 # image_gcp rule
41 "tar"
42
43 # ktest
44 "qemu-system-x86-core"
45
46 # musl-host-gcc
47 "rsync"
48 "xz"
49
50 # Packages included to stabilize SAT solution when there are equal scores.
51 "fedora-release-identity-container"
52 "coreutils-single"
53 "curl-minimal"
54 "libcurl-minimal"
55 "glibc-langpack-en"
56 "selinux-policy-minimum"
57)
58
59DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
60REPO=third_party/sandboxroot/repo.yaml
61BAZEL_ARGS="--noworkspace_rc --bazelrc ${DIR}/../../.bazelrc.sandboxroot"
62
63# Fetch latest repository metadata
64bazel ${BAZEL_ARGS} run //:bazeldnf -- fetch --repofile $REPO
65
66# Write BUILD.bazel template
67cat <<EOF > ${DIR}/BUILD.bazel.in
68load("@bazeldnf//:deps.bzl", "rpmtree")
69load("@bazeldnf//:def.bzl", "bazeldnf")
70
71bazeldnf(
72 name = "sandboxroot",
73 command = "sandbox",
74 tar = ":sandbox",
75)
76
77EOF
78
79touch ${DIR}/repositories.bzl.in
80
81# Create new sandbox root
82bazel ${BAZEL_ARGS} \
83 run //:bazeldnf -- rpmtree \
84 --repofile third_party/sandboxroot/repo.yaml \
85 --name sandbox \
86 --nobest \
87 --buildfile third_party/sandboxroot/BUILD.bazel.in \
88 --workspace third_party/sandboxroot/repositories.bzl.in \
89 ${PKGS[@]}
90
91# Verify package signatures
92bazel ${BAZEL_ARGS} run //:bazeldnf -- verify \
93 --repofile third_party/sandboxroot/repo.yaml \
94 --workspace third_party/sandboxroot/repositories.bzl.in
95
96# Write out repositories.bzl and clean up.
97#
98# Ideally, bazeldnf would support the format natively:
99# https://github.com/rmohr/bazeldnf/issues/26
100cat <<EOF > ${DIR}/repositories.bzl
101load("@bazeldnf//:deps.bzl", "rpm")
102
103def sandbox_dependencies():
104$(cat ${DIR}/repositories.bzl.in | sed 's/^/ /')
105EOF
106
107mv ${DIR}/BUILD.bazel.in ${DIR}/BUILD.bazel
108rm ${DIR}/repositories.bzl.in