Skip to content

Commit cbe1a36

Browse files
committed
Allow 'bundle' brew tap to be used within sandbox
1 parent 37d1e83 commit cbe1a36

File tree

1 file changed

+61
-4
lines changed
  • packages/dkml-base-compiler/dkml-base-compiler.4.12.1~v1.0.0

1 file changed

+61
-4
lines changed

packages/dkml-base-compiler/dkml-base-compiler.4.12.1~v1.0.0/opam

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,54 @@ depends: [
1919
conflict-class: "ocaml-core-compiler"
2020
flags: [ compiler avoid-version ]
2121
build: [
22+
# Homebrew's bundle tap, needed for reproducible build auditing in drc's crossplatform-functions.sh.
23+
#
24+
# The Opam sandbox will stop Homebrew from auto-installing its own tap. In particular 'brew bundle ...'
25+
# is automatically installed per https://github.com/Homebrew/homebrew-bundle/tree/4756e4c4cf95485c5ea4da27375946c1dac2c71d#installation,
26+
# and it is an "official" tap per
27+
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/official_taps.rb#L11-L18 .
28+
#
29+
# So our solution is to:
30+
# a) Use extra-source:[] to download a Git tarball without tripping over the sandbox firewall
31+
# b) Recreate a local file git repository
32+
# c) Use the next build:[] steps to let Homebrew know about the bundle tap
33+
#
34+
# Test with: brew untap homebrew/bundle
35+
["install" "-d" "dl/homebrew-bundle"] {os = "macos"}
36+
["tar" "xCfz" "dl/homebrew-bundle" "dl/homebrew-bundle.tar.gz" "--strip-components=1"] {os = "macos"}
37+
["sh" "-c" """#!/bin/sh
38+
set -eufx
39+
if command -v brew; then
40+
eval $(brew shellenv)
41+
HOMEBREW_BREW_FILE="$(command -v brew)"
42+
HOMEBREW_LIBRARY="${HOMEBREW_REPOSITORY}/Library"
43+
HOMEBREW_PATH="$PATH"
44+
HOMEBREW_CACHE="$PWD/dl/homebrew-cache"
45+
export HOMEBREW_BREW_FILE HOMEBREW_PATH HOMEBREW_CACHE
46+
47+
# Clone the Library which contains the Taps/
48+
# (and also Homebrew/ which is all the core scripts).
49+
# * [-a] will copy and continue even if there are errors (like dangling symlinks).
50+
install -d dl/homebrew
51+
cp -a "$HOMEBREW_LIBRARY" dl/homebrew/ || true
52+
HOMEBREW_LIBRARY="$PWD/dl/homebrew/Library"
53+
export HOMEBREW_LIBRARY
54+
55+
# Install the tap manually by copying it. If we had used
56+
# 'brew tap homebrew/bundle [URL]' or more specifically
57+
# '/bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" tap homebrew/bundle [URL]'
58+
# then brew would try to update its own configuration repository to say the tap was installed.
59+
# It would fail with 'error: could not lock config file .git/config: Operation not permitted'
60+
# because we are in a sandbox. We would have to ignore that error even though the tap was installed.
61+
# too many sandbox permissions, even with a file:// URL).
62+
install -d "${HOMEBREW_LIBRARY}/Taps/homebrew"
63+
cp -rp dl/homebrew-bundle "${HOMEBREW_LIBRARY}/Taps/homebrew/"
64+
65+
/bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" bundle dump
66+
test -e Brewfile
67+
fi
68+
"""] {os = "macos"}
69+
2270
# OCaml source code
2371
["install" "-d" "dl/ocaml/flexdll"]
2472
["tar" "xCfz" "dl/ocaml" "dl/ocaml.tar.gz" "--strip-components=1"]
@@ -43,6 +91,7 @@ install: [
4391
# Run r-c-ocaml-1-setup.sh
4492
[
4593
"env" "TOPDIR=dkmldir/vendor/drc/all/emptytop"
94+
"DKML_REPRODUCIBLE_SYSTEM_BREWFILE=%{_:build}%/Brewfile"
4695
"dkmldir/vendor/dkml-compiler/src/r-c-ocaml-1-setup.sh"
4796
"-d" "dkmldir"
4897
"-t" "%{prefix}%"
@@ -91,16 +140,24 @@ extra-source "dl/flexdll.tar.gz" {
91140
src: "https://github.com/alainfrisch/flexdll/archive/0.39.tar.gz"
92141
checksum: "sha256=51a6ef2e67ff475c33a76b3dc86401a0f286c9a3339ee8145053ea02d2fb5974"
93142
}
143+
extra-source "dl/homebrew-bundle.tar.gz" {
144+
src: "https://github.com/Homebrew/homebrew-bundle/archive/4756e4c4cf95485c5ea4da27375946c1dac2c71d.tar.gz"
145+
checksum: [
146+
"sha256=10c024ca7871cea36b4c27b2601971d3fa6cba6f37855613baf0026d0f555e76"
147+
]
148+
}
94149
extra-source "dl/dkml-runtime-common.tar.gz" {
95-
src: "https://github.com/diskuv/dkml-runtime-common/archive/refs/tags/v0.4.0.tar.gz"
150+
# This violates the v1.0.0 versioning, but this future patch is needed to allow the 'bundle'
151+
# brew tap to be used on macOS in the Opam sandbox.
152+
src: "https://github.com/diskuv/dkml-runtime-common/archive/refs/tags/v1.0.1-prerel0b.tar.gz"
96153
checksum: [
97-
"sha256=8793c636e14b630722ba59145aa1d895fddbb151de4b7f515cefb8942ec2f917"
154+
"sha256=563b89382f07a4ce56917a8eb7034c5fa6993572f087ad909e58229e78748056"
98155
]
99156
}
100157
url {
101158
src: "https://github.com/diskuv/dkml-compiler/archive/4.12.1-v1.0.0.tar.gz"
102159
checksum: [
103-
"md5=23f798f9ac63bf614de0755b0a5a9751"
104-
"sha512=3028db4dc6a5fdbe8e47f699985f81e6d18144dab81b1e15eb5623d8bbdb39cca2987f50a9e0096cfe714169b6177fff0f670b57322dec879cfb558dbc1b0134"
160+
"md5=94f9e2619e329ec6b28c0c42c4e0ced5"
161+
"sha512=9bb83aeccb9054153d879c33d0999e5c648bdf2dbded6f7fc3115c984592fd117ff2d7858edb38c53389bbf480050451e4bcb86ea7e7ff59279e175b48183013"
105162
]
106163
}

0 commit comments

Comments
 (0)