|
| 1 | +opam-version: "2.0" |
| 2 | +synopsis: "DKML component for 32-bit versions of opam" |
| 3 | +description: """For 32-bit capable platforms, opam, opam-putenv and opam-installer will be in <share>/staging-files/<platform>. |
| 4 | +But for any platform that does not support 32-bit, this package will install nothing (aka. be a no-op). |
| 5 | +Consumers of the component should place both tools/opam64 and tools/opam32 into the PATH, so that whichever is available can be used.""" |
| 6 | + |
| 7 | +authors: ["Diskuv, Inc. < [email protected]>"] |
| 8 | +license: "Apache-2.0" |
| 9 | +homepage: "https://github.com/diskuv/dkml-component-opam" |
| 10 | +bug-reports: "https://github.com/diskuv/dkml-component-opam/issues" |
| 11 | +depends: [ |
| 12 | + "dkml-install" {>= "0.2.0"} |
| 13 | + "dune" {>= "2.9"} |
| 14 | + "diskuvbox" {>= "0.1.0" & build} |
| 15 | +] |
| 16 | +depopts: [ |
| 17 | + "ocaml-system" |
| 18 | + "dkml-base-compiler" |
| 19 | + "ocaml-base-compiler" |
| 20 | + "ocaml-variants" |
| 21 | + "ocaml-option-32bit" |
| 22 | +] |
| 23 | +build: [ |
| 24 | + # Homebrew's bundle tap, needed for reproducible build auditing in drc's crossplatform-functions.sh. |
| 25 | + # |
| 26 | + # The Opam sandbox will stop Homebrew from auto-installing its own tap. In particular 'brew bundle ...' |
| 27 | + # is automatically installed per https://github.com/Homebrew/homebrew-bundle/tree/4756e4c4cf95485c5ea4da27375946c1dac2c71d#installation, |
| 28 | + # and it is an "official" tap per |
| 29 | + # https://github.com/Homebrew/brew/blob/master/Library/Homebrew/official_taps.rb#L11-L18 . |
| 30 | + # |
| 31 | + # So our solution is to: |
| 32 | + # a) Use extra-source:[] to download a Git tarball without tripping over the sandbox firewall |
| 33 | + # b) Recreate a local file git repository |
| 34 | + # c) Use the next build:[] steps to let Homebrew know about the bundle tap |
| 35 | + # |
| 36 | + # Test with: brew untap homebrew/bundle |
| 37 | + ["install" "-d" "dl/homebrew-bundle"] {os = "macos"} |
| 38 | + ["tar" "xCfz" "dl/homebrew-bundle" "dl/homebrew-bundle.tar.gz" "--strip-components=1"] {os = "macos"} |
| 39 | + ["sh" "-c" """#!/bin/sh |
| 40 | + set -eufx |
| 41 | + if command -v brew; then |
| 42 | + eval $(brew shellenv) |
| 43 | + HOMEBREW_BREW_FILE="$(command -v brew)" |
| 44 | + HOMEBREW_LIBRARY="${HOMEBREW_REPOSITORY}/Library" |
| 45 | + HOMEBREW_PATH="$PATH" |
| 46 | + HOMEBREW_CACHE="$PWD/dl/homebrew-cache" |
| 47 | + export HOMEBREW_BREW_FILE HOMEBREW_PATH HOMEBREW_CACHE |
| 48 | + |
| 49 | + # Clone the Library which contains the Taps/ |
| 50 | + # (and also Homebrew/ which is all the core scripts). |
| 51 | + install -d dl/homebrew |
| 52 | + cp -a "$HOMEBREW_LIBRARY" dl/homebrew/ || true |
| 53 | + HOMEBREW_LIBRARY="$PWD/dl/homebrew/Library" |
| 54 | + export HOMEBREW_LIBRARY |
| 55 | + |
| 56 | + # Install the tap manually by copying it. If we had used |
| 57 | + # 'brew tap homebrew/bundle [URL]' or more specifically |
| 58 | + # '/bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" tap homebrew/bundle [URL]' |
| 59 | + # then brew would try to update its own configuration repository to say the tap was installed. |
| 60 | + # It would fail with 'error: could not lock config file .git/config: Operation not permitted' |
| 61 | + # because we are in a sandbox. We would have to ignore that error even though the tap was installed. |
| 62 | + # too many sandbox permissions, even with a file:// URL). |
| 63 | + install -d "${HOMEBREW_LIBRARY}/Taps/homebrew" |
| 64 | + cp -rp dl/homebrew-bundle "${HOMEBREW_LIBRARY}/Taps/homebrew/" |
| 65 | + |
| 66 | + /bin/bash "${HOMEBREW_LIBRARY}/Homebrew/brew.sh" bundle dump |
| 67 | + test -e Brewfile |
| 68 | + fi |
| 69 | + """] {os = "macos"} |
| 70 | + |
| 71 | + # Opam source code |
| 72 | + ["install" "-d" "dl/opam"] |
| 73 | + ["tar" "xCfz" "dl/opam" "dl/opam.tar.gz" "--strip-components=1"] |
| 74 | + |
| 75 | + # Create a DKMLDIR. Its structure mimics a git submodule setup. |
| 76 | + |
| 77 | + # <dkmldir>/vendor/drc/ |
| 78 | + ["install" "-d" "dkmldir/vendor/drc"] |
| 79 | + ["tar" "xCfz" "dkmldir/vendor/drc" "dl/dkml-runtime-common.tar.gz" "--strip-components=1"] |
| 80 | + # <dkmldir>/.dkmlroot |
| 81 | + ["install" "dkmldir/vendor/drc/.template.dkmlroot" "dkmldir/.dkmlroot"] |
| 82 | + |
| 83 | + # <dkmldir>/vendor/drd/ |
| 84 | + ["install" "-d" "dkmldir/vendor/drd"] |
| 85 | + ["tar" "xCfz" "dkmldir/vendor/drd" "dl/dkml-runtime-distribution.tar.gz" "--strip-components=1"] |
| 86 | + |
| 87 | + # <dkmldir>/vendor/dkml-compiler/ |
| 88 | + ["install" "-d" "dkmldir/vendor/dkml-compiler/src"] |
| 89 | + ["tar" "xCfz" "dkmldir/vendor/dkml-compiler" "dl/dkml-compiler.tar.gz" "--strip-components=1"] |
| 90 | + |
| 91 | + # We won't build any Dune projects in the dkml-runtime-distribution |
| 92 | + ["diskuvbox" "copy-file" "assets/dune.exclude-all" "dkmldir/vendor/drd/dune"] |
| 93 | + |
| 94 | + # [DEVELOPERS] |
| 95 | + # Rapid iteration ... customize the build scripts as needed. |
| 96 | + # ["diskuvbox" "copy-file" "r-c-opam-2-build.sh" "dkmldir/vendor/drd/src/unix/private/r-c-opam-2-build.sh"] |
| 97 | + |
| 98 | + # Run r-c-opam-1-setup |
| 99 | + [ |
| 100 | + "env" "TOPDIR=dkmldir/vendor/drc/all/emptytop" |
| 101 | + "DKML_REPRODUCIBLE_SYSTEM_BREWFILE=%{_:build}%/Brewfile" |
| 102 | + "dkmldir/vendor/drd/src/unix/private/r-c-opam-1-setup.sh" |
| 103 | + "-d" "dkmldir" |
| 104 | + "-t" "_w" |
| 105 | + "-v" "dl/opam" |
| 106 | + # Instead of letting Opam bootstrap its own OCaml compiler, we can just |
| 107 | + # tell it to use the OCaml home (ie. compiler in %{prefix}%/bin/ocamlc). |
| 108 | + # We don't have a "home" if ocaml-system is installed, but we do for |
| 109 | + # the base compilers. This will save time, reduce build errors and |
| 110 | + # dkml-base-compiler gives access to a cross compiler. |
| 111 | + "-c" { ocaml-base-compiler:installed | dkml-base-compiler:installed | ocaml-variants:installed } |
| 112 | + "%{prefix}%" { ocaml-base-compiler:installed | dkml-base-compiler:installed | ocaml-variants:installed } |
| 113 | + "-f" { ocaml-system:installed } |
| 114 | + "%{ocaml-system:path}%" { ocaml-system:installed } |
| 115 | + # Target ABIs |
| 116 | + "-awindows_x86" { os = "win32" & (ocaml-option-32bit:installed | arch = "x86_32") } |
| 117 | + "-alinux_x86" { os = "linux" & arch = "x86_32" } |
| 118 | + ] { (os = "linux" & arch = "x86_32") | |
| 119 | + (os = "win32" & (ocaml-option-32bit:installed | arch = "x86_32") ) } |
| 120 | + |
| 121 | + # Run r-c-opam-2-build-noargs.sh |
| 122 | + [ |
| 123 | + "sh" "-eufc" |
| 124 | + "cd _w && share/dkml/repro/110co/vendor/drd/src/unix/private/r-c-opam-2-build-noargs.sh" |
| 125 | + ] { (os = "linux" & arch = "x86_32") | |
| 126 | + (os = "win32" & (ocaml-option-32bit:installed | arch = "x86_32") ) } |
| 127 | + |
| 128 | + # -------------- |
| 129 | + # Build install library |
| 130 | + # -------------- |
| 131 | + |
| 132 | + ["dune" "subst"] {dev} |
| 133 | + [ |
| 134 | + "dune" |
| 135 | + "build" |
| 136 | + "-p" |
| 137 | + name |
| 138 | + "-j" |
| 139 | + jobs |
| 140 | + "--promote-install-files=false" |
| 141 | + "@install" |
| 142 | + "@runtest" {with-test} |
| 143 | + "@doc" {with-doc} |
| 144 | + ] |
| 145 | + ["dune" "install" "-p" name "--create-install-files" name] |
| 146 | +] |
| 147 | +install: [ |
| 148 | + [ |
| 149 | + "diskuvbox" |
| 150 | + "copy-file-into" |
| 151 | + "_w/bin/opam" |
| 152 | + "_w/bin/opam-installer" |
| 153 | + "%{_:share}%/staging-files/linux_x86/bin" |
| 154 | + ] { (os = "linux" & arch = "x86_32") } |
| 155 | + [ |
| 156 | + "diskuvbox" |
| 157 | + "copy-file-into" |
| 158 | + "_w/bin/opam.exe" |
| 159 | + "_w/bin/opam-installer.exe" |
| 160 | + "%{_:share}%/staging-files/windows_x86/bin" |
| 161 | + ] { (os = "win32" & (ocaml-option-32bit:installed | arch = "x86_32") ) } |
| 162 | + |
| 163 | + [ |
| 164 | + "diskuvbox" |
| 165 | + "copy-file-into" |
| 166 | + "_w/bin/opam-putenv.exe" |
| 167 | + "%{_:share}%/staging-files/windows_x86/bin" |
| 168 | + ] { (os = "win32" & (ocaml-option-32bit:installed | arch = "x86_32") ) } |
| 169 | + |
| 170 | + [ |
| 171 | + "diskuvbox" |
| 172 | + "copy-dir" |
| 173 | + "_w/share/man" |
| 174 | + "%{_:share}%/staging-files/generic/man" |
| 175 | + ] { (os = "linux" & arch = "x86_32") | |
| 176 | + (os = "win32" & (ocaml-option-32bit:installed | arch = "x86_32") ) } |
| 177 | +] |
| 178 | +dev-repo: "git+https://github.com/diskuv/dkml-component-ocamlcompiler.git" |
| 179 | +extra-source "dl/dkml-compiler.tar.gz" { |
| 180 | + src: "https://github.com/diskuv/dkml-compiler/archive/refs/tags/4.12.1-v1.0.0.tar.gz" |
| 181 | + checksum: [ |
| 182 | + "sha256=b4850314ea64d357ce814faebc1f1ef54052e76ea048602401f481cf6bf40455" |
| 183 | + ] |
| 184 | +} |
| 185 | +extra-source "dl/opam.tar.gz" { |
| 186 | + src: "https://github.com/jonahbeckford/opam/archive/refs/tags/2.2.0-dkml20220801T155940Z.tar.gz" |
| 187 | + checksum: [ |
| 188 | + "sha256=1f23dbef45bf31deaf23bfa463eeea6ce6a253e303f38b9be6b165cfb264daaf" |
| 189 | + ] |
| 190 | +} |
| 191 | +extra-source "dl/homebrew-bundle.tar.gz" { |
| 192 | + src: "https://github.com/Homebrew/homebrew-bundle/archive/4756e4c4cf95485c5ea4da27375946c1dac2c71d.tar.gz" |
| 193 | + checksum: [ |
| 194 | + "sha256=10c024ca7871cea36b4c27b2601971d3fa6cba6f37855613baf0026d0f555e76" |
| 195 | + ] |
| 196 | +} |
| 197 | + |
| 198 | +# ------------------- |
| 199 | +# BEGIN OPAM ARCHIVES |
| 200 | +# |
| 201 | +# Since we don't have network access in sandboxes, we can't let `make -C src_ext cache-archives` |
| 202 | +# actual download. Use extra-source instead. |
| 203 | +# |
| 204 | +# This section can be autogenerated within dl/opam using: |
| 205 | +# join <(awk '$1~/^URL_[a-z]/{sub(/URL_/,"",$1); print $1,"URL",$NF}' src_ext/Makefile src_ext/Makefile.sources) <(awk '$1~/^MD5_[a-z]/{sub(/MD5_/,"",$1); print $1,"MD5",$NF}' src_ext/Makefile src_ext/Makefile.sources) | awk -v dq='"' '$2=="URL" && $4=="MD5"{name=$3; sub(".*/", "",name); printf "extra-source %sdl/opam/src_ext/archives/%s%s {\n src: %s%s%s\n checksum: [\n %smd5=%s%s\n ]\n}\n", dq,name,dq, dq,$3,dq, dq,$5,dq }' |
| 206 | + |
| 207 | +extra-source "dl/opam/src_ext/archives/ocaml-4.13.1.tar.gz" { |
| 208 | + src: "https://caml.inria.fr/pub/distrib/ocaml-4.13/ocaml-4.13.1.tar.gz" |
| 209 | + checksum: [ |
| 210 | + "md5=a55ca12a4e6edf83cb4777abdb7b2f4d" |
| 211 | + ] |
| 212 | +} |
| 213 | +extra-source "dl/opam/src_ext/archives/0.40.tar.gz" { |
| 214 | + src: "https://github.com/alainfrisch/flexdll/archive/0.40.tar.gz" |
| 215 | + checksum: [ |
| 216 | + "md5=e68f7311179fa7e09408825b362c5c5a" |
| 217 | + ] |
| 218 | +} |
| 219 | +extra-source "dl/opam/src_ext/archives/v1.6.8.tar.gz" { |
| 220 | + src: "https://github.com/ocaml-community/cppo/archive/v1.6.8.tar.gz" |
| 221 | + checksum: [ |
| 222 | + "md5=fed401197d86f9089e89f6cbdf1d660d" |
| 223 | + ] |
| 224 | +} |
| 225 | +extra-source "dl/opam/src_ext/archives/extlib-1.7.8.tar.gz" { |
| 226 | + src: "https://ygrek.org/p/release/ocaml-extlib/extlib-1.7.8.tar.gz" |
| 227 | + checksum: [ |
| 228 | + "md5=7e0df072af4e2daa094e5936a661cb11" |
| 229 | + ] |
| 230 | +} |
| 231 | +extra-source "dl/opam/src_ext/archives/base64-v3.5.0.tbz" { |
| 232 | + src: "https://github.com/mirage/ocaml-base64/releases/download/v3.5.0/base64-v3.5.0.tbz" |
| 233 | + checksum: [ |
| 234 | + "md5=0179af18d6c1cf13d77671ee23901433" |
| 235 | + ] |
| 236 | +} |
| 237 | +extra-source "dl/opam/src_ext/archives/re-1.10.3.tbz" { |
| 238 | + src: "https://github.com/ocaml/ocaml-re/releases/download/1.10.3/re-1.10.3.tbz" |
| 239 | + checksum: [ |
| 240 | + "md5=a36347dcfaf71c95916f96f72b0cf2ce" |
| 241 | + ] |
| 242 | +} |
| 243 | +extra-source "dl/opam/src_ext/archives/cmdliner-1.0.4.tbz" { |
| 244 | + src: "http://erratique.ch/software/cmdliner/releases/cmdliner-1.0.4.tbz" |
| 245 | + checksum: [ |
| 246 | + "md5=fe2213d0bc63b1e10a2d0aa66d2fc8d9" |
| 247 | + ] |
| 248 | +} |
| 249 | +extra-source "dl/opam/src_ext/archives/ocamlgraph-2.0.0.tbz" { |
| 250 | + src: "https://github.com/backtracking/ocamlgraph/releases/download/2.0.0/ocamlgraph-2.0.0.tbz" |
| 251 | + checksum: [ |
| 252 | + "md5=2d07fcf3501e1d4997c03fa94cea22f0" |
| 253 | + ] |
| 254 | +} |
| 255 | +extra-source "dl/opam/src_ext/archives/cudf-v0.10.tar.gz" { |
| 256 | + # src: "https://gitlab.com/irill/cudf/-/archive/v0.10/cudf-v0.10.tar.gz" |
| 257 | + # checksum: [ |
| 258 | + # "md5=ed8fea314d0c6dc0d8811ccf860c53dd" |
| 259 | + # ] |
| 260 | + src: "https://github.com/diskuv/dkml-component-opam/releases/download/v0.0.0-dependencies/cudf-v0.10.tar.gz" |
| 261 | + checksum: [ |
| 262 | + "sha256=7b9d7390fca822afd8b35197814616088edfb3fa3cb44903dfa49399e9fefb50" |
| 263 | + ] |
| 264 | +} |
| 265 | +extra-source "dl/opam/src_ext/archives/dose3-7.0.0.tar.gz" { |
| 266 | + # src: "https://gitlab.com/irill/dose3/-/archive/7.0.0/dose3-7.0.0.tar.gz" |
| 267 | + # checksum: [ |
| 268 | + # "md5=bc99cbcea8fca29dca3ebbee54be45e1" |
| 269 | + # ] |
| 270 | + src: "https://github.com/diskuv/dkml-component-opam/releases/download/v0.0.0-dependencies/dose3-7.0.0.tar.gz" |
| 271 | + checksum: [ |
| 272 | + "sha256=02db6104db2683483f8309c76e77705b2606803fc5b58ea0a402f9da30a56029" |
| 273 | + ] |
| 274 | +} |
| 275 | +extra-source "dl/opam/src_ext/archives/1.1+13.tar.gz" { |
| 276 | + src: "https://github.com/AltGr/ocaml-mccs/archive/1.1+13.tar.gz" |
| 277 | + checksum: [ |
| 278 | + "md5=13504d3b5dcbf0bdc6d95a62de20af4a" |
| 279 | + ] |
| 280 | +} |
| 281 | +extra-source "dl/opam/src_ext/archives/opam-0install-cudf-v0.4.2.tbz" { |
| 282 | + src: "https://github.com/ocaml-opam/opam-0install-solver/releases/download/v0.4.2/opam-0install-cudf-v0.4.2.tbz" |
| 283 | + checksum: [ |
| 284 | + "md5=8e1494e8b97fc6f9a463966c394e9bdd" |
| 285 | + ] |
| 286 | +} |
| 287 | +extra-source "dl/opam/src_ext/archives/0install-v2.17.tbz" { |
| 288 | + src: "https://github.com/0install/0install/releases/download/v2.17/0install-v2.17.tbz" |
| 289 | + checksum: [ |
| 290 | + "md5=50daf035b04b29399a3c6e6f965ac447" |
| 291 | + ] |
| 292 | +} |
| 293 | +extra-source "dl/opam/src_ext/archives/2.1.4.tar.gz" { |
| 294 | + src: "https://github.com/ocaml/opam-file-format/archive/2.1.4.tar.gz" |
| 295 | + checksum: [ |
| 296 | + "md5=cd9dac41c2153d07067c5f30cdcf77db" |
| 297 | + ] |
| 298 | +} |
| 299 | +extra-source "dl/opam/src_ext/archives/result-1.5.tbz" { |
| 300 | + src: "https://github.com/janestreet/result/releases/download/1.5/result-1.5.tbz" |
| 301 | + checksum: [ |
| 302 | + "md5=1b82dec78849680b49ae9a8a365b831b" |
| 303 | + ] |
| 304 | +} |
| 305 | +extra-source "dl/opam/src_ext/archives/0.2.2.tar.gz" { |
| 306 | + src: "https://github.com/c-cube/seq/archive/0.2.2.tar.gz" |
| 307 | + checksum: [ |
| 308 | + "md5=9033e02283aa3bde9f97f24e632902e3" |
| 309 | + ] |
| 310 | +} |
| 311 | +extra-source "dl/opam/src_ext/archives/stdlib-shims-0.3.0.tbz" { |
| 312 | + src: "https://github.com/ocaml/stdlib-shims/releases/download/0.3.0/stdlib-shims-0.3.0.tbz" |
| 313 | + checksum: [ |
| 314 | + "md5=09db7af8b4a3a96048a61cb6ae2496ef" |
| 315 | + ] |
| 316 | +} |
| 317 | +extra-source "dl/opam/src_ext/archives/spdx_licenses-v1.1.0.tbz" { |
| 318 | + src: "https://github.com/kit-ty-kate/spdx_licenses/releases/download/v1.1.0/spdx_licenses-v1.1.0.tbz" |
| 319 | + checksum: [ |
| 320 | + "md5=af8493759aa35b629a324caa3f5ced65" |
| 321 | + ] |
| 322 | +} |
| 323 | +extra-source "dl/opam/src_ext/archives/uutf-1.0.3.tbz" { |
| 324 | + src: "https://erratique.ch/software/uutf/releases/uutf-1.0.3.tbz" |
| 325 | + checksum: [ |
| 326 | + "md5=a308285514259d20b48abc92f00a3708" |
| 327 | + ] |
| 328 | +} |
| 329 | +extra-source "dl/opam/src_ext/archives/jsonm-1.0.1.tbz" { |
| 330 | + src: "http://erratique.ch/software/jsonm/releases/jsonm-1.0.1.tbz" |
| 331 | + checksum: [ |
| 332 | + "md5=e2ca39eaefd55b8d155c4f1ec5885311" |
| 333 | + ] |
| 334 | +} |
| 335 | +extra-source "dl/opam/src_ext/archives/sha-1.15.2.tbz" { |
| 336 | + src: "https://github.com/djs55/ocaml-sha/releases/download/1.15.2/sha-1.15.2.tbz" |
| 337 | + checksum: [ |
| 338 | + "md5=b78eea17a52b705b5a068fc7f5b6c6ae" |
| 339 | + ] |
| 340 | +} |
| 341 | + |
| 342 | +# END OPAM ARCHIVES |
| 343 | +# ------------------- |
| 344 | +extra-source "dl/dkml-runtime-common.tar.gz" { |
| 345 | + # This violates the v1.0.0 versioning, but this future patch is needed to allow the 'bundle' |
| 346 | + # brew tap to be used on macOS in the Opam sandbox. |
| 347 | + src: "https://github.com/diskuv/dkml-runtime-common/archive/refs/tags/v1.0.1-prerel0b.tar.gz" |
| 348 | + checksum: [ |
| 349 | + "sha256=563b89382f07a4ce56917a8eb7034c5fa6993572f087ad909e58229e78748056" |
| 350 | + ] |
| 351 | +} |
| 352 | +extra-source "dl/dkml-runtime-distribution.tar.gz" { |
| 353 | + src: "https://github.com/diskuv/dkml-runtime-distribution/archive/refs/tags/v1.0.0.tar.gz" |
| 354 | + checksum: [ |
| 355 | + "sha256=bface5c975172f3d07636e5207806e8c0e43928ada1643ee3a2d4044c6fe6beb" |
| 356 | + ] |
| 357 | +} |
| 358 | +url { |
| 359 | + src: |
| 360 | + "https://github.com/diskuv/dkml-component-opam/archive/v2.2.0-dkml20220801.tar.gz" |
| 361 | + checksum: [ |
| 362 | + "md5=985afb173c7f038c54e584e133a19850" |
| 363 | + "sha512=d6e1641730df18668e221fb7d108de3646acdcf75850d12d1948cfc22d458ca95e0d86820b654f37af38ceb168e9e548e12c7d2315a6e8904f88f8d6f8187904" |
| 364 | + ] |
| 365 | +} |
0 commit comments