mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
Merge branch 'post-txt-refactor' into 'master'
Post .txt refactor See merge request fdroid/fdroidserver!786
This commit is contained in:
commit
3954814a3b
@ -203,15 +203,12 @@ def build_server(app, build, vcs, build_dir, output_dir, log_dir, force):
|
||||
send_dir(lib)
|
||||
# Copy the metadata file too...
|
||||
ftp.chdir(posixpath.join(homedir, 'srclibs'))
|
||||
if os.path.isfile(os.path.join('srclibs', name + '.yml')):
|
||||
ftp.put(os.path.join('srclibs', name + '.yml'),
|
||||
name + '.yml')
|
||||
srclibsfile = os.path.join('srclibs', name + '.yml')
|
||||
if os.path.isfile(srclibsfile):
|
||||
ftp.put(srclibsfile, os.path.basename(srclibsfile))
|
||||
else:
|
||||
raise BuildException("can not find metadata file for "
|
||||
"'{name}', please make sure it is "
|
||||
"present in your 'srclibs' folder."
|
||||
"(supported format: yml)"
|
||||
.format(name=name))
|
||||
raise BuildException(_('cannot find required srclibs: "{path}"')
|
||||
.format(path=srclibsfile))
|
||||
# Copy the main app source code
|
||||
# (no need if it's a srclib)
|
||||
if (not basesrclib) and os.path.exists(build_dir):
|
||||
|
@ -520,15 +520,15 @@ def check_for_unsupported_metadata_files(basedir=""):
|
||||
if not os.path.exists(f + '.yml'):
|
||||
print(_('"%s/" has no matching metadata file!') % f)
|
||||
return_value = True
|
||||
elif os.path.splitext(f)[1][1:] == "yml":
|
||||
elif f.endswith('.yml'):
|
||||
packageName = os.path.splitext(os.path.basename(f))[0]
|
||||
if not common.is_valid_package_name(packageName):
|
||||
print('"' + packageName + '" is an invalid package name!\n'
|
||||
+ 'https://developer.android.com/studio/build/application-id')
|
||||
return_value = True
|
||||
else:
|
||||
print('"' + f.replace(basedir, '')
|
||||
+ '" is not a supported file format (use: .yml)')
|
||||
print(_('"{path}" is not a supported file format (use: metadata/*.yml)')
|
||||
.format(path=f.replace(basedir, '')))
|
||||
return_value = True
|
||||
|
||||
return return_value
|
||||
|
@ -927,8 +927,6 @@ def _decode_bool(s):
|
||||
def parse_metadata(metadatapath, check_vcs=False, refresh=True):
|
||||
'''parse metadata file, optionally checking the git repo for metadata first'''
|
||||
|
||||
_ignored, ext = fdroidserver.common.get_extension(metadatapath)
|
||||
|
||||
app = App()
|
||||
app.metadatapath = metadatapath
|
||||
name, _ignored = fdroidserver.common.get_extension(os.path.basename(metadatapath))
|
||||
@ -937,11 +935,11 @@ def parse_metadata(metadatapath, check_vcs=False, refresh=True):
|
||||
else:
|
||||
app.id = name
|
||||
|
||||
if ext == 'yml':
|
||||
if metadatapath.endswith('.yml'):
|
||||
with open(metadatapath, 'r') as mf:
|
||||
parse_yaml_metadata(mf, app)
|
||||
else:
|
||||
warn_or_exception(_('Unknown metadata format: {path} (use: .yml)')
|
||||
warn_or_exception(_('Unknown metadata format: {path} (use: *.yml)')
|
||||
.format(path=metadatapath))
|
||||
|
||||
if check_vcs and app.Repo:
|
||||
@ -1167,14 +1165,12 @@ build_cont = re.compile(r'^[ \t]')
|
||||
|
||||
|
||||
def write_metadata(metadatapath, app):
|
||||
_ignored, ext = fdroidserver.common.get_extension(metadatapath)
|
||||
|
||||
if ext == 'yml':
|
||||
if metadatapath.endswith('.yml'):
|
||||
if importlib.util.find_spec('ruamel.yaml'):
|
||||
with open(metadatapath, 'w') as mf:
|
||||
return write_yaml(mf, app)
|
||||
else:
|
||||
raise FDroidException('ruamel.yaml not installed, can not write metadata.')
|
||||
raise FDroidException(_('ruamel.yaml not installed, can not write metadata.'))
|
||||
|
||||
warn_or_exception(_('Unknown metadata format: %s') % metadatapath)
|
||||
|
||||
|
@ -38,8 +38,7 @@ def proper_format(app):
|
||||
# read in metadata.py
|
||||
with open(app.metadatapath, 'r') as f:
|
||||
cur_content = f.read()
|
||||
_ignored, extension = common.get_extension(app.metadatapath)
|
||||
if extension == 'yml':
|
||||
if app.metadatapath.endswith('.yml'):
|
||||
metadata.write_yaml(s, app)
|
||||
content = s.getvalue()
|
||||
s.close()
|
||||
@ -68,12 +67,11 @@ def main():
|
||||
|
||||
for appid, app in apps.items():
|
||||
path = app.metadatapath
|
||||
base, ext = common.get_extension(path)
|
||||
if ext != "yml":
|
||||
logging.info(_("Ignoring {ext} file at '{path}'").format(ext=ext, path=path))
|
||||
continue
|
||||
else:
|
||||
if path.endswith('.yml'):
|
||||
logging.info(_("Rewriting '{appid}'").format(appid=appid))
|
||||
else:
|
||||
logging.warning(_('Cannot rewrite "{path}"').format(path=path))
|
||||
continue
|
||||
|
||||
if options.list:
|
||||
if not proper_format(app):
|
||||
|
@ -265,33 +265,33 @@ def scan_source(build_dir, build=metadata.Build()):
|
||||
continue
|
||||
|
||||
path_in_build_dir = os.path.relpath(filepath, build_dir)
|
||||
_ignored, ext = common.get_extension(path_in_build_dir)
|
||||
extension = os.path.splitext(path_in_build_dir)[1]
|
||||
|
||||
if curfile in ('gradle-wrapper.jar', 'gradlew', 'gradlew.bat'):
|
||||
removeproblem(curfile, path_in_build_dir, filepath)
|
||||
elif ext == 'apk':
|
||||
elif extension == '.apk':
|
||||
removeproblem(_('Android APK file'), path_in_build_dir, filepath)
|
||||
|
||||
elif ext == 'a':
|
||||
elif extension == '.a':
|
||||
count += handleproblem(_('static library'), path_in_build_dir, filepath)
|
||||
elif ext == 'aar':
|
||||
elif extension == '.aar':
|
||||
count += handleproblem(_('Android AAR library'), path_in_build_dir, filepath)
|
||||
elif ext == 'class':
|
||||
elif extension == '.class':
|
||||
count += handleproblem(_('Java compiled class'), path_in_build_dir, filepath)
|
||||
elif ext == 'dex':
|
||||
elif extension == '.dex':
|
||||
count += handleproblem(_('Android DEX code'), path_in_build_dir, filepath)
|
||||
elif ext == 'gz':
|
||||
elif extension == '.gz':
|
||||
count += handleproblem(_('gzip file archive'), path_in_build_dir, filepath)
|
||||
elif ext == 'so':
|
||||
elif extension == '.so':
|
||||
count += handleproblem(_('shared library'), path_in_build_dir, filepath)
|
||||
elif ext == 'zip':
|
||||
elif extension == '.zip':
|
||||
count += handleproblem(_('ZIP file archive'), path_in_build_dir, filepath)
|
||||
elif ext == 'jar':
|
||||
elif extension == '.jar':
|
||||
for name in suspects_found(curfile):
|
||||
count += handleproblem('usual suspect \'%s\'' % name, path_in_build_dir, filepath)
|
||||
count += handleproblem(_('Java JAR file'), path_in_build_dir, filepath)
|
||||
|
||||
elif ext == 'java':
|
||||
elif extension == '.java':
|
||||
if not os.path.isfile(filepath):
|
||||
continue
|
||||
with open(filepath, 'r', errors='replace') as f:
|
||||
@ -300,7 +300,7 @@ def scan_source(build_dir, build=metadata.Build()):
|
||||
count += handleproblem('DexClassLoader', path_in_build_dir, filepath)
|
||||
break
|
||||
|
||||
elif ext == 'gradle':
|
||||
elif extension == '.gradle':
|
||||
if not os.path.isfile(filepath):
|
||||
continue
|
||||
with open(filepath, 'r', errors='replace') as f:
|
||||
@ -316,7 +316,7 @@ def scan_source(build_dir, build=metadata.Build()):
|
||||
if not any(r.match(url) for r in allowed_repos):
|
||||
count += handleproblem('unknown maven repo \'%s\'' % url, path_in_build_dir, filepath)
|
||||
|
||||
elif ext in ['', 'bin', 'out', 'exe']:
|
||||
elif extension in ['', '.bin', '.out', '.exe']:
|
||||
if is_binary(filepath):
|
||||
count += handleproblem('binary', path_in_build_dir, filepath)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user