1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-05 18:50:09 +02:00

update: reuse local_copy_dir to provide auto-copying with --nosign

When using `fdroid update --nosign` in combo with `fdroid signindex`, the
unsigned index files have to be copied to a thumb drive or something in
order to be brought to the offline signing server.  This reuses the config
option local_copy_dir as the destination for those unsigned index files.
This commit is contained in:
Hans-Christoph Steiner 2020-08-20 15:22:02 +02:00
parent a2f0356d84
commit b5c941938a

View File

@ -563,12 +563,25 @@ def make_v1(apps, packages, repodir, repodict, requestsdict, fdroid_signing_key_
json.dump(output, fp, default=_index_encoder_default) json.dump(output, fp, default=_index_encoder_default)
if common.options.nosign: if common.options.nosign:
_copy_to_local_copy_dir(repodir, index_file)
logging.debug(_('index-v1 must have a signature, use `fdroid signindex` to create it!')) logging.debug(_('index-v1 must have a signature, use `fdroid signindex` to create it!'))
else: else:
signindex.config = common.config signindex.config = common.config
signindex.sign_index_v1(repodir, json_name) signindex.sign_index_v1(repodir, json_name)
def _copy_to_local_copy_dir(repodir, f):
local_copy_dir = common.config.get('local_copy_dir', '')
if os.path.exists(local_copy_dir):
destdir = os.path.join(local_copy_dir, repodir)
if not os.path.exists(destdir):
os.mkdir(destdir)
shutil.copy2(f, destdir, follow_symlinks=False)
elif local_copy_dir:
raise FDroidException(_('"local_copy_dir" {path} does not exist!')
.format(path=local_copy_dir))
def v1_sort_packages(packages, fdroid_signing_key_fingerprints): def v1_sort_packages(packages, fdroid_signing_key_fingerprints):
"""Sorts the supplied list to ensure a deterministic sort order for """Sorts the supplied list to ensure a deterministic sort order for
package entries in the index file. This sort-order also expresses package entries in the index file. This sort-order also expresses
@ -926,6 +939,7 @@ def make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fing
# Sign the index... # Sign the index...
signed = os.path.join(repodir, 'index.jar') signed = os.path.join(repodir, 'index.jar')
if common.options.nosign: if common.options.nosign:
_copy_to_local_copy_dir(repodir, os.path.join(repodir, jar_output))
# Remove old signed index if not signing # Remove old signed index if not signing
if os.path.exists(signed): if os.path.exists(signed):
os.remove(signed) os.remove(signed)