aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNP-Hardass <np.hardass@gmail.com>2017-03-27 16:01:51 -0400
committerNP-Hardass <np.hardass@gmail.com>2017-03-27 16:01:51 -0400
commitd97aa2b5e45633aa1a9ebf08eb2adf3cd2aa717a (patch)
tree2af46870c1e39576f055598488411d3990dfc4f0
parentwine.eselect: Better error handling for adding and removing symlinks (diff)
downloadeselect-wine-d97aa2b5e45633aa1a9ebf08eb2adf3cd2aa717a.tar.gz
eselect-wine-d97aa2b5e45633aa1a9ebf08eb2adf3cd2aa717a.tar.bz2
eselect-wine-d97aa2b5e45633aa1a9ebf08eb2adf3cd2aa717a.zip
wine.eselect: verify symlinks are valid
-rw-r--r--wine.eselect59
1 files changed, 53 insertions, 6 deletions
diff --git a/wine.eselect b/wine.eselect
index bf835f1..8bdd06a 100644
--- a/wine.eselect
+++ b/wine.eselect
@@ -66,7 +66,13 @@ are_symlinks_valid() {
shift
done
- local active=$(load_config "${CONFIG_DIR}/active" ${v})
+ local v_arg
+ if [[ ${v} != "wine" ]]; then
+ v_arg="--${v}"
+ fi
+
+ local active=$(get_active ${v_arg})
+ local tgt="${active}"
if [[ "${active}" == "(unset)" ]]; then
write_error_message "Invalid active config"
return 1
@@ -74,7 +80,52 @@ are_symlinks_valid() {
set_dir_env
- #TODO check links manually and by config
+ local possible_vars=( bin man )
+ local symlink_vars=$(load_config "${CONFIG_DIR}/links/${v}" symlink_dirs)
+ if [[ -z "${symlink_vars}" ]]; then
+ die -q "Missing any configured symlink_dirs"
+ fi
+ local var
+
+ for var in ${possible_vars[@]}; do
+ if has ${var} ${symlink_vars[@]}; then
+ symlink_vars=$(list_rm_item "${var}" "${symlink_vars}")
+ else
+ write_warning_message "Missing '${var}' in ${v} config"
+ write_warning_message "Might want to re-run set or update"
+ fi
+ done
+ if [[ ! -z ${symlink_vars} ]]; then
+ die -q "Config contains unknown symlink_dirs ${symlink_vars}"
+ fi
+
+ symlink_vars=$(load_config "${CONFIG_DIR}/links/${v}" symlink_dirs)
+ for var in ${symlink_vars[@]}; do
+ local symlinks=$(load_config "${CONFIG_DIR}/links/${v}" ${var})
+ local symlink
+
+ if [[ -z "${symlinks}" ]]; then
+ die -q "Missing listing of ${var} symlinks"
+ fi
+ for symlink in ${symlinks[@]}; do
+ if [[ ! -L ${symlink} ]]; then
+ die -q "${symlink} is not a symlink"
+ else
+ local file=$(canonicalise ${symlink})
+ if [[ ! -e "${file}" ]]; then
+ die -q "${symlink} points to nonexistant ${file}"
+ else
+ eval path=\${wine_${var}}
+ path=$(canonicalise "${path}")
+ if [[ "${file}" != "${path%/}"/* ]]; then
+ write_error_msg "${symlink} points to ${file}"
+ die -q "which doesn't appear to be part of wine"
+ fi
+ fi
+ fi
+ done
+ done
+
unset_dir_env
}
@@ -660,10 +711,6 @@ remove_symlinks() {
v_arg="--${v}"
fi
- if ! are_symlinks_valid ${v_arg}; then
- die -q "Currently configured symlinks are invalid"
- fi
-
local symlink_vars=$(load_config "${CONFIG_DIR}/links/${v}" symlink_dirs)
if [[ -z "${symlink_vars}" ]]; then
die -q "Missing listing of configured symlinks"