@@ -168,12 +168,58 @@ COMMON_ARGS+=("--mode" "run")
168
168
# make sure to use the same parent dir for storing tarballs of tmp
169
169
PREVIOUS_TMP_DIR=${PWD} /previous_tmp
170
170
171
+ # prepare arguments to install_software_layer.sh (specific to build step)
172
+ declare -a BUILD_STEP_ARGS=()
173
+ declare -a INSTALL_SCRIPT_ARGS=()
174
+ declare -a REMOVAL_SCRIPT_ARGS=()
175
+ if [[ ${EESSI_SOFTWARE_SUBDIR_OVERRIDE} =~ .* /generic$ ]]; then
176
+ INSTALL_SCRIPT_ARGS+=(" --generic" )
177
+ REMOVAL_SCRIPT_ARGS+=(" --generic" )
178
+ fi
179
+ [[ ! -z ${BUILD_LOGS_DIR} ]] && INSTALL_SCRIPT_ARGS+=(" --build-logs-dir" " ${BUILD_LOGS_DIR} " )
180
+ [[ ! -z ${SHARED_FS_PATH} ]] && INSTALL_SCRIPT_ARGS+=(" --shared-fs-path" " ${SHARED_FS_PATH} " )
181
+
182
+ # determine if the removal step has to be run
183
+ # assume there's only one diff file that corresponds to the PR patch file
184
+ pr_diff=$( ls [0-9]* .diff | head -1)
185
+ # the true at the end of the next command is important: grep will expectedly return 1 if there is no easystack file being added under rebuilds,
186
+ # but due to "set -e" the entire script would otherwise fail
187
+ changed_easystacks_rebuilds=$( cat ${pr_diff} | grep ' ^+++' | cut -f2 -d' ' | sed ' s@^[a-z]/@@g' | grep ' ^easystacks/.*yml$' | (grep " /rebuilds/" || true))
188
+ if [[ -z " ${changed_easystacks_rebuilds} " ]]; then
189
+ echo " This PR does not add any easystack files in a rebuilds subdirectory, so let's skip the removal step."
190
+ else
191
+ # prepare directory to store tarball of tmp for removal and build steps
192
+ TARBALL_TMP_REMOVAL_STEP_DIR=${PREVIOUS_TMP_DIR} /removal_step
193
+ mkdir -p ${TARBALL_TMP_REMOVAL_STEP_DIR}
194
+
195
+ # prepare arguments to eessi_container.sh specific to remove step
196
+ declare -a REMOVAL_STEP_ARGS=()
197
+ REMOVAL_STEP_ARGS+=(" --save" " ${TARBALL_TMP_REMOVAL_STEP_DIR} " )
198
+ REMOVAL_STEP_ARGS+=(" --storage" " ${STORAGE} " )
199
+ # add fakeroot option in order to be able to remove software, see:
200
+ # https://github.com/EESSI/software-layer/issues/312
201
+ REMOVAL_STEP_ARGS+=(" --fakeroot" )
202
+
203
+ # create tmp file for output of removal step
204
+ removal_outerr=$( mktemp remove.outerr.XXXX)
205
+
206
+ echo " Executing command to remove software:"
207
+ echo " ./eessi_container.sh ${COMMON_ARGS[@]} ${REMOVAL_STEP_ARGS[@]} "
208
+ echo " -- ./EESSI-remove-software.sh \" ${REMOVAL_SCRIPT_ARGS[@]} \" \" $@ \" 2>&1 | tee -a ${removal_outerr} "
209
+ ./eessi_container.sh " ${COMMON_ARGS[@]} " " ${REMOVAL_STEP_ARGS[@]} " \
210
+ -- ./EESSI-remove-software.sh " ${REMOVAL_SCRIPT_ARGS[@]} " " $@ " 2>&1 | tee -a ${removal_outerr}
211
+
212
+ # make sure that the build step resumes from the same temporary directory
213
+ # this is important, as otherwise the removed software will still be there
214
+ REMOVAL_TMPDIR=$( grep ' as tmp directory ' ${removal_outerr} | cut -d ' ' -f 2)
215
+ BUILD_STEP_ARGS+=(" --resume" " ${REMOVAL_TMPDIR} " )
216
+ fi
217
+
171
218
# prepare directory to store tarball of tmp for build step
172
219
TARBALL_TMP_BUILD_STEP_DIR=${PREVIOUS_TMP_DIR} /build_step
173
220
mkdir -p ${TARBALL_TMP_BUILD_STEP_DIR}
174
221
175
222
# prepare arguments to eessi_container.sh specific to build step
176
- declare -a BUILD_STEP_ARGS=()
177
223
BUILD_STEP_ARGS+=(" --save" " ${TARBALL_TMP_BUILD_STEP_DIR} " )
178
224
BUILD_STEP_ARGS+=(" --storage" " ${STORAGE} " )
179
225
# add options required to handle NVIDIA support
@@ -182,14 +228,6 @@ if [[ ! -z ${SHARED_FS_PATH} ]]; then
182
228
BUILD_STEP_ARGS+=(" --host-injections" " ${SHARED_FS_PATH} /host-injections" )
183
229
fi
184
230
185
- # prepare arguments to install_software_layer.sh (specific to build step)
186
- declare -a INSTALL_SCRIPT_ARGS=()
187
- if [[ ${EESSI_SOFTWARE_SUBDIR_OVERRIDE} =~ .* /generic$ ]]; then
188
- INSTALL_SCRIPT_ARGS+=(" --generic" )
189
- fi
190
- [[ ! -z ${BUILD_LOGS_DIR} ]] && INSTALL_SCRIPT_ARGS+=(" --build-logs-dir" " ${BUILD_LOGS_DIR} " )
191
- [[ ! -z ${SHARED_FS_PATH} ]] && INSTALL_SCRIPT_ARGS+=(" --shared-fs-path" " ${SHARED_FS_PATH} " )
192
-
193
231
# create tmp file for output of build step
194
232
build_outerr=$( mktemp build.outerr.XXXX)
195
233
@@ -211,8 +249,14 @@ declare -a TARBALL_STEP_ARGS=()
211
249
TARBALL_STEP_ARGS+=(" --save" " ${TARBALL_TMP_TARBALL_STEP_DIR} " )
212
250
213
251
# determine temporary directory to resume from
214
- BUILD_TMPDIR=$( grep ' as tmp directory ' ${build_outerr} | cut -d ' ' -f 2)
215
- TARBALL_STEP_ARGS+=(" --resume" " ${BUILD_TMPDIR} " )
252
+ if [[ -z ${REMOVAL_TMPDIR} ]]; then
253
+ # no rebuild step was done, so the tarball step should resume from the build directory
254
+ BUILD_TMPDIR=$( grep ' as tmp directory ' ${build_outerr} | cut -d ' ' -f 2)
255
+ TARBALL_STEP_ARGS+=(" --resume" " ${BUILD_TMPDIR} " )
256
+ else
257
+ # a removal step was done, so resume from its temporary directory (which was also used for the build step)
258
+ TARBALL_STEP_ARGS+=(" --resume" " ${REMOVAL_TMPDIR} " )
259
+ fi
216
260
217
261
timestamp=$( date +%s)
218
262
# to set EESSI_VERSION we need to source init/eessi_defaults now
0 commit comments