Skip to content

Commit d77dbe2

Browse files
authored
Merge pull request #53 from AleixMT/dynamic_unload_#46
Dynamic unload #46
2 parents 4c3254b + c6380b5 commit d77dbe2

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/core/functions_common.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,42 @@ load_feature_properties()
276276
fi
277277
}
278278

279+
280+
# - Description: Unloads properties loaded from the ${FEATURE_KEYNAME}.dat.sh and functions from the
281+
# ${FEATURE_KEYNAME}.func.sh
282+
# - Permissions: Can be executed indifferently as root or user.
283+
# - Argument 1: Keyname of the properties to unload.
284+
unload_feature_properties()
285+
{
286+
# Unload functions
287+
unset -f "$1_install_pre"
288+
unset -f "$1_install_mid"
289+
unset -f "$1_install_post"
290+
unset -f "$1_uninstall_pre"
291+
unset -f "$1_uninstall_mid"
292+
unset -f "$1_uninstall_post"
293+
294+
# Unload properties from the .dat.sh
295+
if [ -f "${CUSTOMIZER_PROJECT_FOLDER}/data/features/$1/$1.dat.sh" ]; then
296+
# Select non-commentary lines
297+
while read -r line; do
298+
local variable
299+
variable="$(echo "${line}" | grep -v "^[[:blank:]]*#" | cut -d "=" -f1)"
300+
if [ -z "${variable}" ]; then
301+
continue
302+
fi
303+
unset "${variable}"
304+
done < "${CUSTOMIZER_PROJECT_FOLDER}/data/features/$1/$1.dat.sh"
305+
else
306+
output_proxy_executioner "Properties of $1 feature have not been found, so they can not be unloaded. The file
307+
${CUSTOMIZER_PROJECT_FOLDER}/data/features/$1/$1.dat.sh does not exist. " "ERROR"
308+
fi
309+
310+
# Finally unset ${FEATURENAME}_flagsruntime, which is a dynamically declared variable
311+
unset "$1_flagsruntime"
312+
}
313+
314+
279315
# - Description: Performs a post-install clean by using cleaning option of package manager
280316
# - Permission: Can be called as root or user.
281317
post_install_clean()
@@ -918,6 +954,9 @@ execute_installation()
918954
load_feature_properties "${CURRENT_INSTALLATION_KEYNAME}"
919955

920956
output_proxy_executioner "generic_installation ${keyname}" "COMMAND"
957+
958+
unload_feature_properties "${CURRENT_INSTALLATION_KEYNAME}"
959+
921960
output_proxy_executioner "${keyname} ${FLAG_MODE}ed." "INFO"
922961

923962
# Return flag errors to bash defaults (ignore errors)

0 commit comments

Comments
 (0)