mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
Add functions to find apk and tarball paths
This commit is contained in:
parent
b75d8b7271
commit
a9a947af86
@ -311,8 +311,8 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force):
|
||||
ftp.chdir('/home/vagrant/tmp')
|
||||
else:
|
||||
ftp.chdir('/home/vagrant/unsigned')
|
||||
apkfile = app['id'] + '_' + thisbuild['vercode'] + '.apk'
|
||||
tarball = app['id'] + '_' + thisbuild['vercode'] + '_src' + '.tar.gz'
|
||||
apkfile = common.getapkname(app,thisbuild)
|
||||
tarball = common.getsrcname(app,thisbuild)
|
||||
try:
|
||||
ftp.get(apkfile, os.path.join(output_dir, apkfile))
|
||||
ftp.get(tarball, os.path.join(output_dir, tarball))
|
||||
@ -397,9 +397,8 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||
|
||||
# Build the source tarball right before we build the release...
|
||||
print "Creating source tarball..."
|
||||
tarname = app['id'] + '_' + thisbuild['vercode'] + '_src'
|
||||
tarball = tarfile.open(os.path.join(tmp_dir,
|
||||
tarname + '.tar.gz'), "w:gz")
|
||||
tarname = common.getsrcname(app,thisbuild)
|
||||
tarball = tarfile.open(os.path.join(tmp_dir, tarname), "w:gz")
|
||||
def tarexc(f):
|
||||
for vcs_dir in ['.svn', '.git', '.hg', '.bzr']:
|
||||
if f.endswith(vcs_dir):
|
||||
@ -625,15 +624,13 @@ def build_local(app, thisbuild, vcs, build_dir, output_dir, srclib_dir, extlib_d
|
||||
|
||||
# Copy the unsigned apk to our destination directory for further
|
||||
# processing (by publish.py)...
|
||||
dest = os.path.join(output_dir, app['id'] + '_' +
|
||||
thisbuild['vercode'] + '.apk')
|
||||
dest = common.getapkname(app,thisbuild)
|
||||
shutil.copyfile(src, dest)
|
||||
|
||||
# Move the source tarball into the output directory...
|
||||
if output_dir != tmp_dir:
|
||||
tarfilename = tarname + '.tar.gz'
|
||||
shutil.move(os.path.join(tmp_dir, tarfilename),
|
||||
os.path.join(output_dir, tarfilename))
|
||||
shutil.move(os.path.join(tmp_dir, tarname),
|
||||
os.path.join(output_dir, tarname))
|
||||
|
||||
|
||||
def trybuild(app, thisbuild, build_dir, output_dir, also_check_dir, srclib_dir, extlib_dir,
|
||||
@ -644,17 +641,16 @@ def trybuild(app, thisbuild, build_dir, output_dir, also_check_dir, srclib_dir,
|
||||
Returns True if the build was done, False if it wasn't necessary.
|
||||
"""
|
||||
|
||||
dest = os.path.join(output_dir, app['id'] + '_' +
|
||||
thisbuild['vercode'] + '.apk')
|
||||
dest_repo = os.path.join(repo_dir, app['id'] + '_' +
|
||||
thisbuild['vercode'] + '.apk')
|
||||
dest_apk = common.getapkname(app,thisbuild)
|
||||
|
||||
dest = os.path.join(output_dir, dest_apk)
|
||||
dest_repo = os.path.join(repo_dir, dest_apk)
|
||||
|
||||
if os.path.exists(dest) or (not test and os.path.exists(dest_repo)):
|
||||
return False
|
||||
|
||||
if also_check_dir and not test:
|
||||
dest_also = os.path.join(also_check_dir, app['id'] + '_' +
|
||||
thisbuild['vercode'] + '.apk')
|
||||
dest_also = os.path.join(also_check_dir, dest_apk)
|
||||
if os.path.exists(dest_also):
|
||||
return False
|
||||
|
||||
|
@ -464,9 +464,18 @@ def parse_metadata(metafile, **kw):
|
||||
thisbuild = {}
|
||||
thisbuild['origlines'] = lines
|
||||
thisbuild['version'] = parts[0]
|
||||
thisbuild['vercode'] = parts[1]
|
||||
ver = parts[1].split('-')
|
||||
if len(ver) == 1:
|
||||
thisbuild['vercode'] = parts[1]
|
||||
thisbuild['subvercode'] = None
|
||||
elif len(ver) == 2:
|
||||
thisbuild['vercode'] = ver[0]
|
||||
thisbuild['subvercode'] = ver[1]
|
||||
else:
|
||||
raise MetaDataException("Invalid version code for build in " + metafile.name)
|
||||
try:
|
||||
testvercode = int(thisbuild['vercode'])
|
||||
testsubvercode = int(thisbuild['subvercode'])
|
||||
except:
|
||||
raise MetaDataException("Invalid version code for build in " + metafile.name)
|
||||
thisbuild['commit'] = parts[2]
|
||||
@ -623,6 +632,17 @@ def parse_metadata(metafile, **kw):
|
||||
|
||||
return thisinfo
|
||||
|
||||
def getvercode(build):
|
||||
if build['subvercode'] is None:
|
||||
return build['vercode']
|
||||
return "%s-%s" % (build['vercode'], build['subvercode'])
|
||||
|
||||
def getapkname(app, build):
|
||||
return "%s_%s.apk" % (app['id'], getvercode(build))
|
||||
|
||||
def getsrcname(app, build):
|
||||
return "%s_%s_src.tar.gz" % (app['id'], getvercode(build))
|
||||
|
||||
# Write a metadata file.
|
||||
#
|
||||
# 'dest' - The path to the output file
|
||||
@ -675,6 +695,7 @@ def write_metadata(dest, app):
|
||||
writefield('Repo Type')
|
||||
writefield('Repo')
|
||||
mf.write('\n')
|
||||
keystoignore = ['version', 'vercode', 'subvercode', 'commit']
|
||||
for build in app['builds']:
|
||||
writecomments('build:' + build['version'])
|
||||
mf.write('Build Version:')
|
||||
@ -682,10 +703,12 @@ def write_metadata(dest, app):
|
||||
# Keeping the original formatting if we loaded it from a file...
|
||||
mf.write('\\\n'.join(build['origlines']) + '\n')
|
||||
else:
|
||||
mf.write(build['version'] + ',' + build['vercode'] + ',' +
|
||||
build['commit'])
|
||||
mf.write("%s,%s,%s" % (
|
||||
build['version'],
|
||||
getvercode(build),
|
||||
build['commit']))
|
||||
for key,value in build.iteritems():
|
||||
if key not in ['version', 'vercode', 'commit']:
|
||||
if key not in keystoignore:
|
||||
mf.write(',' + key + '=' + value)
|
||||
mf.write('\n')
|
||||
if len(app['builds']) > 0:
|
||||
|
Loading…
Reference in New Issue
Block a user