From ee915227d502daccc4824d92623525973cec90d9 Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Thu, 1 Jun 2023 18:04:41 -0700 Subject: [PATCH] separate toolchain.env and global.env. Allow env vars in global.env --- Makefile | 24 +++++++++++++++++------- scripts/environment | 6 ++++++ scripts/packages-update | 2 +- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 96e1487..777c64a 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/scripts/environment b/scripts/environment index 2bb6cd2..ed939ce 100755 --- a/scripts/environment +++ b/scripts/environment @@ -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 diff --git a/scripts/packages-update b/scripts/packages-update index fa0b4f4..8e7bac8 100755 --- a/scripts/packages-update +++ b/scripts/packages-update @@ -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 \