diff --git a/ecbundle/util.py b/ecbundle/util.py index 5417b02..20b650d 100644 --- a/ecbundle/util.py +++ b/ecbundle/util.py @@ -105,6 +105,7 @@ def symlink_force(target, link_name): # prefer relative symlink rather than absolute # check first if target is absolute or relative + target_orig = target if os.path.isabs(target): target = os.path.relpath(target, os.path.dirname(link_name)) @@ -117,6 +118,20 @@ def symlink_force(target, link_name): else: raise exc + # If a relative link is invalid, retry with absolute path if available + if not os.path.exists(link_name): + if target != target_orig: + os.remove(link_name) + os.symlink(target_orig, link_name) + + if not os.path.exists(link_name): + error( + "ERROR: Failed to create valid link from {0} to {1}".format( + link_name, target_orig + ) + ) + raise RuntimeError() + def copydir(src_dir, target_dir): import os diff --git a/tests/bundle_create/arch/.gitignore b/tests/bundle_create/arch/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/bundle_create/arch/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/bundle_install/arch/.gitignore b/tests/bundle_install/arch/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/tests/bundle_install/arch/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore