From b741fa9f1ce69cba00436e5da5b3ffad10c038d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20K=C3=BCrten?= <sebastian@mobanisto.de>
Date: Wed, 14 Jun 2023 08:31:46 +0200
Subject: [PATCH] Fix problem with different values of BUILD_DIR in
 create_sources_jar()

---
 upstream/build_tor_macos.py |  2 +-
 utils.py                    | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/upstream/build_tor_macos.py b/upstream/build_tor_macos.py
index 0c76fff..52fd848 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 c0abdb8..ef478b4 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
 
 
-- 
GitLab