88
99display_help () {
1010 echo " usage: $0 [OPTIONS]"
11+ echo " -d | --dry-run"
1112 echo " -g | --generic - instructs script to build for generic architecture target"
1213 echo " -h | --help - display this usage information"
1314}
@@ -16,6 +17,10 @@ POSITIONAL_ARGS=()
1617
1718while [[ $# -gt 0 ]]; do
1819 case $1 in
20+ -n|--dryrun)
21+ DRYRUN=1
22+ shift
23+ ;;
1924 -g|--generic)
2025 DETECTION_PARAMETERS=" --generic"
2126 shift
101106pr_diff=$( ls [0-9]* .diff | head -1)
102107
103108# if this script is run as root, use PR patch file to determine if software needs to be removed first
104- if [ $EUID -eq 0 ]; then
109+ if [[ $EUID -eq 0 ]] || [[ $DRYRUN -eq 1 ] ]; then
105110 changed_easystacks_rebuilds=$( cat ${pr_diff} | grep ' ^+++' | cut -f2 -d' ' | sed ' s@^[a-z]/@@g' | grep ' easystacks/.*yml$' | egrep -v ' known-issues|missing' | grep " /rebuilds/" )
106111 if [ -z ${changed_easystacks_rebuilds} ]; then
107112 echo " No software needs to be removed."
@@ -130,16 +135,20 @@ if [ $EUID -eq 0 ]; then
130135 app_dir=${app_installprefix} /software/${app}
131136 app_subdirs=$( find ${app_dir} -mindepth 1 -maxdepth 1 -type d)
132137 app_module=${app_installprefix} /modules/all/${app} .lua
133- echo_yellow " Removing ${app_dir} and ${app_module} ..."
134- rm -rf ${app_dir}
135- rm -rf ${app_module}
136- # recreate the installation directory and do an ls on the first-level subdirectories to work around
137- # permission issues when reinstalling the application (see https://github.com/EESSI/software-layer/issues/556)
138- echo_yellow " Recreating an empty ${app_dir} ..."
139- mkdir -p ${app_dir}
140- # these subdirs don't (and shouldn't) exist, but we need to do the ls anyway as a workaround,
141- # so redirect to /dev/null and ignore the exit code
142- ls ${app_subdirs} >& /dev/null || true
138+ if [[ $DRYRUN -eq 1 ]]; then
139+ echo " TO BE REMOVED: ${app_dir} "
140+ else
141+ echo_yellow " Removing ${app_dir} and ${app_module} ..."
142+ rm -rf ${app_dir}
143+ rm -rf ${app_module}
144+ # recreate the installation directory and do an ls on the first-level subdirectories to work around
145+ # permission issues when reinstalling the application (see https://github.com/EESSI/software-layer/issues/556)
146+ echo_yellow " Recreating an empty ${app_dir} ..."
147+ mkdir -p ${app_dir}
148+ # these subdirs don't (and shouldn't) exist, but we need to do the ls anyway as a workaround,
149+ # so redirect to /dev/null and ignore the exit code
150+ ls ${app_subdirs} >& /dev/null || true
151+ fi
143152 done
144153 else
145154 fatal_error " Easystack file ${easystack_file} not found!"
0 commit comments