Merge branch 'debug-build-tricks' into 'master'
debug build tricks: set applicationId, versionName, versionCode See merge request fdroid/fdroidclient!609
This commit is contained in:
commit
3fbf77c276
@ -229,6 +229,40 @@ android {
|
|||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
applicationIdSuffix ".debug"
|
||||||
|
resValue "string", "applicationId", defaultConfig.applicationId + applicationIdSuffix
|
||||||
|
versionNameSuffix "-debug"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set the debug versionCode based on DB verson and how many commits in the repo */
|
||||||
|
applicationVariants.all { variant ->
|
||||||
|
if (variant.buildType.isDebuggable()) {
|
||||||
|
// default to a timestamp, in case anything fails later
|
||||||
|
variant.mergedFlavor.versionCode = new Date().getTime() / 1000
|
||||||
|
try {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'git', 'rev-list', '--first-parent', '--count', 'HEAD'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
def commitCount = Integer.parseInt(stdout.toString().trim())
|
||||||
|
stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'sed', '-n', 's,.*DB_VERSION *= *\\([0-9][0-9]*\\).*,\\1,p', 'src/main/java/org/fdroid/fdroid/data/DBHelper.java'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
def dbVersion = Integer.parseInt(stdout.toString().trim())
|
||||||
|
println 'Setting debug versionCode: ' + sprintf("%d%05d", [dbVersion, commitCount])
|
||||||
|
variant.mergedFlavor.versionCode = Integer.parseInt(sprintf("%d%05d", [dbVersion, commitCount]))
|
||||||
|
}
|
||||||
|
catch (ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
testOptions {
|
testOptions {
|
||||||
unitTests {
|
unitTests {
|
||||||
// prevent tests from dying on android.util.Log calls
|
// prevent tests from dying on android.util.Log calls
|
||||||
|
@ -25,6 +25,11 @@ import static org.fdroid.fdroid.Assert.assertValidUri;
|
|||||||
@SuppressWarnings("LineLength")
|
@SuppressWarnings("LineLength")
|
||||||
public class ProviderUriTests {
|
public class ProviderUriTests {
|
||||||
|
|
||||||
|
private static final String CONTENT_URI_BASE = "content://" + FDroidProvider.AUTHORITY;
|
||||||
|
private static final String APK_PROVIDER_URI_BASE = CONTENT_URI_BASE + ".ApkProvider";
|
||||||
|
private static final String APP_PROVIDER_URI_BASE = CONTENT_URI_BASE + ".AppProvider";
|
||||||
|
private static final String TEMP_APP_PROVIDER_URI_BASE = CONTENT_URI_BASE + ".TempAppProvider";
|
||||||
|
|
||||||
private ShadowContentResolver resolver;
|
private ShadowContentResolver resolver;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -47,7 +52,7 @@ public class ProviderUriTests {
|
|||||||
@Test
|
@Test
|
||||||
public void validInstalledAppProviderUris() {
|
public void validInstalledAppProviderUris() {
|
||||||
TestUtils.registerContentProvider(InstalledAppProvider.getAuthority(), InstalledAppProvider.class);
|
TestUtils.registerContentProvider(InstalledAppProvider.getAuthority(), InstalledAppProvider.class);
|
||||||
String[] projection = new String[] {InstalledAppTable.Cols._ID};
|
String[] projection = new String[]{InstalledAppTable.Cols._ID};
|
||||||
assertValidUri(resolver, InstalledAppProvider.getContentUri(), projection);
|
assertValidUri(resolver, InstalledAppProvider.getContentUri(), projection);
|
||||||
assertValidUri(resolver, InstalledAppProvider.getAppUri("org.example.app"), projection);
|
assertValidUri(resolver, InstalledAppProvider.getAppUri("org.example.app"), projection);
|
||||||
assertValidUri(resolver, InstalledAppProvider.getSearchUri("blah"), projection);
|
assertValidUri(resolver, InstalledAppProvider.getSearchUri("blah"), projection);
|
||||||
@ -66,7 +71,7 @@ public class ProviderUriTests {
|
|||||||
@Test
|
@Test
|
||||||
public void validRepoProviderUris() {
|
public void validRepoProviderUris() {
|
||||||
TestUtils.registerContentProvider(RepoProvider.getAuthority(), RepoProvider.class);
|
TestUtils.registerContentProvider(RepoProvider.getAuthority(), RepoProvider.class);
|
||||||
String[] projection = new String[] {Schema.RepoTable.Cols._ID};
|
String[] projection = new String[]{Schema.RepoTable.Cols._ID};
|
||||||
assertValidUri(resolver, RepoProvider.getContentUri(), projection);
|
assertValidUri(resolver, RepoProvider.getContentUri(), projection);
|
||||||
assertValidUri(resolver, RepoProvider.getContentUri(10000L), projection);
|
assertValidUri(resolver, RepoProvider.getContentUri(10000L), projection);
|
||||||
assertValidUri(resolver, RepoProvider.allExceptSwapUri(), projection);
|
assertValidUri(resolver, RepoProvider.allExceptSwapUri(), projection);
|
||||||
@ -82,25 +87,26 @@ public class ProviderUriTests {
|
|||||||
@Test
|
@Test
|
||||||
public void validAppProviderUris() {
|
public void validAppProviderUris() {
|
||||||
TestUtils.registerContentProvider(AppProvider.getAuthority(), AppProvider.class);
|
TestUtils.registerContentProvider(AppProvider.getAuthority(), AppProvider.class);
|
||||||
String[] projection = new String[] {Schema.AppMetadataTable.Cols._ID};
|
String[] projection = new String[]{Schema.AppMetadataTable.Cols._ID};
|
||||||
assertValidUri(resolver, AppProvider.getContentUri(), "content://org.fdroid.fdroid.data.AppProvider", projection);
|
assertValidUri(resolver, AppProvider.getContentUri(), APP_PROVIDER_URI_BASE, projection);
|
||||||
assertValidUri(resolver, AppProvider.getSearchUri("'searching!'", null), "content://org.fdroid.fdroid.data.AppProvider/search/'searching!'", projection);
|
assertValidUri(resolver, AppProvider.getSearchUri("'searching!'", null), APP_PROVIDER_URI_BASE + "/search/'searching!'", projection);
|
||||||
assertValidUri(resolver, AppProvider.getSearchUri("'searching!'", "Games"), "content://org.fdroid.fdroid.data.AppProvider/search/'searching!'/Games", projection);
|
assertValidUri(resolver, AppProvider.getSearchUri("'searching!'", "Games"), APP_PROVIDER_URI_BASE + "/search/'searching!'/Games", projection);
|
||||||
assertValidUri(resolver, AppProvider.getSearchUri("/", null), "content://org.fdroid.fdroid.data.AppProvider/search/%2F", projection);
|
assertValidUri(resolver, AppProvider.getSearchUri("/", null), APP_PROVIDER_URI_BASE + "/search/%2F", projection);
|
||||||
assertValidUri(resolver, AppProvider.getSearchUri("/", "Games"), "content://org.fdroid.fdroid.data.AppProvider/search/%2F/Games", projection);
|
assertValidUri(resolver, AppProvider.getSearchUri("/", "Games"), APP_PROVIDER_URI_BASE + "/search/%2F/Games", projection);
|
||||||
assertValidUri(resolver, AppProvider.getSearchUri("", null), "content://org.fdroid.fdroid.data.AppProvider", projection);
|
assertValidUri(resolver, AppProvider.getSearchUri("", null), APP_PROVIDER_URI_BASE, projection);
|
||||||
assertValidUri(resolver, AppProvider.getCategoryUri("Games"), "content://org.fdroid.fdroid.data.AppProvider/category/Games", projection);
|
assertValidUri(resolver, AppProvider.getSearchUri("", "Games"), APP_PROVIDER_URI_BASE + "/category/Games", projection);
|
||||||
assertValidUri(resolver, AppProvider.getSearchUri("", "Games"), "content://org.fdroid.fdroid.data.AppProvider/category/Games", projection);
|
assertValidUri(resolver, AppProvider.getCategoryUri("Games"), APP_PROVIDER_URI_BASE + "/category/Games", projection);
|
||||||
assertValidUri(resolver, AppProvider.getSearchUri((String) null, null), "content://org.fdroid.fdroid.data.AppProvider", projection);
|
assertValidUri(resolver, AppProvider.getSearchUri((String) null, null), APP_PROVIDER_URI_BASE, projection);
|
||||||
assertValidUri(resolver, AppProvider.getSearchUri((String) null, "Games"), "content://org.fdroid.fdroid.data.AppProvider/category/Games", projection);
|
assertValidUri(resolver, AppProvider.getSearchUri((String) null, "Games"), APP_PROVIDER_URI_BASE + "/category/Games", projection);
|
||||||
assertValidUri(resolver, AppProvider.getInstalledUri(), "content://org.fdroid.fdroid.data.AppProvider/installed", projection);
|
assertValidUri(resolver, AppProvider.getInstalledUri(), APP_PROVIDER_URI_BASE + "/installed", projection);
|
||||||
assertValidUri(resolver, AppProvider.getCanUpdateUri(), "content://org.fdroid.fdroid.data.AppProvider/canUpdate", projection);
|
assertValidUri(resolver, AppProvider.getCanUpdateUri(), APP_PROVIDER_URI_BASE + "/canUpdate", projection);
|
||||||
|
|
||||||
App app = new App();
|
App app = new App();
|
||||||
app.repoId = 1;
|
app.repoId = 1;
|
||||||
app.packageName = "org.fdroid.fdroid";
|
app.packageName = "org.fdroid.fdroid";
|
||||||
|
|
||||||
assertValidUri(resolver, AppProvider.getSpecificAppUri(app.packageName, app.repoId), "content://org.fdroid.fdroid.data.AppProvider/app/1/org.fdroid.fdroid", projection);
|
assertValidUri(resolver, AppProvider.getSpecificAppUri(app.packageName, app.repoId),
|
||||||
|
APP_PROVIDER_URI_BASE + "/app/1/org.fdroid.fdroid", projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -116,8 +122,9 @@ public class ProviderUriTests {
|
|||||||
packageNames.add("org.fdroid.fdroid");
|
packageNames.add("org.fdroid.fdroid");
|
||||||
packageNames.add("com.example.com");
|
packageNames.add("com.example.com");
|
||||||
|
|
||||||
assertValidUri(resolver, TempAppProvider.getAppsUri(packageNames, 1), "content://org.fdroid.fdroid.data.TempAppProvider/apps/1/org.fdroid.fdroid%2Ccom.example.com", projection);
|
assertValidUri(resolver, TempAppProvider.getAppsUri(packageNames, 1),
|
||||||
assertValidUri(resolver, TempAppProvider.getContentUri(), "content://org.fdroid.fdroid.data.TempAppProvider", projection);
|
TEMP_APP_PROVIDER_URI_BASE + "/apps/1/org.fdroid.fdroid%2Ccom.example.com", projection);
|
||||||
|
assertValidUri(resolver, TempAppProvider.getContentUri(), TEMP_APP_PROVIDER_URI_BASE, projection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -130,17 +137,22 @@ public class ProviderUriTests {
|
|||||||
@Test
|
@Test
|
||||||
public void validApkProviderUris() {
|
public void validApkProviderUris() {
|
||||||
TestUtils.registerContentProvider(ApkProvider.getAuthority(), ApkProvider.class);
|
TestUtils.registerContentProvider(ApkProvider.getAuthority(), ApkProvider.class);
|
||||||
String[] projection = new String[] {Schema.ApkTable.Cols._ID};
|
String[] projection = new String[]{Schema.ApkTable.Cols._ID};
|
||||||
|
|
||||||
List<Apk> apks = new ArrayList<>(10);
|
List<Apk> apks = new ArrayList<>(10);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
apks.add(new MockApk("com.example." + i, i));
|
apks.add(new MockApk("com.example." + i, i));
|
||||||
}
|
}
|
||||||
|
|
||||||
assertValidUri(resolver, ApkProvider.getContentUri(), "content://org.fdroid.fdroid.data.ApkProvider", projection);
|
assertValidUri(resolver, ApkProvider.getContentUri(),
|
||||||
assertValidUri(resolver, ApkProvider.getAppUri("org.fdroid.fdroid"), "content://org.fdroid.fdroid.data.ApkProvider/app/org.fdroid.fdroid", projection);
|
APK_PROVIDER_URI_BASE, projection);
|
||||||
assertValidUri(resolver, ApkProvider.getApkFromAnyRepoUri(new MockApk("org.fdroid.fdroid", 100)), "content://org.fdroid.fdroid.data.ApkProvider/apk-any-repo/100/org.fdroid.fdroid", projection);
|
assertValidUri(resolver, ApkProvider.getAppUri("org.fdroid.fdroid"),
|
||||||
assertValidUri(resolver, ApkProvider.getApkFromAnyRepoUri("org.fdroid.fdroid", 100, null), "content://org.fdroid.fdroid.data.ApkProvider/apk-any-repo/100/org.fdroid.fdroid", projection);
|
APK_PROVIDER_URI_BASE + "/app/org.fdroid.fdroid", projection);
|
||||||
assertValidUri(resolver, ApkProvider.getRepoUri(1000), "content://org.fdroid.fdroid.data.ApkProvider/repo/1000", projection);
|
assertValidUri(resolver, ApkProvider.getApkFromAnyRepoUri(new MockApk("org.fdroid.fdroid", 100)),
|
||||||
|
APK_PROVIDER_URI_BASE + "/apk-any-repo/100/org.fdroid.fdroid", projection);
|
||||||
|
assertValidUri(resolver, ApkProvider.getApkFromAnyRepoUri("org.fdroid.fdroid", 100, null),
|
||||||
|
APK_PROVIDER_URI_BASE + "/apk-any-repo/100/org.fdroid.fdroid", projection);
|
||||||
|
assertValidUri(resolver, ApkProvider.getRepoUri(1000),
|
||||||
|
APK_PROVIDER_URI_BASE + "/repo/1000", projection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,6 @@ apt-get update
|
|||||||
apt-get install -y --no-install-recommends -t stretch-backports \
|
apt-get install -y --no-install-recommends -t stretch-backports \
|
||||||
fdroidserver openssh-client rsync python3-qrcode
|
fdroidserver openssh-client rsync python3-qrcode
|
||||||
|
|
||||||
db=`sed -n 's,.*DB_VERSION *= *\([0-9][0-9]*\).*,\1,p' app/src/main/java/org/fdroid/fdroid/data/DBHelper.java`
|
|
||||||
count=`git rev-list --first-parent --count HEAD`
|
|
||||||
sed -i "s,versionCode *[0-9][0-9]*.*,versionCode `printf '%d%05d' $db $count`," app/build.gradle
|
|
||||||
|
|
||||||
repo_git_base=${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}-nightly
|
repo_git_base=${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}-nightly
|
||||||
repo_base=https://gitlab.com/${repo_git_base}
|
repo_base=https://gitlab.com/${repo_git_base}
|
||||||
repo_url=${repo_base}/raw/master/fdroid/repo
|
repo_url=${repo_base}/raw/master/fdroid/repo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user