provide warning if config items will not preserve order

If a group of items are enclosed in {}, then that will be a Python set,
which does not preserve order.  To preserve order, the data must be either
a tuple () or list [].
This commit is contained in:
Hans-Christoph Steiner 2017-02-24 10:28:00 +01:00
parent 388c336e76
commit 4e39621601
2 changed files with 7 additions and 1 deletions

View File

@ -221,6 +221,12 @@ def read_config(opts, config_file='config.py'):
logging.critical("Missing config file - is this a repo directory?")
sys.exit(2)
for k in ('mirrors', 'install_list', 'uninstall_list', 'serverwebroot', 'servergitroot'):
if k in config:
if not type(config[k]) in (str, list, tuple):
logging.warn('"' + k + '" will be in random order!'
+ ' Use () or [] brackets if order is important!')
# smartcardoptions must be a list since its command line args for Popen
if 'smartcardoptions' in config:
config['smartcardoptions'] = config['smartcardoptions'].split(' ')

View File

@ -131,7 +131,7 @@ cd $REPOROOT
$fdroid init
sed -i.tmp 's,^ *repo_description.*,repo_description = """获取已安装在您的设备上的应用的,' config.py
echo "mirrors = {'https://foo.bar/fdroid', 'http://secret.onion/fdroid'}" >> config.py
echo "mirrors = ('https://foo.bar/fdroid', 'http://secret.onion/fdroid')" >> config.py
mkdir metadata
cp $WORKSPACE/tests/urzip.apk repo/
cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.txt metadata/