make fdroid server check whether serverwebroot is set

Having serverwebroot optional in `fdroid server` means that it can support
multiple methods of hosting, like cloud storage services.  `fdroid server`
can also then support multiple repo hosting options at the same time.
This commit is contained in:
Hans-Christoph Steiner 2014-04-14 23:44:20 -04:00
parent 1ca7949bb1
commit 6b65257516
2 changed files with 32 additions and 26 deletions

View file

@ -100,10 +100,10 @@ keyaliases['com.example.another.plugin'] = '@com.example.another'
# generated repo to the server that is it hosted on. It must end in the # generated repo to the server that is it hosted on. It must end in the
# standard public repo name of "/fdroid", but can be in up to three levels of # standard public repo name of "/fdroid", but can be in up to three levels of
# sub-directories (i.e. /var/www/packagerepos/fdroid). # sub-directories (i.e. /var/www/packagerepos/fdroid).
serverwebroot = 'user@example:/var/www/fdroid' #serverwebroot = 'user@example:/var/www/fdroid'
# If you want to force 'fdroid server' to use a non-standard serverwebroot # If you want to force 'fdroid server' to use a non-standard serverwebroot
#nonstandardwebroot = True #nonstandardwebroot = False
#Wiki details #Wiki details
wiki_protocol = "http" wiki_protocol = "http"

View file

@ -50,19 +50,22 @@ def main():
logging.critical("The only commands currently supported are 'init' and 'update'") logging.critical("The only commands currently supported are 'init' and 'update'")
sys.exit(1) sys.exit(1)
if 'serverwebroot' in config:
serverwebroot = config['serverwebroot'].rstrip('/').replace('//', '/') serverwebroot = config['serverwebroot'].rstrip('/').replace('//', '/')
host, fdroiddir = serverwebroot.split(':') host, fdroiddir = serverwebroot.split(':')
serverrepobase = os.path.basename(fdroiddir) serverrepobase = os.path.basename(fdroiddir)
if 'nonstandardwebroot' in config and config['nonstandardwebroot'] == True:
standardwebroot = False
else:
standardwebroot = True
if serverrepobase != 'fdroid' and standardwebroot: if serverrepobase != 'fdroid' and standardwebroot:
print('ERROR: serverwebroot does not end with "fdroid", ' logging.error('serverwebroot does not end with "fdroid", '
+ 'perhaps you meant one of these:\n\t' + 'perhaps you meant one of these:\n\t'
+ serverwebroot.rstrip('/') + '/fdroid\n\t' + serverwebroot.rstrip('/') + '/fdroid\n\t'
+ serverwebroot.rstrip('/').rstrip(serverrepobase) + 'fdroid') + serverwebroot.rstrip('/').rstrip(serverrepobase) + 'fdroid')
sys.exit(1) sys.exit(1)
else:
serverwebroot = None
if 'nonstandardwebroot' in config and config['nonstandardwebroot'] == True:
standardwebroot = False
else:
standardwebroot = True
repodirs = ['repo'] repodirs = ['repo']
if config['archive_older'] != 0: if config['archive_older'] != 0:
@ -70,10 +73,13 @@ def main():
for repodir in repodirs: for repodir in repodirs:
if args[0] == 'init': if args[0] == 'init':
if subprocess.call(['ssh', '-v', host, if serverwebroot == None:
logging.warn('No serverwebroot set! Edit your config.py to set it.')
elif subprocess.call(['ssh', '-v', host,
'mkdir -p', fdroiddir + '/' + repodir]) != 0: 'mkdir -p', fdroiddir + '/' + repodir]) != 0:
sys.exit(1) sys.exit(1)
elif args[0] == 'update': elif args[0] == 'update':
if serverwebroot != None:
index = os.path.join(repodir, 'index.xml') index = os.path.join(repodir, 'index.xml')
indexjar = os.path.join(repodir, 'index.jar') indexjar = os.path.join(repodir, 'index.jar')
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete', if subprocess.call(['rsync', '-u', '-v', '-r', '--delete',