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

View File

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

View File

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