blob: 7224d4e35f476c3e64f270ae0616e6c410627936 [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
Tim Windelschmidt8e7df7b2023-03-30 15:02:35 +020016 # Required to build static CGO binaries
17 # see monogon-dev/monogon#192
18 "libstdc++-static"
19
Leopold7fbf1042023-01-06 19:57:37 +010020 # Kernel build
21 "flex"
22 "bison"
23 "elfutils-libelf-devel"
24 "openssl-devel"
25 "diffutils"
26 "bc"
27 "perl"
28 "lz4"
29
30 # EDK2
31 "libuuid-devel"
32 "util-linux"
33 "nasm"
34 "acpica-tools"
35
Serge Bazanski0f1939a2023-02-23 09:36:10 +000036 # patch tool, as used by gazelle
37 "patch"
38
Leopold7fbf1042023-01-06 19:57:37 +010039 # TPM emulator for testing
40 "swtpm-tools"
41
42 # Clang/LLVM (for EFI toolchain)
43 "clang"
44 "llvm"
45 "lld"
46
47 # image_gcp rule
48 "tar"
49
50 # ktest
51 "qemu-system-x86-core"
52
53 # musl-host-gcc
54 "rsync"
55 "xz"
56
57 # Packages included to stabilize SAT solution when there are equal scores.
58 "fedora-release-identity-container"
59 "coreutils-single"
60 "curl-minimal"
61 "libcurl-minimal"
62 "glibc-langpack-en"
63 "selinux-policy-minimum"
64)
65
66DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
67REPO=third_party/sandboxroot/repo.yaml
68BAZEL_ARGS="--noworkspace_rc --bazelrc ${DIR}/../../.bazelrc.sandboxroot"
69
70# Fetch latest repository metadata
71bazel ${BAZEL_ARGS} run //:bazeldnf -- fetch --repofile $REPO
72
73# Write BUILD.bazel template
74cat <<EOF > ${DIR}/BUILD.bazel.in
75load("@bazeldnf//:deps.bzl", "rpmtree")
76load("@bazeldnf//:def.bzl", "bazeldnf")
77
78bazeldnf(
79 name = "sandboxroot",
80 command = "sandbox",
81 tar = ":sandbox",
82)
83
84EOF
85
Leopold7eeec652023-01-20 21:16:08 +010086echo > ${DIR}/repositories.bzl.in
Leopold7fbf1042023-01-06 19:57:37 +010087
88# Create new sandbox root
89bazel ${BAZEL_ARGS} \
90 run //:bazeldnf -- rpmtree \
91 --repofile third_party/sandboxroot/repo.yaml \
92 --name sandbox \
93 --nobest \
94 --buildfile third_party/sandboxroot/BUILD.bazel.in \
95 --workspace third_party/sandboxroot/repositories.bzl.in \
96 ${PKGS[@]}
97
98# Verify package signatures
99bazel ${BAZEL_ARGS} run //:bazeldnf -- verify \
100 --repofile third_party/sandboxroot/repo.yaml \
101 --workspace third_party/sandboxroot/repositories.bzl.in
102
103# Write out repositories.bzl and clean up.
104#
105# Ideally, bazeldnf would support the format natively:
106# https://github.com/rmohr/bazeldnf/issues/26
107cat <<EOF > ${DIR}/repositories.bzl
108load("@bazeldnf//:deps.bzl", "rpm")
109
110def sandbox_dependencies():
111$(cat ${DIR}/repositories.bzl.in | sed 's/^/ /')
112EOF
113
114mv ${DIR}/BUILD.bazel.in ${DIR}/BUILD.bazel
115rm ${DIR}/repositories.bzl.in
Serge Bazanski77b87a62023-04-03 15:24:27 +0200116
117
118# Mirror everything
119bazel ${BAZEL_ARGS} \
120 run //third_party/sandboxroot/mirror sync