Browse Source

add hint about using BORG_LIBC to error messages

Thomas Waldmann 4 years ago
parent
commit
aaa4f518d2
1 changed files with 7 additions and 5 deletions
  1. 7 5
      src/borg/xattr.py

+ 7 - 5
src/borg/xattr.py

@@ -62,6 +62,10 @@ def get_all(path, follow_symlinks=True):
             return {}
             return {}
 
 
 
 
+HINT_MSG = "Try installing ldconfig, gcc/cc or objdump or use BORG_LIBC."
+LIBC_NOT_FOUND_NO_FALLBACK_MSG = "Can't find C library. No fallback known. " + HINT_MSG
+LIBC_NOT_FOUND_FNAME_MSG = "Can't find C library [%s]. " + HINT_MSG
+
 libc_name = os.environ.get('BORG_LIBC') or find_library('c')
 libc_name = os.environ.get('BORG_LIBC') or find_library('c')
 if libc_name is None:
 if libc_name is None:
     # find_library didn't work, maybe we are on some minimal system that misses essential
     # find_library didn't work, maybe we are on some minimal system that misses essential
@@ -74,9 +78,8 @@ if libc_name is None:
     elif sys.platform == 'darwin':
     elif sys.platform == 'darwin':
         libc_name = 'libc.dylib'
         libc_name = 'libc.dylib'
     else:
     else:
-        msg = "Can't find C library. No fallback known. Try installing ldconfig, gcc/cc or objdump."
-        print(msg, file=sys.stderr)  # logger isn't initialized at this stage
-        raise Exception(msg)
+        print(LIBC_NOT_FOUND_NO_FALLBACK_MSG, file=sys.stderr)  # logger isn't initialized at this stage
+        raise Exception(LIBC_NOT_FOUND_NO_FALLBACK_MSG)
 
 
 # If we are running with fakeroot on Linux, then use the xattr functions of fakeroot. This is needed by
 # If we are running with fakeroot on Linux, then use the xattr functions of fakeroot. This is needed by
 # the 'test_extract_capabilities' test, but also allows xattrs to work with fakeroot on Linux in normal use.
 # the 'test_extract_capabilities' test, but also allows xattrs to work with fakeroot on Linux in normal use.
@@ -102,8 +105,7 @@ if sys.platform.startswith('linux'):
 try:
 try:
     libc = CDLL(libc_name, use_errno=True)
     libc = CDLL(libc_name, use_errno=True)
 except OSError as e:
 except OSError as e:
-    msg = "Can't find C library [%s]. Try installing ldconfig, gcc/cc or objdump." % e
-    raise Exception(msg)
+    raise Exception(LIBC_NOT_FOUND_FNAME_MSG % e)
 
 
 
 
 def split_string0(buf):
 def split_string0(buf):