mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-03 17:50:11 +02:00
Merge branch 'master' into 'master'
Fix applicationIdSuffix / versionNameSuffix not understood #455 Closes #455 See merge request fdroid/fdroidserver!484
This commit is contained in:
commit
18a7dddd23
@ -1332,7 +1332,9 @@ def remove_debuggable_flags(root_dir):
|
||||
|
||||
vcsearch_g = re.compile(r'''.*[Vv]ersionCode\s*=?\s*["']*([0-9]+)["']*''').search
|
||||
vnsearch_g = re.compile(r'''.*[Vv]ersionName\s*=?\s*(["'])((?:(?=(\\?))\3.)*?)\1.*''').search
|
||||
vnssearch_g = re.compile(r'''.*[Vv]ersionNameSuffix\s*=?\s*(["'])((?:(?=(\\?))\3.)*?)\1.*''').search
|
||||
psearch_g = re.compile(r'''.*(packageName|applicationId)\s*=*\s*["']([^"']+)["'].*''').search
|
||||
fsearch_g = re.compile(r'''.*(applicationIdSuffix)\s*=*\s*["']([^"']+)["'].*''').search
|
||||
|
||||
|
||||
def app_matches_packagename(app, package):
|
||||
@ -1372,6 +1374,8 @@ def parse_androidmanifests(paths, app):
|
||||
package = None
|
||||
|
||||
flavour = None
|
||||
temp_app_id = None
|
||||
temp_version_name = None
|
||||
if app.builds and 'gradle' in app.builds[-1] and app.builds[-1].gradle:
|
||||
flavour = app.builds[-1].gradle[-1]
|
||||
|
||||
@ -1383,6 +1387,16 @@ def parse_androidmanifests(paths, app):
|
||||
if gradle_comment.match(line):
|
||||
continue
|
||||
|
||||
if "applicationId" in line and not temp_app_id:
|
||||
matches = psearch_g(line)
|
||||
if matches:
|
||||
temp_app_id = matches.group(2)
|
||||
|
||||
if "versionName" in line and not temp_version_name:
|
||||
matches = vnsearch_g(line)
|
||||
if matches:
|
||||
temp_version_name = matches.group(2)
|
||||
|
||||
if inside_flavour_group > 0:
|
||||
if inside_required_flavour > 0:
|
||||
matches = psearch_g(line)
|
||||
@ -1390,10 +1404,24 @@ def parse_androidmanifests(paths, app):
|
||||
s = matches.group(2)
|
||||
if app_matches_packagename(app, s):
|
||||
package = s
|
||||
else:
|
||||
# If build.gradle contains applicationIdSuffix add it to the end of package name
|
||||
matches = fsearch_g(line)
|
||||
if matches and temp_app_id:
|
||||
suffix = matches.group(2)
|
||||
temp_app_id = temp_app_id + suffix
|
||||
if app_matches_packagename(app, temp_app_id):
|
||||
package = temp_app_id
|
||||
|
||||
matches = vnsearch_g(line)
|
||||
if matches:
|
||||
version = matches.group(2)
|
||||
else:
|
||||
# If build.gradle contains applicationNameSuffix add it to the end of version name
|
||||
matches = vnssearch_g(line)
|
||||
if matches and temp_version_name:
|
||||
name_suffix = matches.group(2)
|
||||
version = temp_version_name + name_suffix
|
||||
|
||||
matches = vcsearch_g(line)
|
||||
if matches:
|
||||
|
@ -740,6 +740,45 @@ class CommonTest(unittest.TestCase):
|
||||
self.assertEqual(('1.9.8.1-ose', '197', 'at.bitfire.davdroid'),
|
||||
fdroidserver.common.parse_androidmanifests(paths, app))
|
||||
|
||||
app = fdroidserver.metadata.App()
|
||||
build = fdroidserver.metadata.Build()
|
||||
build.gradle = ['libre']
|
||||
app.builds = [build]
|
||||
app.id = 'com.kunzisoft.fdroidtest.applicationidsuffix.libre'
|
||||
paths = [
|
||||
os.path.join(source_files_dir, 'com.kunzisoft.testcase', 'build.gradle'),
|
||||
]
|
||||
for path in paths:
|
||||
self.assertTrue(os.path.isfile(path))
|
||||
self.assertEqual(('1.0-libre', '1', 'com.kunzisoft.fdroidtest.applicationidsuffix.libre'),
|
||||
fdroidserver.common.parse_androidmanifests(paths, app))
|
||||
|
||||
app = fdroidserver.metadata.App()
|
||||
build = fdroidserver.metadata.Build()
|
||||
build.gradle = ['pro']
|
||||
app.builds = [build]
|
||||
app.id = 'com.kunzisoft.fdroidtest.applicationidsuffix.pro'
|
||||
paths = [
|
||||
os.path.join(source_files_dir, 'com.kunzisoft.testcase', 'build.gradle'),
|
||||
]
|
||||
for path in paths:
|
||||
self.assertTrue(os.path.isfile(path))
|
||||
self.assertEqual(('20180430-pro', '20180430', 'com.kunzisoft.fdroidtest.applicationidsuffix.pro'),
|
||||
fdroidserver.common.parse_androidmanifests(paths, app))
|
||||
|
||||
app = fdroidserver.metadata.App()
|
||||
build = fdroidserver.metadata.Build()
|
||||
build.gradle = ['free']
|
||||
app.builds = [build]
|
||||
app.id = 'com.kunzisoft.fdroidtest.applicationidsuffix'
|
||||
paths = [
|
||||
os.path.join(source_files_dir, 'com.kunzisoft.testcase', 'build.gradle'),
|
||||
]
|
||||
for path in paths:
|
||||
self.assertTrue(os.path.isfile(path))
|
||||
self.assertEqual(('1.0-free', '1', 'com.kunzisoft.fdroidtest.applicationidsuffix'),
|
||||
fdroidserver.common.parse_androidmanifests(paths, app))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = optparse.OptionParser()
|
||||
|
62
tests/source-files/com.kunzisoft.testcase/build.gradle
Normal file
62
tests/source-files/com.kunzisoft.testcase/build.gradle
Normal file
@ -0,0 +1,62 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
defaultConfig {
|
||||
applicationId "com.kunzisoft.fdroidtest.applicationidsuffix"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 27
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled = false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
dexOptions {
|
||||
}
|
||||
|
||||
flavorDimensions "tier"
|
||||
productFlavors {
|
||||
libre {
|
||||
applicationIdSuffix = ".libre"
|
||||
versionNameSuffix "-libre"
|
||||
buildConfigField "boolean", "FULL_VERSION", "true"
|
||||
buildConfigField "boolean", "CLOSED_STORE", "false"
|
||||
// ApplicationId : com.kunzisoft.fdroidtest.applicationidsuffix.libre
|
||||
// Version code : 1
|
||||
// Version name : 1.0-libre
|
||||
}
|
||||
pro {
|
||||
applicationIdSuffix = ".pro"
|
||||
versionCode 20180430
|
||||
versionName "20180430-pro"
|
||||
buildConfigField "boolean", "FULL_VERSION", "true"
|
||||
buildConfigField "boolean", "CLOSED_STORE", "true"
|
||||
// ApplicationId : com.kunzisoft.fdroidtest.applicationidsuffix.pro
|
||||
// Version code : 20180430
|
||||
// Version name : 20180430-pro
|
||||
}
|
||||
free {
|
||||
versionNameSuffix "-free"
|
||||
buildConfigField "boolean", "FULL_VERSION", "false"
|
||||
buildConfigField "boolean", "CLOSED_STORE", "true"
|
||||
// ApplicationId : com.kunzisoft.fdroidtest.applicationidsuffix
|
||||
// Version code : 1
|
||||
// Version name : 1.0-free
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
}
|
Loading…
Reference in New Issue
Block a user