mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
remove txt srclib support
This commit is contained in:
parent
c8f25c2652
commit
cb368a674c
@ -657,46 +657,6 @@ def description_html(s, linkres):
|
|||||||
return ps.text_html
|
return ps.text_html
|
||||||
|
|
||||||
|
|
||||||
def parse_txt_srclib(metadatapath):
|
|
||||||
|
|
||||||
thisinfo = {}
|
|
||||||
|
|
||||||
# Defaults for fields that come from metadata
|
|
||||||
thisinfo['RepoType'] = ''
|
|
||||||
thisinfo['Repo'] = ''
|
|
||||||
thisinfo['Subdir'] = None
|
|
||||||
thisinfo['Prepare'] = None
|
|
||||||
|
|
||||||
if not os.path.exists(metadatapath):
|
|
||||||
return thisinfo
|
|
||||||
|
|
||||||
metafile = open(metadatapath, "r")
|
|
||||||
|
|
||||||
n = 0
|
|
||||||
for line in metafile:
|
|
||||||
n += 1
|
|
||||||
line = line.rstrip('\r\n')
|
|
||||||
if not line or line.startswith("#"):
|
|
||||||
continue
|
|
||||||
|
|
||||||
try:
|
|
||||||
f, v = line.split(':', 1)
|
|
||||||
except ValueError:
|
|
||||||
warn_or_exception(_("Invalid metadata in %s:%d") % (line, n))
|
|
||||||
|
|
||||||
# collapse whitespaces in field names
|
|
||||||
f = f.replace(' ', '')
|
|
||||||
|
|
||||||
if f == "Subdir":
|
|
||||||
thisinfo[f] = v.split(',')
|
|
||||||
else:
|
|
||||||
thisinfo[f] = v
|
|
||||||
|
|
||||||
metafile.close()
|
|
||||||
|
|
||||||
return thisinfo
|
|
||||||
|
|
||||||
|
|
||||||
def parse_yaml_srclib(metadatapath):
|
def parse_yaml_srclib(metadatapath):
|
||||||
|
|
||||||
thisinfo = {'RepoType': '',
|
thisinfo = {'RepoType': '',
|
||||||
@ -752,7 +712,7 @@ def read_srclibs():
|
|||||||
|
|
||||||
The information read will be accessible as metadata.srclibs, which is a
|
The information read will be accessible as metadata.srclibs, which is a
|
||||||
dictionary, keyed on srclib name, with the values each being a dictionary
|
dictionary, keyed on srclib name, with the values each being a dictionary
|
||||||
in the same format as that returned by the parse_txt_srclib function.
|
in the same format as that returned by the parse_yaml_srclib function.
|
||||||
|
|
||||||
A MetaDataException is raised if there are any problems with the srclib
|
A MetaDataException is raised if there are any problems with the srclib
|
||||||
metadata.
|
metadata.
|
||||||
@ -769,10 +729,6 @@ def read_srclibs():
|
|||||||
if not os.path.exists(srcdir):
|
if not os.path.exists(srcdir):
|
||||||
os.makedirs(srcdir)
|
os.makedirs(srcdir)
|
||||||
|
|
||||||
for metadatapath in sorted(glob.glob(os.path.join(srcdir, '*.txt'))):
|
|
||||||
srclibname = os.path.basename(metadatapath[:-4])
|
|
||||||
srclibs[srclibname] = parse_txt_srclib(metadatapath)
|
|
||||||
|
|
||||||
for metadatapath in sorted(glob.glob(os.path.join(srcdir, '*.yml'))):
|
for metadatapath in sorted(glob.glob(os.path.join(srcdir, '*.yml'))):
|
||||||
srclibname = os.path.basename(metadatapath[:-4])
|
srclibname = os.path.basename(metadatapath[:-4])
|
||||||
srclibs[srclibname] = parse_yaml_srclib(metadatapath)
|
srclibs[srclibname] = parse_yaml_srclib(metadatapath)
|
||||||
|
@ -637,88 +637,6 @@ class MetadataTest(unittest.TestCase):
|
|||||||
UpdateCheckMode: None
|
UpdateCheckMode: None
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
def test_parse_txt_srclib(self):
|
|
||||||
fdroidserver.metadata.warnings_action = 'error'
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
|
|
||||||
with open('JSoup.txt', 'w', encoding='utf-8') as f:
|
|
||||||
f.write(textwrap.dedent('''\
|
|
||||||
# Source details (the only mandatory fields)
|
|
||||||
Repo Type:git
|
|
||||||
Repo:https://github.com/jhy/jsoup.git
|
|
||||||
|
|
||||||
# Comma-separated list of subdirs to use. The first existing subdirectory
|
|
||||||
# found between those given will be used. If none is found or provided, the
|
|
||||||
# root of the repo directory will be used instead.
|
|
||||||
Subdir:
|
|
||||||
|
|
||||||
# Any extra commands to prepare the source library
|
|
||||||
Prepare:
|
|
||||||
'''))
|
|
||||||
srclib = fdroidserver.metadata.parse_txt_srclib('JSoup.txt')
|
|
||||||
self.assertDictEqual({'Repo': 'https://github.com/jhy/jsoup.git',
|
|
||||||
'RepoType': 'git',
|
|
||||||
'Subdir': [''],
|
|
||||||
'Prepare': ''},
|
|
||||||
srclib)
|
|
||||||
|
|
||||||
def test_parse_txt_srclib_simple(self):
|
|
||||||
fdroidserver.metadata.warnings_action = 'error'
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
|
|
||||||
with open('simple.txt', 'w', encoding='utf-8') as f:
|
|
||||||
f.write(textwrap.dedent('''\
|
|
||||||
# this should be simple
|
|
||||||
Repo Type:git
|
|
||||||
Repo:https://git.host/repo.git
|
|
||||||
'''))
|
|
||||||
srclib = fdroidserver.metadata.parse_txt_srclib('simple.txt')
|
|
||||||
self.assertDictEqual({'Repo': 'https://git.host/repo.git',
|
|
||||||
'RepoType': 'git',
|
|
||||||
'Subdir': None,
|
|
||||||
'Prepare': None},
|
|
||||||
srclib)
|
|
||||||
|
|
||||||
def test_parse_txt_srclib_simple_blanks(self):
|
|
||||||
fdroidserver.metadata.warnings_action = 'error'
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
|
|
||||||
with open('simple.txt', 'w', encoding='utf-8') as f:
|
|
||||||
f.write(textwrap.dedent('''\
|
|
||||||
# this should be simple
|
|
||||||
|
|
||||||
Repo Type:git
|
|
||||||
|
|
||||||
Repo:https://git.host/repo.git
|
|
||||||
|
|
||||||
Subdir:
|
|
||||||
|
|
||||||
Prepare:
|
|
||||||
'''))
|
|
||||||
srclib = fdroidserver.metadata.parse_txt_srclib('simple.txt')
|
|
||||||
self.assertDictEqual({'Repo': 'https://git.host/repo.git',
|
|
||||||
'RepoType': 'git',
|
|
||||||
'Subdir': [''],
|
|
||||||
'Prepare': ''},
|
|
||||||
srclib)
|
|
||||||
|
|
||||||
def test_parse_txt_srclib_Changelog_cketti(self):
|
|
||||||
fdroidserver.metadata.warnings_action = 'error'
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
|
|
||||||
with open('Changelog-cketti.txt', 'w', encoding='utf-8') as f:
|
|
||||||
f.write(textwrap.dedent('''\
|
|
||||||
Repo Type:git
|
|
||||||
Repo:https://github.com/cketti/ckChangeLog
|
|
||||||
|
|
||||||
Subdir:library,ckChangeLog/src/main
|
|
||||||
Prepare:[ -f project.properties ] || echo 'source.dir=java' > ant.properties && echo -e 'android.library=true\\ntarget=android-19' > project.properties
|
|
||||||
'''))
|
|
||||||
srclib = fdroidserver.metadata.parse_txt_srclib('Changelog-cketti.txt')
|
|
||||||
self.assertDictEqual({'Repo': 'https://github.com/cketti/ckChangeLog',
|
|
||||||
'RepoType': 'git',
|
|
||||||
'Subdir': ['library', 'ckChangeLog/src/main'],
|
|
||||||
'Prepare': "[ -f project.properties ] || echo 'source.dir=java' > "
|
|
||||||
"ant.properties && echo -e "
|
|
||||||
"'android.library=true\\ntarget=android-19' > project.properties"},
|
|
||||||
srclib)
|
|
||||||
|
|
||||||
def test_parse_yaml_srclib_unknown_key(self):
|
def test_parse_yaml_srclib_unknown_key(self):
|
||||||
fdroidserver.metadata.warnings_action = 'error'
|
fdroidserver.metadata.warnings_action = 'error'
|
||||||
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
|
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
|
||||||
@ -885,11 +803,11 @@ class MetadataTest(unittest.TestCase):
|
|||||||
RepoType: git
|
RepoType: git
|
||||||
Repo: https://git.host/repo.git
|
Repo: https://git.host/repo.git
|
||||||
'''))
|
'''))
|
||||||
with open('srclibs/simple-wb.txt', 'w', encoding='utf-8') as f:
|
with open('srclibs/simple-wb.yml', 'w', encoding='utf-8') as f:
|
||||||
f.write(textwrap.dedent('''\
|
f.write(textwrap.dedent('''\
|
||||||
# this should be simple
|
# this should be simple
|
||||||
Repo Type:git
|
RepoType: git
|
||||||
Repo:https://git.host/repo.git
|
Repo: https://git.host/repo.git
|
||||||
|
|
||||||
Subdir:
|
Subdir:
|
||||||
Prepare:
|
Prepare:
|
||||||
|
Loading…
Reference in New Issue
Block a user