If a build is interrupted, a standard mkdir command may fail if the directory already exists. Switching to mkdir -p ensures the build can resume gracefully.
Fix #34712.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | sedited |
If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.
I took a quick look at the failure mode shown in the issue log. Changing mkdir to mkdir -p does avoid the immediate “File exists” error, but I’m not sure it fully covers the interrupted-build case.
If the job gets killed while qtbase/qttranslations/qttools/cmake are being populated, those directories can be left half-extracted. On the rerun, mkdir -p will continue without failing, but the build may now proceed using a partially extracted tree, which could later show up as harder-to-trace configure or build errors.
One possible alternative would be to make the extract step explicitly restart-safe by clearing those directories before re-extracting, for example in both depends/packages/native_qt.mk and depends/packages/qt.mk:
0$(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \
1rm -rf qtbase qttranslations qttools cmake && \
2mkdir qtbase && \
3$(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source) -C qtbase && \
4mkdir qttranslations && \
5$(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \
6mkdir qttools && \
7$(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttools_file_name) -C qttools && \
8mkdir cmake && \
9cp ...
This does mean a rerun may redo the extraction work, but it guarantees that rerunning make starts from a clean extracted state instead of whatever was left behind after the interruption.
I tried this locally by interrupting the depends build during extraction and rerunning make, and it resumed cleanly using this approach as well.
I took a quick look at the failure mode shown in the issue log. Changing mkdir to mkdir -p does avoid the immediate “File exists” error, but I’m not sure it fully covers the interrupted-build case.
If the job gets killed while qtbase/qttranslations/qttools/cmake are being populated, those directories can be left half-extracted. On the rerun, mkdir -p will continue without failing, but the build may now proceed using a partially extracted tree, which could later show up as harder-to-trace configure or build errors.
One possible alternative would be to make the extract step explicitly restart-safe by clearing those directories before re-extracting, for example in both depends/packages/native_qt.mk and depends/packages/qt.mk:
0$(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ 1rm -rf qtbase qttranslations qttools cmake && \ 2mkdir qtbase && \ 3$(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source) -C qtbase && \ 4mkdir qttranslations && \ 5$(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \ 6mkdir qttools && \ 7$(build_TAR) --no-same-owner --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttools_file_name) -C qttools && \ 8mkdir cmake && \ 9cp ...This does mean a rerun may redo the extraction work, but it guarantees that rerunning make starts from a clean extracted state instead of whatever was left behind after the interruption.
I tried this locally by interrupting the depends build during extraction and rerunning make, and it resumed cleanly using this approach as well.
I’ll leave the branch as is for now, as it follows the current defaults:https://github.com/bitcoin/bitcoin/blob/01dcb2fcc5834071eb3cc1c1ad2f8c931d80e741/depends/funcs.mk#L125