1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 22:40:12 +01:00

Merge branch 'get_release_filename' into 'master'

fix invalid extension of output apk

Closes fdroiddata#2410

See merge request fdroid/fdroidserver!969
This commit is contained in:
Jochen Sprickerhof 2021-06-24 13:42:28 +00:00
commit ecadad63f1
3 changed files with 40 additions and 3 deletions

View File

@ -810,7 +810,12 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
# Copy the unsigned APK to our destination directory for further
# processing (by publish.py)...
dest = os.path.join(output_dir, common.get_release_filename(app, build))
dest = os.path.join(
output_dir,
common.get_release_filename(
app, build, common.get_file_extension(src)
)
)
shutil.copyfile(src, dest)
# Move the source tarball into the output directory...

View File

@ -785,8 +785,10 @@ def apk_parse_release_filename(apkname):
return None, None, None
def get_release_filename(app, build):
if build.output:
def get_release_filename(app, build, extension=None):
if extension:
return "%s_%s.%s" % (app.id, build.versionCode, extension)
if build.output and get_file_extension(build.output):
return "%s_%s.%s" % (app.id, build.versionCode, get_file_extension(build.output))
else:
return "%s_%s.apk" % (app.id, build.versionCode)

View File

@ -2112,6 +2112,36 @@ class CommonTest(unittest.TestCase):
self.assertEqual(tags, ['8.9.5', '8.9.4', '8.9.3', '8,9,3',
'8.9.3b', 'awesome_release', '8.6.3'])
def test_get_release_filename(self):
app = fdroidserver.metadata.App()
app.id = 'test.app'
build = fdroidserver.metadata.Build()
build.versionCode = 123
build.output = 'build/apk/*'
self.assertEqual(
fdroidserver.common.get_release_filename(app, build),
"%s_%s.apk" % (app.id, build.versionCode),
)
build.output = 'build/apk/*.zip'
self.assertEqual(
fdroidserver.common.get_release_filename(app, build),
"%s_%s.zip" % (app.id, build.versionCode),
)
build.output = 'build/apk/*.apk'
self.assertEqual(
fdroidserver.common.get_release_filename(app, build),
"%s_%s.apk" % (app.id, build.versionCode),
)
build.output = 'build/apk/*.apk'
self.assertEqual(
fdroidserver.common.get_release_filename(app, build, 'exe'),
"%s_%s.exe" % (app.id, build.versionCode),
)
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))