Allow the script to be run from inside the packaging dir.
authorWayne Davison <wayne@opencoder.net>
Fri, 1 Oct 2021 20:23:30 +0000 (13:23 -0700)
committerWayne Davison <wayne@opencoder.net>
Fri, 1 Oct 2021 20:23:30 +0000 (13:23 -0700)
packaging/var-checker

index 11f99ef0bcca26859e7adc03af44d591d5690463..f17c69a296978c74eb8d0533acf81016722502bc 100755 (executable)
@@ -4,7 +4,7 @@
 # for vars that are defined but not used, and for inconsistent array
 # sizes.  Run it from inside the main rsync directory.
 
-import re, argparse, glob
+import os, sys, re, argparse, glob
 
 VARS_RE = re.compile(r'^(?!(?:extern|enum)\s)([a-zA-Z]\S*\s+.*);', re.M)
 EXTERNS_RE = re.compile(r'^extern\s+(.*);', re.M)
@@ -15,6 +15,13 @@ def main():
     add_syscall_c = set('t_stub.c t_unsafe.c tls.c trimslash.c'.split())
     add_util_c = set('t_stub.c t_unsafe.c'.split())
 
+    if not os.path.exists('syscall.c'):
+        if os.path.exists('var-checker'):
+            os.chdir('..')
+        else:
+            print("Couldn't find the source dir.")
+            sys.exit(1)
+
     syscall_c = slurp_file('syscall.c', True)
     util_c = slurp_file('util1.c', True)