1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-08-16 19:30:09 +02:00

Reading config now also checks its assigned bins and dirs

This commit is contained in:
Daniel Martí 2013-12-06 12:55:56 +01:00
parent 9ecf6fcf74
commit 9a2a0efa41

View File

@ -26,6 +26,7 @@ import operator
import Queue
import threading
import magic
from distutils.spawn import find_executable
import metadata
@ -45,6 +46,7 @@ def read_config(opts, config_file='config.py'):
if not os.path.isfile(config_file):
print "Missing config file - is this a repo directory?"
sys.exit(2)
st = os.stat(config_file)
if st.st_mode & stat.S_IRWXG or st.st_mode & stat.S_IRWXO:
print "WARNING: unsafe permissions on {0} (should be 0600)!".format(config_file)
@ -67,11 +69,35 @@ def read_config(opts, config_file='config.py'):
if options.verbose:
print "Reading %s..." % config_file
execfile(config_file, config)
# Expand environment variables
for k, v in config.items():
if type(v) != str:
continue
if v[0] == '$':
config[k] = os.environ[v[1:]]
# Check that commands and binaries do exist
for key in ('mvn3', 'gradle'):
if key not in config:
print "WARNING: %s not set in config" % key
val = config[key]
executable = find_executable(val)
if not executable:
print "ERROR: No such command or binary for %s: %s" % (key, val)
sys.exit(3)
# Check that directories exist
for key in ('sdk_path', 'ndk_path', 'build_tools'):
if key not in config:
print "WARNING: %s not set in config" % key
val = config[key]
if key == 'build_tools':
val = os.path.join(config['sdk_path'], 'build-tools', val)
if not os.path.isdir(val):
print "ERROR: No such directory found for %s: %s" % (key, val)
sys.exit(3)
return config
def getapkname(app, build):