diff --git a/upstream/build_tor_macos.py b/upstream/build_tor_macos.py
index 0c76fff8c74b5e31c0bd16d285b666ad6ad19c1f..52fd848d14878c4b450bcc7be10bfb7df6689d75 100755
--- a/upstream/build_tor_macos.py
+++ b/upstream/build_tor_macos.py
@@ -34,7 +34,7 @@ def setup():
     check_call(['git', 'submodule', 'update'], cwd=Path(BUILD_DIR))
 
     # create sources jar before building
-    jar_name = create_sources_jar(versions, PLATFORM)
+    jar_name = create_sources_jar(versions, PLATFORM, BUILD_DIR)
 
     return versions, jar_name
 
diff --git a/utils.py b/utils.py
index c0abdb8072308fbd4b97e23bd28bf2407f97832e..ef478b467a62a2ac3f6c71bd12d9f41b82e127bd 100644
--- a/utils.py
+++ b/utils.py
@@ -74,7 +74,7 @@ def setup(platform):
     prepare_repos(versions)
 
     # create sources jar before building
-    jar_name = create_sources_jar(versions, platform)
+    jar_name = create_sources_jar(versions, platform, BUILD_DIR)
 
     return versions, jar_name
 
@@ -183,10 +183,10 @@ def reset_time(filename, versions):
     check_call(['touch', '--no-dereference', '-t', versions['timestamp'], filename])
 
 
-def create_sources_jar(versions, platform):
+def create_sources_jar(versions, platform, build_dir):
     output_dir = get_output_dir(platform)
     jar_files = []
-    for root, dir_names, filenames in os.walk(BUILD_DIR):
+    for root, dir_names, filenames in os.walk(build_dir):
         for f in filenames:
             if '/.git' in root:
                 continue
@@ -195,13 +195,13 @@ def create_sources_jar(versions, platform):
         reset_time(file, versions)
     jar_name = get_sources_file_name(versions, platform)
     jar_path = os.path.abspath(jar_name)
-    rel_paths = [os.path.relpath(f, BUILD_DIR) for f in sorted(jar_files)]
+    rel_paths = [os.path.relpath(f, build_dir) for f in sorted(jar_files)]
     # create jar archive with first files
     jar_step = 5000
-    check_call(['jar', 'cf', jar_path] + rel_paths[0:jar_step], cwd=BUILD_DIR)
+    check_call(['jar', 'cf', jar_path] + rel_paths[0:jar_step], cwd=build_dir)
     # add subsequent files in steps, because the command line can't handle all at once
     for i in range(jar_step, len(rel_paths), jar_step):
-        check_call(['jar', 'uf', jar_path] + rel_paths[i:i + jar_step], cwd=BUILD_DIR)
+        check_call(['jar', 'uf', jar_path] + rel_paths[i:i + jar_step], cwd=build_dir)
     return jar_name