1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-09-21 04:10:37 +02:00

feat(deploy): support the index-only option when syncing from/to local copies

This commit is contained in:
proletarius101 2023-12-14 15:50:54 +00:00
parent 3ec997d58e
commit 7071cc6f6d
No known key found for this signature in database
2 changed files with 29 additions and 31 deletions

20
.vscode/settings.json vendored
View File

@ -2,20 +2,8 @@
"python.formatting.blackArgs": [ "python.formatting.blackArgs": [
"--config=pyproject.toml" "--config=pyproject.toml"
], ],
"python.formatting.provider": "black", "python.analysis.typeCheckingMode": "basic",
"python.linting.banditEnabled": true, "conventionalCommits.scopes": [
"python.linting.banditArgs": [ "deploy"
"-ii",
"--ini=.bandit",
], ],
"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,
}

View File

@ -63,7 +63,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. """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 The process of pushing all the new packages to the various
@ -72,11 +72,11 @@ def _get_index_file_paths(repo_section):
client learns about them from the new index files. 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): def _get_index_excludes(base_dir):
indexes = _get_index_file_paths(repo_section) indexes = _get_index_file_paths(base_dir)
index_excludes = [] index_excludes = []
for f in indexes: for f in indexes:
index_excludes.append('--exclude') index_excludes.append('--exclude')
@ -84,8 +84,8 @@ def _get_index_excludes(repo_section):
return index_excludes return index_excludes
def _get_index_includes(repo_section): def _get_index_includes(base_dir):
indexes = _get_index_file_paths(repo_section) indexes = _get_index_file_paths(base_dir)
index_includes = [] index_includes = []
for f in indexes: for f in indexes:
index_includes.append('--include') index_includes.append('--include')
@ -559,13 +559,18 @@ def sync_from_localcopy(repo_section, local_copy_dir):
""" """
logging.info('Syncing from local_copy_dir to this repo.') logging.info('Syncing from local_copy_dir to this repo.')
# trailing slashes have a meaning in rsync which is not needed here, so if options.index_only:
# make sure both paths have exactly one trailing slash common.local_rsync(common.get_options(),
common.local_rsync( _get_index_includes(local_copy_dir),
common.get_options(), repo_section.rstrip('/') + '/')
os.path.join(local_copy_dir, repo_section).rstrip('/') + '/', else:
repo_section.rstrip('/') + '/', # 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(
common.get_options(),
os.path.join(local_copy_dir, repo_section).rstrip('/') + '/',
repo_section.rstrip('/') + '/',
)
offline_copy = os.path.join(local_copy_dir, BINARY_TRANSPARENCY_DIR) offline_copy = os.path.join(local_copy_dir, BINARY_TRANSPARENCY_DIR)
if os.path.exists(os.path.join(offline_copy, '.git')): if os.path.exists(os.path.join(offline_copy, '.git')):
@ -581,8 +586,13 @@ def update_localcopy(repo_section, local_copy_dir):
drive. drive.
""" """
# local_copy_dir is guaranteed to have a trailing slash in main() below if options.index_only:
common.local_rsync(common.get_options(), repo_section, local_copy_dir) common.local_rsync(common.get_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(common.get_options(), repo_section, local_copy_dir)
offline_copy = os.path.join(os.getcwd(), BINARY_TRANSPARENCY_DIR) offline_copy = os.path.join(os.getcwd(), BINARY_TRANSPARENCY_DIR)
if os.path.isdir(os.path.join(offline_copy, '.git')): if os.path.isdir(os.path.join(offline_copy, '.git')):