# ctng-buildenv -- EVERY tool a build in its scope calls (the crosstool-ng bake, the kernel cascade, the box builders),
# as one relocated Alpine closure. Each builder SEALS its PATH to this bundle (provisioning sealToScope, plus the ccache
# host-compiler wrapper): nothing resolves from the host, so a host tool can never be
# picked up (a host autoheader on the host's perl broke a bake) and the bundle's env never reaches a foreign program.
# Landed in the scope of the project whose tools.manifest says `bundle ctng-buildenv` (os-generator kernel-flavors/linux).
#
# Several tools look for their data under the absolute /usr paths they were built with. `self-locate` makes every perl and
# sh script compute the bundle root from where it lies (provisioning rewrites their quoted /usr paths); `rooted` writes
# the bundle location into autom4te.cfg, a data file autom4te reads; the env lines cover the binaries (perl modules,
# bison and m4, file's magic, curl's certificates). ProvisioningIsolate.pm (glue, loaded via PERL5OPT) drops the host perl
# folders the perl binary carries at the end of @INC, so a module the bundle lacks fails instead of coming from the host.
kind bundle
self-locate
rooted usr/share/autoconf/autom4te.cfg
# the userland ct-ng's scripts and the package builds expect (GNU, not busybox applets)
package bash
package busybox-binsh   # /bin/sh (busybox ash): `#!/usr/bin/env sh` scripts (libtoolize) find sh on the sealed PATH
package coreutils
# Alpine splits these out of coreutils; only the listed packages' tools are projected into bin/ (ct-ng digests with sha512sum)
package coreutils-env
package coreutils-fmt
package coreutils-sha512sum
package findutils
package grep
package sed
package gawk
package diffutils
package make
package patch
package tar
package gzip
package xz
package bzip2
package zstd
package unzip
package file
package which
# binutils' configure finds ct-ng's own zstd through pkg-config (ct-ng sets PKG_CONFIG_PATH to its companion libs)
package pkgconf
# getconf: ct-ng counts the CPUs with `getconf _NPROCESSORS_ONLN`; without it every make runs -j1
package musl-utils
# the kernel: bc writes timeconst.h; lz4 compresses the image (020-minimize: KERNEL_LZ4)
package bc
package lz4
# linux >= 5.3 headers_install copies with rsync; without it ct-ng silently offers only kernel headers older than 5.3
package rsync
# host builds (gmp, mpfr, isl, ...) link with the plain binutils names
package binutils
# ct-ng downloads what is not pre-seeded
package curl
package ca-certificates
# parsers, docs, and the autotools a regenerated configure or config.h.in needs
package flex
package bison
package m4
package perl
package texinfo
package help2man
package autoconf
package automake
package libtool
env AUTOMAKE_LIBDIR=$ROOT/usr/share/automake-1.17
env BISON_PKGDATADIR=$ROOT/usr/share/bison
env M4=$ROOT/usr/bin/m4
env MAGIC=$ROOT/usr/share/misc/magic.mgc
env SSL_CERT_FILE=$ROOT/etc/ssl/certs/ca-certificates.crt
env CURL_CA_BUNDLE=$ROOT/etc/ssl/certs/ca-certificates.crt
glue ProvisioningIsolate.pm
env PERL5OPT=-MProvisioningIsolate
env PERL5LIB=$ROOT/.provisioning:$ROOT/usr/share/perl5/core_perl:$ROOT/usr/lib/perl5/core_perl:$ROOT/usr/share/perl5/vendor_perl:$ROOT/usr/lib/perl5/vendor_perl:$ROOT/usr/share/texinfo:$ROOT/usr/lib/texinfo
