test/init.sh: handle broken dir symlinks

This commit is contained in:
The MMGen Project 2023-11-21 15:30:42 +00:00
commit d0874f9a2d
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 13 additions and 6 deletions

View file

@ -1 +1 @@
3.2.dev7
3.2.dev8

View file

@ -12,7 +12,7 @@
test.cmdtest_py_d.cfg: configuration data for cmdtest.py
"""
import os
cmd_groups_altcoin = []
cmd_groups_dfl = {
'main': ('CmdTestMain',{}),
@ -29,4 +29,5 @@ cfgs = {
'3': {}, # main
}
def fixup_cfgs(): pass
def fixup_cfgs():
pass

View file

@ -47,9 +47,15 @@ build_mmgen_extmod() {
create_dir_links() {
for link_name in 'mmgen' 'scripts'; do
target="$wallet_repo/$link_name"
if [ -e $link_name ]; then
[ $(realpath --relative-to=. $link_name) == $target ] || die "'$link_name' does not point to '$target'"
else
if [ -L $link_name ]; then
[ "$(realpath --relative-to=. $link_name 2>/dev/null)" == $target ] || {
echo "Removing broken symlink '$link_name'"
rm $link_name
}
elif [ -e $link_name ]; then
die "'$link_name' is not a symbolic link. Please remove or relocate it and re-run this script"
fi
if [ ! -e $link_name ]; then
echo "Creating symlink: $link_name"
ln -s $target
fi