Skip to content

Commit a35af4f

Browse files
authored
Unrolled build for rust-lang#119165
Rollup merge of rust-lang#119165 - onur-ozkan:update-container-entrypoint, r=Kobzol improve container runner script First commit fixes rust-lang#118930 Second commit is mostly for development purposes. In read-only mode submodules cannot be initialized due to access limitations (see the log below), which means that tools cannot be built. ```sh Updating submodule src/tools/cargo error: could not lock config file .git/config: Read-only file system error: could not lock config file .git/config: Read-only file system fatal: Failed to register url for submodule path 'src/tools/cargo' error: could not lock config file .git/config: Read-only file system error: could not lock config file .git/config: Read-only file system fatal: Failed to register url for submodule path 'src/tools/cargo' Build completed unsuccessfully in 0:00:00 ```
2 parents cdd6374 + b498489 commit a35af4f

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/ci/docker/run.sh

+21-4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ root_dir="`dirname $src_dir`"
3636
objdir=$root_dir/obj
3737
dist=$objdir/build/dist
3838

39+
40+
if [ -d "$root_dir/.git" ]; then
41+
IS_GIT_SOURCE=1
42+
fi
43+
3944
source "$ci_dir/shared.sh"
4045

4146
CACHE_DOMAIN="${CACHE_DOMAIN:-ci-caches.rust-lang.org}"
@@ -194,6 +199,14 @@ else
194199
args="$args --env SCCACHE_DIR=/sccache --volume $HOME/.cache/sccache:/sccache"
195200
fi
196201

202+
# By default, container volumes are bound as read-only; therefore doing experimental work
203+
# or debugging within the container environment (such as fetching submodules and
204+
# building them) is not possible. Setting READ_ONLY_SRC to 0 enables this capability by
205+
# binding the volumes in read-write mode.
206+
if [ "$READ_ONLY_SRC" != "0" ]; then
207+
SRC_MOUNT_OPTION=":ro"
208+
fi
209+
197210
# Run containers as privileged as it should give them access to some more
198211
# syscalls such as ptrace and whatnot. In the upgrade to LLVM 5.0 it was
199212
# discovered that the leak sanitizer apparently needs these syscalls nowadays so
@@ -228,7 +241,7 @@ if [ -f /.dockerenv ]; then
228241
docker cp . checkout:/checkout
229242
args="$args --volumes-from checkout"
230243
else
231-
args="$args --volume $root_dir:/checkout:ro"
244+
args="$args --volume $root_dir:/checkout$SRC_MOUNT_OPTION"
232245
args="$args --volume $objdir:/checkout/obj"
233246
args="$args --volume $HOME/.cargo:/cargo"
234247
args="$args --volume $HOME/rustsrc:$HOME/rustsrc"
@@ -249,9 +262,13 @@ if [ "$dev" = "1" ]
249262
then
250263
# Interactive + TTY
251264
args="$args -it"
252-
command="/bin/bash"
265+
if [ $IS_GIT_SOURCE -eq 1 ]; then
266+
command=(/bin/bash -c 'git config --global --add safe.directory /checkout;bash')
267+
else
268+
command=(/bin/bash)
269+
fi
253270
else
254-
command="/checkout/src/ci/run.sh"
271+
command=(/checkout/src/ci/run.sh)
255272
fi
256273

257274
if [ "$CI" != "" ]; then
@@ -301,7 +318,7 @@ docker \
301318
--init \
302319
--rm \
303320
rust-ci \
304-
$command
321+
"${command[@]}"
305322

306323
cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}"
307324

0 commit comments

Comments
 (0)