#297 Create bin wrapper for symlinks

This commit is contained in:
Filippo Squillace 2022-07-28 00:07:15 +02:00
parent 21b5e3fabb
commit 100b49c84d
2 changed files with 21 additions and 2 deletions

View file

@ -25,7 +25,10 @@ function create_wrappers() {
cd "${JUNEST_HOME}/usr/bin" || return 1
for file in *
do
[[ -x $file ]] || continue
[[ -d $file ]] && continue
# Symlinks outside junest appear as broken even though the are correct
# within a junest session. The following do not skip broken symlinks:
[[ -x $file || -L $file ]] || continue
if [[ -e ${JUNEST_HOME}/usr/bin_wrappers/$file ]] && ! $force
then
continue
@ -47,7 +50,7 @@ EOF
cd "${JUNEST_HOME}/usr/bin_wrappers" || return 1
for file in *
do
[[ -e ${JUNEST_HOME}/usr/bin/$file ]] || rm -f "$file"
[[ -e ${JUNEST_HOME}/usr/bin/$file || -L ${JUNEST_HOME}/usr/bin/$file ]] || rm -f "$file"
done
}

View file

@ -34,6 +34,22 @@ function test_create_wrappers_not_executable_file(){
assertTrue "myfile wrapper should not exist" "[ ! -x $JUNEST_HOME/usr/bin_wrappers/myfile ]"
}
function test_create_wrappers_directory(){
mkdir -p "$JUNEST_HOME"/usr/bin/mydir
assertCommandSuccess create_wrappers
assertEquals "" "$(cat "$STDOUTF")"
assertTrue "bin_wrappers should exist" "[ -e $JUNEST_HOME/usr/bin_wrappers ]"
assertTrue "mydir wrapper should not exist" "[ ! -e $JUNEST_HOME/usr/bin_wrappers/mydir ]"
}
function test_create_wrappers_broken_link(){
ln -s /opt/myapp/bin/cmd "$JUNEST_HOME"/usr/bin/cmd
assertCommandSuccess create_wrappers
assertEquals "" "$(cat "$STDOUTF")"
assertTrue "bin_wrappers should exist" "[ -e $JUNEST_HOME/usr/bin_wrappers ]"
assertTrue "cmd wrapper should exist" "[ -x $JUNEST_HOME/usr/bin_wrappers/cmd ]"
}
function test_create_wrappers_executable_file(){
touch "$JUNEST_HOME"/usr/bin/myfile
chmod +x "$JUNEST_HOME"/usr/bin/myfile