Compare commits

...

4 commits

Author SHA1 Message Date
linsui
b19b8050db Merge branch 'fix-schildichat-fastlane' into 'master'
update: more accurate fastlane subdir/flavor matching

See merge request fdroid/fdroidserver!1687
2025-07-26 12:52:31 +00:00
Hans-Christoph Steiner
6a3758d3c4 update: more accurate fastlane subdir/flavor matching
This should fix Schildichat showing Element X's metadata.
2025-07-26 12:36:32 +00:00
Hans-Christoph Steiner
546821fc3d Merge branch 'scanpath' into 'master'
scanner: report all errors

See merge request fdroid/fdroidserver!1688
2025-07-26 10:44:26 +00:00
linsui
120a1655b4 scanner: report all errors 2025-07-26 18:33:57 +08:00
4 changed files with 69 additions and 12 deletions

View file

@ -2733,17 +2733,17 @@ def getpaths_map(build_dir, globpaths):
paths[p] = [r[len(str(build_dir)) + 1:] for r in glob.glob(full_path)]
if not paths[p]:
not_found_paths.append(p)
return paths, not_found_paths
def getpaths(build_dir, globpaths):
"""Extend via globbing the paths from a field and return them as a set."""
paths_map, not_found_paths = getpaths_map(build_dir, globpaths)
if not_found_paths:
raise FDroidException(
"Some glob paths did not match any files/dirs:\n"
+ "\n".join(not_found_paths)
)
return paths
def getpaths(build_dir, globpaths):
"""Extend via globbing the paths from a field and return them as a set."""
paths_map = getpaths_map(build_dir, globpaths)
paths = set()
for k, v in paths_map.items():
for p in v:

View file

@ -750,8 +750,12 @@ def scan_source(build_dir, build=metadata.Build(), json_per_build=None):
]
]
scanignore = common.getpaths_map(build_dir, build.scanignore)
scandelete = common.getpaths_map(build_dir, build.scandelete)
scanignore, scanignore_not_found_paths = common.getpaths_map(
build_dir, build.scanignore
)
scandelete, scandelete_not_found_paths = common.getpaths_map(
build_dir, build.scandelete
)
scanignore_worked = set()
scandelete_worked = set()
@ -1109,11 +1113,19 @@ def scan_source(build_dir, build=metadata.Build(), json_per_build=None):
json_per_build,
)
for p in scanignore_not_found_paths:
logging.error(_("Non-exist scanignore path: %s") % p)
count += 1
for p in scanignore:
if p not in scanignore_worked:
logging.error(_('Unused scanignore path: %s') % p)
count += 1
for p in scandelete_not_found_paths:
logging.error(_("Non-exist scandelete path: %s") % p)
count += 1
for p in scandelete:
if p not in scandelete_worked:
logging.error(_('Unused scandelete path: %s') % p)

View file

@ -1148,6 +1148,7 @@ def insert_localized_app_metadata(apps):
metadata/<locale>/
fastlane/metadata/android/<locale>/
<subdir>/fastlane/metadata/android/<locale>/
src/<buildFlavor>/fastlane/metadata/android/<locale>/
...as well as the /metadata/<packageName>/<locale> directory.
@ -1186,7 +1187,7 @@ def insert_localized_app_metadata(apps):
builds = apps.get(packageName, {}).get('Builds', [])
found_in_subdir = (
builds
and len(segments) > 7
and len(segments) > 6
and segments[-4] == "fastlane"
and segments[-3] == "metadata"
and segments[-2] == "android"
@ -1199,12 +1200,18 @@ def insert_localized_app_metadata(apps):
build_flavors = common.calculate_gradle_flavor_combination(
builds[-1]['gradle']
)
found_in_flavor = (
len(segments) > 7
and segments[2] == 'src'
and segments[4] == "fastlane"
and segments[3] in build_flavors
)
if (
not found_in_subdir
and len(segments) >= 5
and segments[4] == "fastlane"
and segments[3] not in build_flavors
and not found_in_flavor
and segments[0] == 'build'
and segments[2] not in ('metadata', 'fastlane')
):
logging.debug(
'Not scanning "{dir}" with unknown subdir or gradle flavor "{value}"'.format(

View file

@ -286,6 +286,44 @@ class UpdateTest(unittest.TestCase):
fdroidserver.update.insert_localized_app_metadata(apps)
self.assertEqual(second_value, apps[app.id]['localized']['en-US']['name'])
def test_fastlane_with_schildichat(self):
"""Test if fastlane is found in this tangle of dirs and symlinks.
https://github.com/SchildiChat/schildichat-android-next/tree/sc_v0.10.3-ex_25_6_2
"""
os.chdir(self.testdir)
config = dict()
fdroidserver.common.fill_config_defaults(config)
fdroidserver.update.config = config
app = fdroidserver.metadata.App()
app.id = 'chat.schildi.android'
build_dir = f'build/{app.id}'
flavors = ['fdroid', 'sc', 'default']
subdir = 'app'
apps = {app.id: app}
build = fdroidserver.metadata.Build()
build.versionCode = 42
build.gradle = flavors
build.subdir = subdir
app['Builds'] = [build]
wrong_value = 'wrong'
wrong_dir = Path(f'{build_dir}/upstream_infra/fastlane/metadata/android/en-US')
wrong_dir.mkdir(parents=True)
(wrong_dir / 'title.txt').write_text(wrong_value)
right_value = 'right'
right_dir = Path(f'{build_dir}/metadata/en-US')
right_dir.mkdir(parents=True)
(right_dir / 'title.txt').write_text(right_value)
_fastlane = Path('.fastlane/metadata')
_fastlane.mkdir(parents=True)
os.symlink('../../metadata', _fastlane / 'android')
os.symlink('.fastlane', 'fastlane')
fdroidserver.update.insert_localized_app_metadata(apps)
self.assertEqual(right_value, apps[app.id]['localized']['en-US']['name'])
def test_fastlane_with_multi_level_subdir(self):
"""Test if fastlane in multi-level subdir is found."""
os.chdir(self.testdir)