mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 14:30:11 +01:00
Centralise management of srclib metadata
This commit is contained in:
parent
e29da6b023
commit
3a73654d49
@ -983,8 +983,9 @@ def main():
|
|||||||
srclib_dir = os.path.join(build_dir, 'srclib')
|
srclib_dir = os.path.join(build_dir, 'srclib')
|
||||||
extlib_dir = os.path.join(build_dir, 'extlib')
|
extlib_dir = os.path.join(build_dir, 'extlib')
|
||||||
|
|
||||||
# Get all apps...
|
# Read all app and srclib metadata
|
||||||
allapps = metadata.read_metadata(xref=not options.onserver)
|
allapps = metadata.read_metadata(xref=not options.onserver)
|
||||||
|
metadata.read_srclibs()
|
||||||
|
|
||||||
apps = common.read_app_args(args, allapps, True)
|
apps = common.read_app_args(args, allapps, True)
|
||||||
apps = [app for app in apps if (options.force or not app['Disabled']) and
|
apps = [app for app in apps if (options.force or not app['Disabled']) and
|
||||||
|
@ -280,10 +280,9 @@ def getvcs(vcstype, remote, local):
|
|||||||
|
|
||||||
|
|
||||||
def getsrclibvcs(name):
|
def getsrclibvcs(name):
|
||||||
srclib_path = os.path.join('srclibs', name + ".txt")
|
if not name in metadata.srclibs:
|
||||||
if not os.path.exists(srclib_path):
|
|
||||||
raise VCSException("Missing srclib " + name)
|
raise VCSException("Missing srclib " + name)
|
||||||
return metadata.parse_srclib(srclib_path)['Repo Type']
|
return metadata.srclibs[name]['Repo Type']
|
||||||
|
|
||||||
|
|
||||||
class vcs:
|
class vcs:
|
||||||
@ -940,12 +939,10 @@ def getsrclib(spec, srclib_dir, srclibpaths=[], subdir=None,
|
|||||||
if '/' in name:
|
if '/' in name:
|
||||||
name, subdir = name.split('/', 1)
|
name, subdir = name.split('/', 1)
|
||||||
|
|
||||||
srclib_path = os.path.join('srclibs', name + ".txt")
|
if not name in metadata.srclibs:
|
||||||
|
|
||||||
if not os.path.exists(srclib_path):
|
|
||||||
raise BuildException('srclib ' + name + ' not found.')
|
raise BuildException('srclib ' + name + ' not found.')
|
||||||
|
|
||||||
srclib = metadata.parse_srclib(srclib_path)
|
srclib = metadata.srclibs[name]
|
||||||
|
|
||||||
sdir = os.path.join(srclib_dir, name)
|
sdir = os.path.join(srclib_dir, name)
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import glob
|
|||||||
import cgi
|
import cgi
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
srclibs = []
|
srclibs = {}
|
||||||
|
|
||||||
class MetaDataException(Exception):
|
class MetaDataException(Exception):
|
||||||
def __init__(self, value):
|
def __init__(self, value):
|
||||||
@ -421,6 +421,28 @@ def parse_srclib(metafile):
|
|||||||
return thisinfo
|
return thisinfo
|
||||||
|
|
||||||
|
|
||||||
|
def read_srclibs():
|
||||||
|
"""Read all srclib metadata.
|
||||||
|
|
||||||
|
The information read will be accessible as metadata.srclibs, which is a
|
||||||
|
dictionary, keyed on srclib name, with the values each being a dictionary
|
||||||
|
in the same format as that returned by the parse_srclib function.
|
||||||
|
|
||||||
|
A MetaDataException is raised if there are any problems with the srclib
|
||||||
|
metadata.
|
||||||
|
"""
|
||||||
|
global srclibs
|
||||||
|
srclibs = {}
|
||||||
|
|
||||||
|
srcdir = 'srclibs'
|
||||||
|
if not os.path.exists(srcdir):
|
||||||
|
os.makedirs(srcdir)
|
||||||
|
|
||||||
|
for metafile in sorted(glob.glob(os.path.join(srcdir, '*.txt'))):
|
||||||
|
srclibname = os.path.basename(metafile[:-4])
|
||||||
|
srclibs[srclibname] = parse_srclib(metafile)
|
||||||
|
|
||||||
|
|
||||||
# Read all metadata. Returns a list of 'app' objects (which are dictionaries as
|
# Read all metadata. Returns a list of 'app' objects (which are dictionaries as
|
||||||
# returned by the parse_metadata function.
|
# returned by the parse_metadata function.
|
||||||
def read_metadata(xref=True):
|
def read_metadata(xref=True):
|
||||||
|
@ -47,9 +47,10 @@ def main():
|
|||||||
|
|
||||||
config = common.read_config(options)
|
config = common.read_config(options)
|
||||||
|
|
||||||
# Get all apps...
|
# Read all app and srclib metadata
|
||||||
allapps = metadata.read_metadata()
|
allapps = metadata.read_metadata()
|
||||||
apps = common.read_app_args(args, allapps, True)
|
apps = common.read_app_args(args, allapps, True)
|
||||||
|
metadata.read_srclibs()
|
||||||
|
|
||||||
problems = []
|
problems = []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user