From 9482ddfbe3641de32f8399c9c5ed1cea11532c49 Mon Sep 17 00:00:00 2001 From: linsui <2873532-linsui@users.noreply.gitlab.com> Date: Sun, 1 Sep 2024 01:27:26 +0800 Subject: [PATCH] scanner: support workspace for lock files --- fdroidserver/scanner.py | 12 +++++++++--- .../.dart_tool/flutter_gen}/pubspec.yaml | 0 .../{Cargo.lock => flutter/pubspec.lock} | 0 .../{Cargo.toml => flutter/pubspec.yaml} | 0 .../lockfile.test/{ => javascript}/package.json | 0 .../lockfile.test/{ => javascript}/yarn.lock | 0 .../lockfile.test/rust/subdir/Cargo.lock | 0 .../lockfile.test/rust/subdir/Cargo.toml | 0 .../rust/subdir/subdir/subdir/Cargo.toml | 0 .../lockfile.test/rust/subdir2/Cargo.toml | 0 10 files changed, 9 insertions(+), 3 deletions(-) rename tests/source-files/lockfile.test/{ => flutter/.dart_tool/flutter_gen}/pubspec.yaml (100%) rename tests/source-files/lockfile.test/{Cargo.lock => flutter/pubspec.lock} (100%) rename tests/source-files/lockfile.test/{Cargo.toml => flutter/pubspec.yaml} (100%) rename tests/source-files/lockfile.test/{ => javascript}/package.json (100%) rename tests/source-files/lockfile.test/{ => javascript}/yarn.lock (100%) create mode 100644 tests/source-files/lockfile.test/rust/subdir/Cargo.lock create mode 100644 tests/source-files/lockfile.test/rust/subdir/Cargo.toml create mode 100644 tests/source-files/lockfile.test/rust/subdir/subdir/subdir/Cargo.toml create mode 100644 tests/source-files/lockfile.test/rust/subdir2/Cargo.toml diff --git a/fdroidserver/scanner.py b/fdroidserver/scanner.py index d212d811..573df30d 100644 --- a/fdroidserver/scanner.py +++ b/fdroidserver/scanner.py @@ -816,9 +816,15 @@ def scan_source(build_dir, build=metadata.Build(), json_per_build=None): ) elif curfile in DEPFILE: - for lockfile in DEPFILE[curfile]: - if os.path.isfile(os.path.join(root, lockfile)): - break + d = root + while d.startswith(build_dir): + for lockfile in DEPFILE[curfile]: + if os.path.isfile(os.path.join(d, lockfile)): + break + else: + d = os.path.dirname(d) + continue + break else: count += handleproblem( _('dependency file without lock'), diff --git a/tests/source-files/lockfile.test/pubspec.yaml b/tests/source-files/lockfile.test/flutter/.dart_tool/flutter_gen/pubspec.yaml similarity index 100% rename from tests/source-files/lockfile.test/pubspec.yaml rename to tests/source-files/lockfile.test/flutter/.dart_tool/flutter_gen/pubspec.yaml diff --git a/tests/source-files/lockfile.test/Cargo.lock b/tests/source-files/lockfile.test/flutter/pubspec.lock similarity index 100% rename from tests/source-files/lockfile.test/Cargo.lock rename to tests/source-files/lockfile.test/flutter/pubspec.lock diff --git a/tests/source-files/lockfile.test/Cargo.toml b/tests/source-files/lockfile.test/flutter/pubspec.yaml similarity index 100% rename from tests/source-files/lockfile.test/Cargo.toml rename to tests/source-files/lockfile.test/flutter/pubspec.yaml diff --git a/tests/source-files/lockfile.test/package.json b/tests/source-files/lockfile.test/javascript/package.json similarity index 100% rename from tests/source-files/lockfile.test/package.json rename to tests/source-files/lockfile.test/javascript/package.json diff --git a/tests/source-files/lockfile.test/yarn.lock b/tests/source-files/lockfile.test/javascript/yarn.lock similarity index 100% rename from tests/source-files/lockfile.test/yarn.lock rename to tests/source-files/lockfile.test/javascript/yarn.lock diff --git a/tests/source-files/lockfile.test/rust/subdir/Cargo.lock b/tests/source-files/lockfile.test/rust/subdir/Cargo.lock new file mode 100644 index 00000000..e69de29b diff --git a/tests/source-files/lockfile.test/rust/subdir/Cargo.toml b/tests/source-files/lockfile.test/rust/subdir/Cargo.toml new file mode 100644 index 00000000..e69de29b diff --git a/tests/source-files/lockfile.test/rust/subdir/subdir/subdir/Cargo.toml b/tests/source-files/lockfile.test/rust/subdir/subdir/subdir/Cargo.toml new file mode 100644 index 00000000..e69de29b diff --git a/tests/source-files/lockfile.test/rust/subdir2/Cargo.toml b/tests/source-files/lockfile.test/rust/subdir2/Cargo.toml new file mode 100644 index 00000000..e69de29b