blob: 698098fbd562d7a9c1aa94b1e1b28d9164604db9 [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
Serge Bazanski0f1939a2023-02-23 09:36:10 +000032 # patch tool, as used by gazelle
33 "patch"
34
Leopold7fbf1042023-01-06 19:57:37 +010035 # TPM emulator for testing
36 "swtpm-tools"
37
38 # Clang/LLVM (for EFI toolchain)
39 "clang"
40 "llvm"
41 "lld"
42
43 # image_gcp rule
44 "tar"
45
46 # ktest
47 "qemu-system-x86-core"
48
49 # musl-host-gcc
50 "rsync"
51 "xz"
52
53 # Packages included to stabilize SAT solution when there are equal scores.
54 "fedora-release-identity-container"
55 "coreutils-single"
56 "curl-minimal"
57 "libcurl-minimal"
58 "glibc-langpack-en"
59 "selinux-policy-minimum"
60)
61
62DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
63REPO=third_party/sandboxroot/repo.yaml
64BAZEL_ARGS="--noworkspace_rc --bazelrc ${DIR}/../../.bazelrc.sandboxroot"
65
66# Fetch latest repository metadata
67bazel ${BAZEL_ARGS} run //:bazeldnf -- fetch --repofile $REPO
68
69# Write BUILD.bazel template
70cat <<EOF > ${DIR}/BUILD.bazel.in
71load("@bazeldnf//:deps.bzl", "rpmtree")
72load("@bazeldnf//:def.bzl", "bazeldnf")
73
74bazeldnf(
75 name = "sandboxroot",
76 command = "sandbox",
77 tar = ":sandbox",
78)
79
80EOF
81
Leopold7eeec652023-01-20 21:16:08 +010082echo > ${DIR}/repositories.bzl.in
Leopold7fbf1042023-01-06 19:57:37 +010083
84# Create new sandbox root
85bazel ${BAZEL_ARGS} \
86 run //:bazeldnf -- rpmtree \
87 --repofile third_party/sandboxroot/repo.yaml \
88 --name sandbox \
89 --nobest \
90 --buildfile third_party/sandboxroot/BUILD.bazel.in \
91 --workspace third_party/sandboxroot/repositories.bzl.in \
92 ${PKGS[@]}
93
94# Verify package signatures
95bazel ${BAZEL_ARGS} run //:bazeldnf -- verify \
96 --repofile third_party/sandboxroot/repo.yaml \
97 --workspace third_party/sandboxroot/repositories.bzl.in
98
99# Write out repositories.bzl and clean up.
100#
101# Ideally, bazeldnf would support the format natively:
102# https://github.com/rmohr/bazeldnf/issues/26
103cat <<EOF > ${DIR}/repositories.bzl
104load("@bazeldnf//:deps.bzl", "rpm")
105
106def sandbox_dependencies():
107$(cat ${DIR}/repositories.bzl.in | sed 's/^/ /')
108EOF
109
110mv ${DIR}/BUILD.bazel.in ${DIR}/BUILD.bazel
111rm ${DIR}/repositories.bzl.in