From 463bfc56396f6474080583f81f0149ac31a1b5bb Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 30 Apr 2015 23:36:10 -0400 Subject: [PATCH 1/2] server: delay deleting on the server for as long as possible In order to keep things working as much as possible during the update, the rsync should only delete the obsolete APKs after it has finished uploading the new APKs. --- fdroidserver/server.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fdroidserver/server.py b/fdroidserver/server.py index c5496dee..5a0a442a 100644 --- a/fdroidserver/server.py +++ b/fdroidserver/server.py @@ -123,7 +123,7 @@ def update_awsbucket(repo_section): def update_serverwebroot(serverwebroot, repo_section): # use a checksum comparison for accurate comparisons on different # filesystems, for example, FAT has a low resolution timestamp - rsyncargs = ['rsync', '--archive', '--delete', '--safe-links'] + rsyncargs = ['rsync', '--archive', '--delete-after', '--safe-links'] if not options.no_checksum: rsyncargs.append('--checksum') if options.verbose: @@ -136,13 +136,14 @@ def update_serverwebroot(serverwebroot, repo_section): rsyncargs += ['-e', 'ssh -i ' + config['identity_file']] indexxml = os.path.join(repo_section, 'index.xml') indexjar = os.path.join(repo_section, 'index.jar') - # upload the first time without the index so that the repo stays working - # while this update is running. Then once it is complete, rerun the - # command again to upload the index. Always using the same target with - # rsync allows for very strict settings on the receiving server, you can - # literally specify the one rsync command that is allowed to run in - # ~/.ssh/authorized_keys. (serverwebroot is guaranteed to have a trailing - # slash in common.py) + # Upload the first time without the index files and delay the deletion as + # much as possible, that keeps the repo functional while this update is + # running. Then once it is complete, rerun the command again to upload + # the index files. Always using the same target with rsync allows for + # very strict settings on the receiving server, you can literally specify + # the one rsync command that is allowed to run in ~/.ssh/authorized_keys. + # (serverwebroot is guaranteed to have a trailing slash in common.py) + logging.info('rsyncing ' + repo_section + ' to ' + serverwebroot) if subprocess.call(rsyncargs + ['--exclude', indexxml, '--exclude', indexjar, repo_section, serverwebroot]) != 0: From c941bf3215920b8644865e1cf6df9b627a80c29d Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 30 Apr 2015 23:39:58 -0400 Subject: [PATCH 2/2] server: support plain paths as a serverwebroot For use cases where there is a web server running on the same machine where the `fdroid update` is being run, allow plain paths in the serverwebroot list. This is useful for debug repos from build servers, like: https://dev.guardianproject.info/fdroid --- fdroidserver/server.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fdroidserver/server.py b/fdroidserver/server.py index 5a0a442a..93447767 100644 --- a/fdroidserver/server.py +++ b/fdroidserver/server.py @@ -226,7 +226,15 @@ def main(): standardwebroot = True for serverwebroot in config.get('serverwebroot', []): - host, fdroiddir = serverwebroot.rstrip('/').split(':') + # this supports both an ssh host:path and just a path + s = serverwebroot.rstrip('/').split(':') + if len(s) == 1: + fdroiddir = s[0] + elif len(s) == 2: + host, fdroiddir = s + else: + logging.error('Malformed serverwebroot line: ' + serverwebroot) + sys.exit(1) repobase = os.path.basename(fdroiddir) if standardwebroot and repobase != 'fdroid': logging.error('serverwebroot path does not end with "fdroid", '