mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 22:40:12 +01:00
implement -q and -v for fdroid server
The --quiet and --verbose options that are standard with the fdroid tools were not implemented yet with the `server` command.
This commit is contained in:
parent
5ce3b61a2a
commit
d1cd817759
@ -115,6 +115,13 @@ def read_config(opts, config_file='config.py'):
|
||||
if k in config:
|
||||
write_password_file(k)
|
||||
|
||||
# since this is used with rsync, where trailing slashes have meaning,
|
||||
# ensure there is always a trailing slash
|
||||
if 'serverwebroot' in config:
|
||||
if config['serverwebroot'][-1] != '/':
|
||||
config['serverwebroot'] += '/'
|
||||
config['serverwebroot'] = config['serverwebroot'].replace('//', '/')
|
||||
|
||||
return config
|
||||
|
||||
def write_password_file(pwtype, password=None):
|
||||
|
@ -29,19 +29,23 @@ options = None
|
||||
|
||||
|
||||
def update_serverwebroot(repo_section):
|
||||
rsyncargs = ['rsync', '-u', '-r', '--delete']
|
||||
if options.verbose:
|
||||
rsyncargs += ['--verbose']
|
||||
if options.quiet:
|
||||
rsyncargs += ['--quiet']
|
||||
index = os.path.join(repo_section, 'index.xml')
|
||||
indexjar = os.path.join(repo_section, 'index.jar')
|
||||
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete',
|
||||
'--exclude', index, '--exclude', indexjar,
|
||||
# serverwebroot is guaranteed to have a trailing slash in common.py
|
||||
if subprocess.call(rsyncargs +
|
||||
['--exclude', index, '--exclude', indexjar,
|
||||
repo_section, config['serverwebroot']]) != 0:
|
||||
sys.exit(1)
|
||||
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete',
|
||||
index,
|
||||
config['serverwebroot'] + '/' + repo_section]) != 0:
|
||||
if subprocess.call(rsyncargs +
|
||||
[index, config['serverwebroot'] + repo_section]) != 0:
|
||||
sys.exit(1)
|
||||
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete',
|
||||
indexjar,
|
||||
config['serverwebroot'] + '/' + repo_section]) != 0:
|
||||
if subprocess.call(rsyncargs +
|
||||
[indexjar, config['serverwebroot'] + repo_section]) != 0:
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
@ -71,8 +75,8 @@ def main():
|
||||
standardwebroot = True
|
||||
|
||||
if 'serverwebroot' in config:
|
||||
serverwebroot = config['serverwebroot'].rstrip('/').replace('//', '/')
|
||||
host, fdroiddir = serverwebroot.split(':')
|
||||
serverwebroot = config['serverwebroot']
|
||||
host, fdroiddir = serverwebroot.rstrip('/').split(':')
|
||||
serverrepobase = os.path.basename(fdroiddir)
|
||||
if serverrepobase != 'fdroid' and standardwebroot:
|
||||
logging.error('serverwebroot does not end with "fdroid", '
|
||||
@ -93,9 +97,16 @@ def main():
|
||||
|
||||
if args[0] == 'init':
|
||||
if serverwebroot != None:
|
||||
sshargs = ['ssh']
|
||||
if options.quiet:
|
||||
sshargs += ['-q']
|
||||
for repo_section in repo_sections:
|
||||
if subprocess.call(['ssh', '-v', host,
|
||||
'mkdir -p', fdroiddir + '/' + repo_section]) != 0:
|
||||
cmd = sshargs + [host, 'mkdir -p', fdroiddir + '/' + repo_section]
|
||||
if options.verbose:
|
||||
# ssh -v produces different output than rsync -v, so this
|
||||
# simulates rsync -v
|
||||
logging.info(' '.join(cmd))
|
||||
if subprocess.call(cmd) != 0:
|
||||
sys.exit(1)
|
||||
elif args[0] == 'update':
|
||||
for repo_section in repo_sections:
|
||||
|
Loading…
Reference in New Issue
Block a user