mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
Merge branch 'master' into 'master'
last PEP8 fixes (everything but E501 line too long and E123 close bracket indent) These two commits fix all the rest of the PEP8 errors and warnings except for: * E123 closing bracket does not match indentation of opening bracket's line * E501 line too long (x > 79 characters) Almost all of the fixed issues were these errors: * E124 closing bracket does not match visual indentation * E125 continuation line does not distinguish itself from next logical line * E126 continuation line over-indented for hanging indent * E127 continuation line over-indented for visual indent * E128 continuation line under-indented for visual indent * E226 missing whitespace around arithmetic operator If you would like to make it run as part of the automated builds, it would just be a matter of adding this line to `jenkins-build`: ``` pep8 --ignore=E123,E501,W fdroid fdroidserver/*.py examples/*.py ```
This commit is contained in:
commit
7a699e4a48
15 changed files with 374 additions and 359 deletions
|
|
@ -449,7 +449,8 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
|||
|
||||
# Prepare the source code...
|
||||
root_dir, srclibpaths = common.prepare_source(vcs, app, thisbuild,
|
||||
build_dir, srclib_dir, extlib_dir, onserver)
|
||||
build_dir, srclib_dir,
|
||||
extlib_dir, onserver)
|
||||
|
||||
# We need to clean via the build tool in case the binary dirs are
|
||||
# different from the default ones
|
||||
|
|
@ -536,9 +537,11 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
|||
with open(manifest, 'r') as f:
|
||||
manifestcontent = f.read()
|
||||
manifestcontent = manifestcontent.replace('</manifest>',
|
||||
'<fdroid buildserverid="' + buildserverid + '"' +
|
||||
' fdroidserverid="' + fdroidserverid + '"' +
|
||||
'/></manifest>')
|
||||
'<fdroid buildserverid="'
|
||||
+ buildserverid + '"'
|
||||
+ ' fdroidserverid="'
|
||||
+ fdroidserverid + '"'
|
||||
+ '/></manifest>')
|
||||
with open(manifest, 'w') as f:
|
||||
f.write(manifestcontent)
|
||||
|
||||
|
|
@ -601,12 +604,16 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
|||
if 'target' in thisbuild:
|
||||
target = thisbuild["target"].split('-')[1]
|
||||
FDroidPopen(['sed', '-i',
|
||||
's@<platform>[0-9]*</platform>@<platform>'+target+'</platform>@g',
|
||||
'pom.xml'], cwd=root_dir)
|
||||
's@<platform>[0-9]*</platform>@<platform>'
|
||||
+ target + '</platform>@g',
|
||||
'pom.xml'],
|
||||
cwd=root_dir)
|
||||
if '@' in thisbuild['maven']:
|
||||
FDroidPopen(['sed', '-i',
|
||||
's@<platform>[0-9]*</platform>@<platform>'+target+'</platform>@g',
|
||||
'pom.xml'], cwd=maven_dir)
|
||||
's@<platform>[0-9]*</platform>@<platform>'
|
||||
+ target + '</platform>@g',
|
||||
'pom.xml'],
|
||||
cwd=maven_dir)
|
||||
|
||||
if 'mvnflags' in thisbuild:
|
||||
mvncmd += thisbuild['mvnflags']
|
||||
|
|
@ -769,8 +776,8 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
|||
if not os.path.exists(src):
|
||||
raise BuildException("Unsigned apk is not at expected location of " + src)
|
||||
|
||||
p = SilentPopen([os.path.join(config['sdk_path'],
|
||||
'build-tools', config['build_tools'], 'aapt'),
|
||||
p = SilentPopen([os.path.join(config['sdk_path'], 'build-tools',
|
||||
config['build_tools'], 'aapt'),
|
||||
'dump', 'badging', src])
|
||||
|
||||
vercode = None
|
||||
|
|
@ -820,7 +827,8 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
|||
raise BuildException(("Unexpected version/version code in output;"
|
||||
" APK: '%s' / '%s', "
|
||||
" Expected: '%s' / '%s'")
|
||||
% (version, str(vercode), thisbuild['version'], str(thisbuild['vercode']))
|
||||
% (version, str(vercode), thisbuild['version'],
|
||||
str(thisbuild['vercode']))
|
||||
)
|
||||
|
||||
# Copy the unsigned apk to our destination directory for further
|
||||
|
|
@ -1020,16 +1028,18 @@ def main():
|
|||
build_dir = os.path.join('build', app['id'])
|
||||
|
||||
# Set up vcs interface and make sure we have the latest code...
|
||||
logging.debug("Getting {0} vcs interface for {1}".format(
|
||||
app['Repo Type'], app['Repo']))
|
||||
logging.debug("Getting {0} vcs interface for {1}"
|
||||
.format(app['Repo Type'], app['Repo']))
|
||||
vcs = common.getvcs(app['Repo Type'], app['Repo'], build_dir)
|
||||
|
||||
first = False
|
||||
|
||||
logging.debug("Checking " + thisbuild['version'])
|
||||
if trybuild(app, thisbuild, build_dir, output_dir, also_check_dir,
|
||||
srclib_dir, extlib_dir, tmp_dir, repo_dir, vcs, options.test,
|
||||
options.server, options.force, options.onserver):
|
||||
if trybuild(app, thisbuild, build_dir, output_dir,
|
||||
also_check_dir, srclib_dir, extlib_dir,
|
||||
tmp_dir, repo_dir, vcs, options.test,
|
||||
options.server, options.force,
|
||||
options.onserver):
|
||||
build_succeeded.append(app)
|
||||
wikilog = "Build succeeded"
|
||||
except BuildException as be:
|
||||
|
|
|
|||
|
|
@ -138,8 +138,8 @@ def check_tags(app, pattern):
|
|||
if not package or package != appid or not version or not vercode:
|
||||
continue
|
||||
|
||||
logging.debug("Manifest exists. Found version {0} ({1})".format(
|
||||
version, vercode))
|
||||
logging.debug("Manifest exists. Found version {0} ({1})"
|
||||
.format(version, vercode))
|
||||
if int(vercode) > int(hcode):
|
||||
htag = tag
|
||||
hcode = str(int(vercode))
|
||||
|
|
@ -340,18 +340,18 @@ def main():
|
|||
if version is not None:
|
||||
stored = app['Current Version']
|
||||
if not stored:
|
||||
logging.info("{0} has no Current Version but has version {1} on the Play Store".format(
|
||||
common.getappname(app), version))
|
||||
logging.info("{0} has no Current Version but has version {1} on the Play Store"
|
||||
.format(common.getappname(app), version))
|
||||
elif LooseVersion(stored) < LooseVersion(version):
|
||||
logging.info("{0} has version {1} on the Play Store, which is bigger than {2}".format(
|
||||
common.getappname(app), version, stored))
|
||||
logging.info("{0} has version {1} on the Play Store, which is bigger than {2}"
|
||||
.format(common.getappname(app), version, stored))
|
||||
else:
|
||||
if stored != version:
|
||||
logging.info("{0} has version {1} on the Play Store, which differs from {2}".format(
|
||||
common.getappname(app), version, stored))
|
||||
logging.info("{0} has version {1} on the Play Store, which differs from {2}"
|
||||
.format(common.getappname(app), version, stored))
|
||||
else:
|
||||
logging.info("{0} has the same version {1} on the Play Store".format(
|
||||
common.getappname(app), version))
|
||||
logging.info("{0} has the same version {1} on the Play Store"
|
||||
.format(common.getappname(app), version))
|
||||
return
|
||||
|
||||
for app in apps:
|
||||
|
|
@ -507,8 +507,7 @@ def main():
|
|||
metadata.write_metadata(metafile, app)
|
||||
if options.commit:
|
||||
logging.info("Commiting update for " + metafile)
|
||||
gitcmd = ["git", "commit", "-m",
|
||||
commitmsg]
|
||||
gitcmd = ["git", "commit", "-m", commitmsg]
|
||||
if 'auto_author' in config:
|
||||
gitcmd.extend(['--author', config['auto_author']])
|
||||
gitcmd.extend(["--", metafile])
|
||||
|
|
|
|||
|
|
@ -731,7 +731,8 @@ def retrieve_string(app_dir, string, xmlfiles=None):
|
|||
# Return list of existing files that will be used to find the highest vercode
|
||||
def manifest_paths(app_dir, flavour):
|
||||
|
||||
possible_manifests = [os.path.join(app_dir, 'AndroidManifest.xml'),
|
||||
possible_manifests = \
|
||||
[os.path.join(app_dir, 'AndroidManifest.xml'),
|
||||
os.path.join(app_dir, 'src', 'main', 'AndroidManifest.xml'),
|
||||
os.path.join(app_dir, 'src', 'AndroidManifest.xml'),
|
||||
os.path.join(app_dir, 'build.gradle')]
|
||||
|
|
@ -1112,13 +1113,15 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
|||
n = build["target"].split('-')[1]
|
||||
FDroidPopen(['sed', '-i',
|
||||
's@compileSdkVersion *[0-9]*@compileSdkVersion ' + n + '@g',
|
||||
'build.gradle'], cwd=root_dir)
|
||||
'build.gradle'],
|
||||
cwd=root_dir)
|
||||
if '@' in build['gradle']:
|
||||
gradle_dir = os.path.join(root_dir, build['gradle'].split('@', 1)[1])
|
||||
gradle_dir = os.path.normpath(gradle_dir)
|
||||
FDroidPopen(['sed', '-i',
|
||||
's@compileSdkVersion *[0-9]*@compileSdkVersion ' + n + '@g',
|
||||
'build.gradle'], cwd=gradle_dir)
|
||||
'build.gradle'],
|
||||
cwd=gradle_dir)
|
||||
|
||||
# Remove forced debuggable flags
|
||||
remove_debuggable_flags(root_dir)
|
||||
|
|
@ -1131,13 +1134,15 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
|||
continue
|
||||
if has_extension(path, 'xml'):
|
||||
p = SilentPopen(['sed', '-i',
|
||||
's/android:versionName="[^"]*"/android:versionName="' + build['version'] + '"/g',
|
||||
's/android:versionName="[^"]*"/android:versionName="'
|
||||
+ build['version'] + '"/g',
|
||||
path])
|
||||
if p.returncode != 0:
|
||||
raise BuildException("Failed to amend manifest")
|
||||
elif has_extension(path, 'gradle'):
|
||||
p = SilentPopen(['sed', '-i',
|
||||
's/versionName *=* *"[^"]*"/versionName = "' + build['version'] + '"/g',
|
||||
's/versionName *=* *"[^"]*"/versionName = "'
|
||||
+ build['version'] + '"/g',
|
||||
path])
|
||||
if p.returncode != 0:
|
||||
raise BuildException("Failed to amend build.gradle")
|
||||
|
|
@ -1148,13 +1153,15 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver=
|
|||
continue
|
||||
if has_extension(path, 'xml'):
|
||||
p = SilentPopen(['sed', '-i',
|
||||
's/android:versionCode="[^"]*"/android:versionCode="' + build['vercode'] + '"/g',
|
||||
's/android:versionCode="[^"]*"/android:versionCode="'
|
||||
+ build['vercode'] + '"/g',
|
||||
path])
|
||||
if p.returncode != 0:
|
||||
raise BuildException("Failed to amend manifest")
|
||||
elif has_extension(path, 'gradle'):
|
||||
p = SilentPopen(['sed', '-i',
|
||||
's/versionCode *=* *[0-9]*/versionCode = ' + build['vercode'] + '/g',
|
||||
's/versionCode *=* *[0-9]*/versionCode = '
|
||||
+ build['vercode'] + '/g',
|
||||
path])
|
||||
if p.returncode != 0:
|
||||
raise BuildException("Failed to amend build.gradle")
|
||||
|
|
@ -1460,8 +1467,8 @@ def isApkDebuggable(apkfile, config):
|
|||
|
||||
:param apkfile: full path to the apk to check"""
|
||||
|
||||
p = SilentPopen([os.path.join(config['sdk_path'],
|
||||
'build-tools', config['build_tools'], 'aapt'),
|
||||
p = SilentPopen([os.path.join(config['sdk_path'], 'build-tools',
|
||||
config['build_tools'], 'aapt'),
|
||||
'dump', 'xmltree', apkfile, 'AndroidManifest.xml'])
|
||||
if p.returncode != 0:
|
||||
logging.critical("Failed to get apk manifest information")
|
||||
|
|
|
|||
|
|
@ -265,8 +265,7 @@ def main():
|
|||
if repo_keyalias is not None:
|
||||
logging.info(' Alias for key in store:\t' + repo_keyalias)
|
||||
logging.info('\nTo complete the setup, add your APKs to "' +
|
||||
os.path.join(fdroiddir, 'repo') + '"' +
|
||||
'''
|
||||
os.path.join(fdroiddir, 'repo') + '"' + '''
|
||||
then run "fdroid update -c; fdroid update". You might also want to edit
|
||||
"config.py" to set the URL, repo name, and more. You should also set up
|
||||
a signing key (a temporary one might have been automatically generated).
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ regex_warnings = {
|
|||
(re.compile(r'^ '),
|
||||
"Unnecessary leading space"),
|
||||
],
|
||||
|
||||
}
|
||||
|
||||
regex_pedantic = {
|
||||
|
|
@ -194,7 +193,6 @@ def main():
|
|||
pwarn("Summary '%s' probably contains redundant info already in app name '%s'" % (
|
||||
summary, name))
|
||||
|
||||
|
||||
# Description size limit
|
||||
desc_chars = sum(len(l) for l in app['Description'])
|
||||
if desc_chars > config['char_limits']['Description']:
|
||||
|
|
@ -213,7 +211,6 @@ def main():
|
|||
if m.match(l):
|
||||
warn("%s at line '%s': %s" % (f, l, r))
|
||||
|
||||
|
||||
# Regex pedantic checks in all kinds of fields
|
||||
if options.pedantic:
|
||||
for f in regex_pedantic:
|
||||
|
|
|
|||
|
|
@ -510,17 +510,17 @@ def parse_metadata(metafile):
|
|||
def add_buildflag(p, thisbuild):
|
||||
bv = p.split('=', 1)
|
||||
if len(bv) != 2:
|
||||
raise MetaDataException("Invalid build flag at {0} in {1}".
|
||||
format(buildlines[0], linedesc))
|
||||
raise MetaDataException("Invalid build flag at {0} in {1}"
|
||||
.format(buildlines[0], linedesc))
|
||||
pk, pv = bv
|
||||
if pk in thisbuild:
|
||||
raise MetaDataException("Duplicate definition on {0} in version {1} of {2}".
|
||||
format(pk, thisbuild['version'], linedesc))
|
||||
raise MetaDataException("Duplicate definition on {0} in version {1} of {2}"
|
||||
.format(pk, thisbuild['version'], linedesc))
|
||||
|
||||
pk = pk.lstrip()
|
||||
if pk not in ordered_flags:
|
||||
raise MetaDataException("Unrecognised build flag at {0} in {1}".
|
||||
format(p, linedesc))
|
||||
raise MetaDataException("Unrecognised build flag at {0} in {1}"
|
||||
.format(p, linedesc))
|
||||
t = flagtype(pk)
|
||||
if t == 'list':
|
||||
# Port legacy ';' separators
|
||||
|
|
@ -530,8 +530,8 @@ def parse_metadata(metafile):
|
|||
elif t == 'script':
|
||||
thisbuild[pk] = pv
|
||||
else:
|
||||
raise MetaDataException("Unrecognised build flag type '%s' at %s in %s" % (
|
||||
t, p, linedesc))
|
||||
raise MetaDataException("Unrecognised build flag type '%s' at %s in %s"
|
||||
% (t, p, linedesc))
|
||||
|
||||
def parse_buildline(lines):
|
||||
value = "".join(lines)
|
||||
|
|
@ -606,8 +606,8 @@ def parse_metadata(metafile):
|
|||
if mode == 3:
|
||||
if not any(line.startswith(s) for s in (' ', '\t')):
|
||||
if 'commit' not in curbuild and 'disable' not in curbuild:
|
||||
raise MetaDataException("No commit specified for {0} in {1}".format(
|
||||
curbuild['version'], linedesc))
|
||||
raise MetaDataException("No commit specified for {0} in {1}"
|
||||
.format(curbuild['version'], linedesc))
|
||||
thisinfo['builds'].append(curbuild)
|
||||
add_comments('build:' + curbuild['version'])
|
||||
mode = 0
|
||||
|
|
@ -662,8 +662,8 @@ def parse_metadata(metafile):
|
|||
curbuild = {}
|
||||
vv = value.split(',')
|
||||
if len(vv) != 2:
|
||||
raise MetaDataException('Build should have comma-separated version and vercode, not "{0}", in {1}'.
|
||||
format(value, linedesc))
|
||||
raise MetaDataException('Build should have comma-separated version and vercode, not "{0}", in {1}'
|
||||
.format(value, linedesc))
|
||||
curbuild['version'] = vv[0]
|
||||
curbuild['vercode'] = vv[1]
|
||||
buildlines = []
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ def main():
|
|||
if p.returncode != 0:
|
||||
logging.info("Key does not exist - generating...")
|
||||
p = FDroidPopen(['keytool', '-genkey',
|
||||
'-keystore', config['keystore'], '-alias', keyalias,
|
||||
'-keystore', config['keystore'],
|
||||
'-alias', keyalias,
|
||||
'-keyalg', 'RSA', '-keysize', '2048',
|
||||
'-validity', '10000',
|
||||
'-storepass:file', config['keystorepassfile'],
|
||||
|
|
|
|||
|
|
@ -90,13 +90,14 @@ def main():
|
|||
|
||||
# Prepare the source code...
|
||||
root_dir, _ = common.prepare_source(vcs, app, thisbuild,
|
||||
build_dir, srclib_dir, extlib_dir, False)
|
||||
build_dir, srclib_dir,
|
||||
extlib_dir, False)
|
||||
|
||||
# Do the scan...
|
||||
buildprobs = common.scan_source(build_dir, root_dir, thisbuild)
|
||||
for problem in buildprobs:
|
||||
problems.append(problem +
|
||||
' in ' + app['id'] + ' ' + thisbuild['version'])
|
||||
problems.append(problem + ' in ' + app['id']
|
||||
+ ' ' + thisbuild['version'])
|
||||
|
||||
except BuildException as be:
|
||||
msg = "Could not scan app %s due to BuildException: %s" % (app['id'], be)
|
||||
|
|
|
|||
|
|
@ -129,9 +129,8 @@ def update_wiki(apps, apks):
|
|||
if 'disable' in thisbuild:
|
||||
if thisbuild['vercode'] == app['Current Version Code']:
|
||||
cantupdate = True
|
||||
apklist.append({
|
||||
#TODO: Nasty: vercode is a string in the build, and an int elsewhere
|
||||
'versioncode': int(thisbuild['vercode']),
|
||||
apklist.append({'versioncode': int(thisbuild['vercode']),
|
||||
'version': thisbuild['version'],
|
||||
'buildproblem': thisbuild['disable']
|
||||
})
|
||||
|
|
@ -143,8 +142,7 @@ def update_wiki(apps, apks):
|
|||
break
|
||||
if not builtit:
|
||||
buildfails = True
|
||||
apklist.append({
|
||||
'versioncode': int(thisbuild['vercode']),
|
||||
apklist.append({'versioncode': int(thisbuild['vercode']),
|
||||
'version': thisbuild['version'],
|
||||
'buildproblem': "The build for this version appears to have failed. Check the [[{0}/lastbuild|build log]].".format(app['id'])
|
||||
})
|
||||
|
|
@ -221,7 +219,8 @@ def update_wiki(apps, apks):
|
|||
# Drop double spaces caused mostly by replacing ':' above
|
||||
apppagename = apppagename.replace(' ', ' ')
|
||||
for expagename in site.allpages(prefix=apppagename,
|
||||
filterredir='nonredirects', generator=False):
|
||||
filterredir='nonredirects',
|
||||
generator=False):
|
||||
if expagename == apppagename:
|
||||
noclobber = True
|
||||
# Another reason not to make the redirect page is if the app name
|
||||
|
|
@ -379,8 +378,8 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
|||
thisinfo['features'] = []
|
||||
thisinfo['icons_src'] = {}
|
||||
thisinfo['icons'] = {}
|
||||
p = FDroidPopen([os.path.join(config['sdk_path'],
|
||||
'build-tools', config['build_tools'], 'aapt'),
|
||||
p = FDroidPopen([os.path.join(config['sdk_path'], 'build-tools',
|
||||
config['build_tools'], 'aapt'),
|
||||
'dump', 'badging', apkfile])
|
||||
if p.returncode != 0:
|
||||
logging.critical("Failed to get apk information")
|
||||
|
|
@ -430,8 +429,8 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
|||
perm = re.match(string_pat, line).group(1)
|
||||
#Filter out this, it's only added with the latest SDK tools and
|
||||
#causes problems for lots of apps.
|
||||
if (perm != "android.hardware.screen.portrait" and
|
||||
perm != "android.hardware.screen.landscape"):
|
||||
if perm != "android.hardware.screen.portrait" \
|
||||
and perm != "android.hardware.screen.landscape":
|
||||
if perm.startswith("android.feature."):
|
||||
perm = perm[16:]
|
||||
thisinfo['features'].append(perm)
|
||||
|
|
@ -530,8 +529,8 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
|||
continue
|
||||
if last_density is None:
|
||||
continue
|
||||
logging.info("Density %s not available, resizing down from %s" % (
|
||||
density, last_density))
|
||||
logging.info("Density %s not available, resizing down from %s"
|
||||
% (density, last_density))
|
||||
|
||||
last_iconpath = os.path.join(
|
||||
get_icon_dir(repodir, last_density), iconfilename)
|
||||
|
|
@ -557,8 +556,8 @@ def scan_apks(apps, apkcache, repodir, knownapks):
|
|||
continue
|
||||
if last_density is None:
|
||||
continue
|
||||
logging.info("Density %s not available, copying from lower density %s" % (
|
||||
density, last_density))
|
||||
logging.info("Density %s not available, copying from lower density %s"
|
||||
% (density, last_density))
|
||||
|
||||
shutil.copyfile(
|
||||
os.path.join(get_icon_dir(repodir, last_density), iconfilename),
|
||||
|
|
@ -704,7 +703,8 @@ def make_index(apps, apks, repodir, archive, categories):
|
|||
return ("fdroid.app:" + link, app['Name'])
|
||||
raise MetaDataException("Cannot resolve app id " + link)
|
||||
addElement('desc',
|
||||
metadata.description_html(app['Description'], linkres), doc, apel)
|
||||
metadata.description_html(app['Description'], linkres),
|
||||
doc, apel)
|
||||
addElement('license', app['License'], doc, apel)
|
||||
if 'Categories' in app:
|
||||
addElement('categories', ','.join(app["Categories"]), doc, apel)
|
||||
|
|
|
|||
|
|
@ -95,7 +95,8 @@ def main():
|
|||
os.path.join("..", "..", unsigned_dir, apkfilename)],
|
||||
cwd=thisdir) != 0:
|
||||
raise Exception("Failed to unpack local build of " + apkfilename)
|
||||
if subprocess.call(['jar', 'xf', os.path.join("..", "..", remoteapk)],
|
||||
if subprocess.call(['jar', 'xf',
|
||||
os.path.join("..", "..", remoteapk)],
|
||||
cwd=thatdir) != 0:
|
||||
raise Exception("Failed to unpack remote build of " + apkfilename)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue