[backport] Fix cache corruption by scripts when layout and integration commands are used
Description
This is a backport of !934 (merged) to bst-1.2. It also contains !941 (merged).
This merge request, when approved, will close: #749 (closed)
Edited by Valentin David