Merge commit 'refs/merge-requests/132' of gitorious.org:f-droid/fdroidserver

This commit is contained in:
Daniel Martí 2013-12-07 13:57:55 +01:00
commit 55492655a5
3 changed files with 50 additions and 22 deletions

View file

@ -85,9 +85,15 @@ keyaliases['com.example.app'] = 'example'
#the @ prefix. #the @ prefix.
keyaliases['com.example.another.plugin'] = '@com.example.another' keyaliases['com.example.another.plugin'] = '@com.example.another'
#The ssh path to the server's public web root directory. This is used for # The full path to the root of the repository. It must be specified in
#uploading data, etc. # rsync/ssh format for a remote host/path. This is used for syncing a locally
serverwebroot = 'user@example:/var/www/repo' # 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
# sub-directories (i.e. /var/www/packagerepos/fdroid).
serverwebroot = 'user@example:/var/www/fdroid'
# If you want to force 'fdroid server' to use a non-standard serverwebroot
#nonstandardwebroot = True
#Wiki details #Wiki details
wiki_protocol = "http" wiki_protocol = "http"

View file

@ -102,12 +102,12 @@ def main():
prefix = tmp prefix = tmp
examplesdir = prefix examplesdir = prefix
repodir = os.getcwd() fdroiddir = os.getcwd()
if not os.path.exists('config.py') and not os.path.exists('repo'): if not os.path.exists('config.py') and not os.path.exists('repo'):
# 'metadata' and 'tmp' are created in fdroid # 'metadata' and 'tmp' are created in fdroid
os.mkdir('repo') os.mkdir('repo')
shutil.copy(os.path.join(examplesdir, 'fdroid-icon.png'), repodir) shutil.copy(os.path.join(examplesdir, 'fdroid-icon.png'), fdroiddir)
shutil.copyfile(os.path.join(examplesdir, 'config.sample.py'), 'config.py') shutil.copyfile(os.path.join(examplesdir, 'config.sample.py'), 'config.py')
os.chmod('config.py', 0o0600) os.chmod('config.py', 0o0600)
else: else:
@ -206,13 +206,14 @@ def main():
write_to_config('keydname', keydname) write_to_config('keydname', keydname)
genkey(keystore, repo_keyalias, password, keydname) genkey(keystore, repo_keyalias, password, keydname)
print('Built repo in "' + repodir + '" with this config:') print('Built repo based in "' + fdroiddir + '"')
print('with this config:')
print(' Android SDK:\t\t\t' + sdk_path) print(' Android SDK:\t\t\t' + sdk_path)
print(' Android SDK Build Tools:\t' + os.path.dirname(aapt)) print(' Android SDK Build Tools:\t' + os.path.dirname(aapt))
print(' Android NDK (optional):\t' + ndk_path) print(' Android NDK (optional):\t' + ndk_path)
print(' Keystore for signing key:\t' + keystore) print(' Keystore for signing key:\t' + keystore)
print('\nTo complete the setup, add your APKs to "' + print('\nTo complete the setup, add your APKs to "' +
os.path.join(repodir, 'repo') + '"' + os.path.join(fdroiddir, 'repo') + '"' +
''' '''
then run "fdroid update -c; fdroid update". You might also want to edit then run "fdroid update -c; fdroid update". You might also want to edit
"config.py" to set the URL, repo name, and more. You should also set up "config.py" to set the URL, repo name, and more. You should also set up

View file

@ -26,6 +26,7 @@ import common
config = None config = None
options = None options = None
def main(): def main():
global config, options global config, options
@ -42,8 +43,22 @@ def main():
print "Specify a single command" print "Specify a single command"
sys.exit(1) sys.exit(1)
if args[0] != 'update': if args[0] != 'init' and args[0] != 'update':
print "The only command currently supported is 'update'" print "The only commands currently supported are 'init' and 'update'"
sys.exit(1)
serverwebroot = config['serverwebroot'].rstrip('/').replace('//', '/')
host, fdroiddir = serverwebroot.split(':')
serverrepobase = os.path.basename(fdroiddir)
if 'nonstandardwebroot' in config and config['nonstandardwebroot'] == True:
standardwebroot = False
else:
standardwebroot = True
if serverrepobase != 'fdroid' and standardwebroot:
print('ERROR: serverwebroot does not end with "fdroid", '
+ 'perhaps you meant one of these:\n\t'
+ serverwebroot.rstrip('/') + '/fdroid\n\t'
+ serverwebroot.rstrip('/').rstrip(serverrepobase) + 'fdroid')
sys.exit(1) sys.exit(1)
repodirs = ['repo'] repodirs = ['repo']
@ -51,21 +66,27 @@ def main():
repodirs.append('archive') repodirs.append('archive')
for repodir in repodirs: for repodir in repodirs:
index = os.path.join(repodir, 'index.xml') if args[0] == 'init':
indexjar = os.path.join(repodir, 'index.jar') if subprocess.call(['ssh', '-v', host,
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete', 'mkdir -p', fdroiddir + '/' + repodir]) != 0:
'--exclude', index, '--exclude', indexjar, repodir, config['serverwebroot']]) != 0: sys.exit(1)
sys.exit(1) elif args[0] == 'update':
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete', index = os.path.join(repodir, 'index.xml')
index, config['serverwebroot'] + '/' + repodir]) != 0: indexjar = os.path.join(repodir, 'index.jar')
sys.exit(1) if subprocess.call(['rsync', '-u', '-v', '-r', '--delete',
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete', '--exclude', index, '--exclude', indexjar,
indexjar, config['serverwebroot'] + '/' + repodir]) != 0: repodir, config['serverwebroot']]) != 0:
sys.exit(1) sys.exit(1)
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete',
index,
config['serverwebroot'] + '/' + repodir]) != 0:
sys.exit(1)
if subprocess.call(['rsync', '-u', '-v', '-r', '--delete',
indexjar,
config['serverwebroot'] + '/' + repodir]) != 0:
sys.exit(1)
sys.exit(0) sys.exit(0)
if __name__ == "__main__": if __name__ == "__main__":
main() main()