From 8e6996b25db0553ce4b66f2c3e6f8ac43d1b6546 Mon Sep 17 00:00:00 2001 From: proletarius101 Date: Thu, 14 Dec 2023 15:50:54 +0000 Subject: [PATCH] feat(deploy): support the index-only option when syncing from/to local copies --- .vscode/settings.json | 20 ++++---------------- fdroidserver/deploy.py | 36 +++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index da31cd7f..154dce4a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,20 +2,8 @@ "python.formatting.blackArgs": [ "--config=pyproject.toml" ], - "python.formatting.provider": "black", - "python.linting.banditEnabled": true, - "python.linting.banditArgs": [ - "-ii", - "--ini=.bandit", + "python.analysis.typeCheckingMode": "basic", + "conventionalCommits.scopes": [ + "deploy" ], - "python.linting.enabled": true, - "python.linting.mypyArgs": [ - "--config-file=mypy.ini" - ], - "python.linting.mypyEnabled": true, - "python.linting.flake8Enabled": true, - "python.linting.pylintArgs": [ - "--rcfile=.pylint-rcfile" - ], - "python.linting.pylintEnabled": true, -} +} \ No newline at end of file diff --git a/fdroidserver/deploy.py b/fdroidserver/deploy.py index 1f9154b3..94bd3458 100644 --- a/fdroidserver/deploy.py +++ b/fdroidserver/deploy.py @@ -61,7 +61,7 @@ INDEX_FILES = [ ] -def _get_index_file_paths(repo_section): +def _get_index_file_paths(base_dir): """Return the list of files to be synced last, since they finalize the deploy. The process of pushing all the new packages to the various @@ -70,11 +70,11 @@ def _get_index_file_paths(repo_section): client learns about them from the new index files. """ - return [os.path.join(repo_section, filename) for filename in INDEX_FILES] + return [os.path.join(base_dir, filename) for filename in INDEX_FILES] -def _get_index_excludes(repo_section): - indexes = _get_index_file_paths(repo_section) +def _get_index_excludes(base_dir): + indexes = _get_index_file_paths(base_dir) index_excludes = [] for f in indexes: index_excludes.append('--exclude') @@ -82,8 +82,8 @@ def _get_index_excludes(repo_section): return index_excludes -def _get_index_includes(repo_section): - indexes = _get_index_file_paths(repo_section) +def _get_index_includes(base_dir): + indexes = _get_index_file_paths(base_dir) index_includes = [] for f in indexes: index_includes.append('--include') @@ -387,11 +387,16 @@ def sync_from_localcopy(repo_section, local_copy_dir): """ logging.info('Syncing from local_copy_dir to this repo.') - # trailing slashes have a meaning in rsync which is not needed here, so - # make sure both paths have exactly one trailing slash - common.local_rsync(options, - os.path.join(local_copy_dir, repo_section).rstrip('/') + '/', - repo_section.rstrip('/') + '/') + if options.index_only: + common.local_rsync(options, + _get_index_includes(local_copy_dir), + repo_section.rstrip('/') + '/') + else: + # trailing slashes have a meaning in rsync which is not needed here, so + # make sure both paths have exactly one trailing slash + common.local_rsync(options, + os.path.join(local_copy_dir, repo_section).rstrip('/') + '/', + repo_section.rstrip('/') + '/') offline_copy = os.path.join(local_copy_dir, BINARY_TRANSPARENCY_DIR) if os.path.exists(os.path.join(offline_copy, '.git')): @@ -407,8 +412,13 @@ def update_localcopy(repo_section, local_copy_dir): drive. """ - # local_copy_dir is guaranteed to have a trailing slash in main() below - common.local_rsync(options, repo_section, local_copy_dir) + if options.index_only: + common.local_rsync(options, + _get_index_includes(repo_section), + repo_section.rstrip('/') + '/') + else: + # local_copy_dir is guaranteed to have a trailing slash in main() below + common.local_rsync(options, repo_section, local_copy_dir) offline_copy = os.path.join(os.getcwd(), BINARY_TRANSPARENCY_DIR) if os.path.isdir(os.path.join(offline_copy, '.git')):