Skip to content

Commit 4c57e53

Browse files
committed
Merge bitcoin/bitcoin#28138: ci: Keep system env vars as-is (bugfix)
fabc04a ci: Keep system env vars as-is (MarcoFalke) fa8dcdc ci: Set PATH inside the CI env (MarcoFalke) fac229a ci: Remove P_CI_DIR and --workdir (MarcoFalke) Pull request description: This fixes a bug where the `$PATH` from the host is used inside the container. This will lead to bugs when the `$PATH` is different. For example on a host of Fedora 38, and a container of `debian:bullseye`. This can be tested with the `FILE_ENV=./ci/test/00_setup_env_arm.sh` CI env. On master: ``` Error: crun: executable file `bash` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found ``` On this pull: (everything passes) ACKs for top commit: TheCharlatan: lgtm ACK fabc04a Tree-SHA512: 51d2affed91624d0e5b43a3ee1e696313f934e05fde6b5a19e8ac4e6666c1e7b667a444bf3de3f77190bcd00e81efb7576196afb0f6b5e788d1a50e7ddb28d7e
2 parents 42a9110 + fabc04a commit 4c57e53

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

ci/lint/04_install.sh

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
export LC_ALL=C
88

9+
export PATH=$PWD/ci/retry:$PATH
10+
911
${CI_RETRY_EXE} apt-get update
1012
# Lint dependencies:
1113
# - curl/xz-utils (to install shellcheck)

ci/test/00_setup_env.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ export BASE_ROOT_DIR
1515
# The depends dir.
1616
# This folder exists only on the ci guest, and on the ci host as a volume.
1717
export DEPENDS_DIR=${DEPENDS_DIR:-$BASE_ROOT_DIR/depends}
18-
# A folder for the ci system to put temporary files (ccache, datadirs for tests, ...)
19-
# This folder only exists on the ci host.
18+
# A folder for the ci system to put temporary files (build result, datadirs for tests, ...)
19+
# This folder only exists on the ci guest.
2020
export BASE_SCRATCH_DIR=${BASE_SCRATCH_DIR:-$BASE_ROOT_DIR/ci/scratch}
21+
# A folder for the ci system to put executables.
22+
# This folder only exists on the ci guest.
23+
export BINS_SCRATCH_DIR="${BASE_SCRATCH_DIR}/bins/"
2124

2225
echo "Setting specific values in env"
2326
if [ -n "${FILE_ENV}" ]; then
@@ -69,5 +72,4 @@ export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
6972
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git procps bison}
7073
export GOAL=${GOAL:-install}
7174
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
72-
export PATH=${BASE_ROOT_DIR}/ci/retry:$PATH
7375
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}

ci/test/04_install.sh

+5-7
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ if [[ $BITCOIN_CONFIG = *--with-sanitizers=*address* ]]; then # If ran with (ASa
2222
CI_CONTAINER_CAP="--cap-add SYS_PTRACE"
2323
fi
2424

25-
export P_CI_DIR="$PWD"
26-
export BINS_SCRATCH_DIR="${BASE_SCRATCH_DIR}/bins/"
27-
2825
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
2926
# Export all env vars to avoid missing some.
3027
# Though, exclude those with newlines to avoid parsing problems.
31-
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" not in key]' | tee /tmp/env
28+
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee /tmp/env
29+
# System-dependent env vars must be kept as is. So read them from the container.
30+
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append /tmp/env
3231
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
33-
DOCKER_BUILDKIT=1 ${CI_RETRY_EXE} docker build \
32+
DOCKER_BUILDKIT=1 docker build \
3433
--file "${BASE_ROOT_DIR}/ci/test_imagefile" \
3534
--build-arg "CI_IMAGE_NAME_TAG=${CI_IMAGE_NAME_TAG}" \
3635
--build-arg "FILE_ENV=${FILE_ENV}" \
@@ -53,7 +52,6 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
5352
--mount "type=volume,src=${CONTAINER_NAME}_ccache,dst=$CCACHE_DIR" \
5453
--mount "type=volume,src=${CONTAINER_NAME}_depends,dst=$DEPENDS_DIR" \
5554
--mount "type=volume,src=${CONTAINER_NAME}_previous_releases,dst=$PREVIOUS_RELEASES_DIR" \
56-
-w $BASE_ROOT_DIR \
5755
--env-file /tmp/env \
5856
--name $CONTAINER_NAME \
5957
$CONTAINER_NAME)
@@ -64,7 +62,7 @@ else
6462
fi
6563

6664
CI_EXEC () {
67-
$CI_EXEC_CMD_PREFIX bash -c "export PATH=${BINS_SCRATCH_DIR}:\$PATH && cd \"$P_CI_DIR\" && $*"
65+
$CI_EXEC_CMD_PREFIX bash -c "export PATH=${BINS_SCRATCH_DIR}:${BASE_ROOT_DIR}/ci/retry:\$PATH && cd \"${BASE_ROOT_DIR}\" && $*"
6866
}
6967
export -f CI_EXEC
7068

0 commit comments

Comments
 (0)