separate toolchain.env and global.env. Allow env vars in global.env

This commit is contained in:
Lance Vick 2023-06-01 18:04:41 -07:00
parent 7b178a53ef
commit ee915227d5
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
3 changed files with 24 additions and 8 deletions

View File

@ -50,8 +50,8 @@ export
docker = docker
include $(CONFIG_DIR)/global.env
export $(shell sed 's/=.*//' $(CONFIG_DIR)/global.env)
include $(CONFIG_DIR)/toolchain.env
export $(shell sed 's/=.*//' $(CONFIG_DIR)/toolchain.env)
## Use env vars from existing release if present
ifneq (,$(wildcard $(DIST_DIR)/release.env))
@ -130,11 +130,22 @@ $(OUT_DIR):
mkdir -p $@
$(CACHE_DIR_ROOT)/toolchain.env: \
$(CACHE_DIR) \
$(SRC_DIR)/toolchain/scripts/environment
$(SRC_DIR)/toolchain/scripts/environment > $@
$(CACHE_DIR_ROOT)/toolchain.state
env > $(CACHE_DIR)/bootstrap.env
docker run \
--rm \
--env UID=$(UID) \
--env GID=$(GID) \
--env-file $(CACHE_DIR)/bootstrap.env \
--platform=linux/$(ARCH) \
--volume $(TOOLCHAIN_VOLUME) \
--workdir $(TOOLCHAIN_WORKDIR) \
$(shell cat cache/toolchain.state 2> /dev/null) \
$(SRC_DIR)/toolchain/scripts/environment > $@
rm $(CACHE_DIR)/bootstrap.env
$(CACHE_DIR_ROOT)/toolchain.tar: \
$(CONFIG_DIR)/toolchain.env \
$(SRC_DIR)/toolchain/Dockerfile \
$(CONFIG_DIR)/toolchain/package-hashes-$(ARCH).txt \
$(CONFIG_DIR)/toolchain/packages-base.list \
@ -222,7 +233,7 @@ endef
define toolchain
docker run \
--rm \
--rm \
--tty \
$(2) \
--env UID=$(UID) \
@ -232,7 +243,6 @@ define toolchain
--cpus $(CPUS) \
--volume $(TOOLCHAIN_VOLUME) \
--workdir $(TOOLCHAIN_WORKDIR) \
--env-file=$(CONFIG_DIR)/global.env \
--env-file=$(CACHE_DIR_ROOT)/toolchain.env \
$(shell cat cache/toolchain.state 2> /dev/null) \
$(SRC_DIR)/toolchain/scripts/host-env bash -c $(1)

View File

@ -1,6 +1,10 @@
#!/bin/sh
HOME=/home/build
CONFIG_DIR=/home/build/config
cat ${CONFIG_DIR}/toolchain.env
cat <<- EOF
HOME=${HOME}
PATH=${HOME}/${BIN_DIR}:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
@ -33,3 +37,5 @@ cat <<- EOF
BIN_DIR=${HOME}/${BIN_DIR}
FETCH_DIR=${HOME}/${FETCH_DIR}
EOF
envsubst < ${CONFIG_DIR}/global.env

View File

@ -28,7 +28,7 @@ apt-get install -y --download-only --reinstall $( \
apt-get install \
-y \
--download-only \
sudo \
sudo gettext \
$(cat /config/toolchain/packages-base.list)
( cd /var/cache/apt/archives \