🧭 add mirrors to default_repos.xml

This commit is contained in:
Michael Pöhn
2023-07-11 17:25:45 +02:00
committed by Torsten Grote
parent 7459381f0c
commit bcd9cc0548
6 changed files with 60 additions and 10 deletions

View File

@@ -80,8 +80,8 @@ final class ContentProviderMigrator {
}
// add new repo if not existing
if (repo == null) { // new repo to be added to new DB
InitialRepository newRepo = new InitialRepository(name, address, "", certificate,
0, enabled, ++weight);
InitialRepository newRepo = new InitialRepository(
name, address, Arrays.asList(new String[]{}), "", certificate, 0, enabled, ++weight);
long repoId = repoDao.insert(newRepo);
repo = ObjectsCompat.requireNonNull(repoDao.getRepository(repoId));
} else { // old repo that may need an update for the new DB

View File

@@ -75,9 +75,17 @@ public class DBHelper {
boolean hasEnabledRepo = false;
for (int i = 0; i < initialRepos.size(); i += REPO_XML_ITEM_COUNT) {
boolean enabled = initialRepos.get(i + 4).equals("1");
// split addresses into a list
List<String> addresses = new ArrayList<>();
for (String address : initialRepos.get(i + 1).split("\\s+")) {
if (!address.isEmpty()) {
addresses.add(address);
}
}
InitialRepository repo = new InitialRepository(
initialRepos.get(i), // name
initialRepos.get(i + 1), // address
addresses.get(0), // primary address (by convention: the first item)
addresses.subList(1, addresses.size()), // list of mirrors
initialRepos.get(i + 2), // description
initialRepos.get(i + 6), // certificate
Integer.parseInt(initialRepos.get(i + 3)), // version

View File

@@ -6,7 +6,19 @@
<!-- name -->
<item>F-Droid Archive</item>
<!-- address -->
<item>https://f-droid.org/archive</item>
<item>
https://f-droid.org/archive
http://fdroidorg6cooksyluodepej4erfctzk7rrjpjbbr6wx24jh3lqyfwyd.onion/fdroid/archive
http://ftpfaudev4triw2vxiwzf4334e3mynz7osqgtozhbc77fixncqzbyoyd.onion/fdroid/archive
https://fdroid.tetaneutral.net/fdroid/archive
https://ftp.agdsn.de/fdroid/archive
https://ftp.fau.de/fdroid/archive
https://ftp.lysator.liu.se/pub/fdroid/archive
https://mirror.cyberbits.eu/fdroid/archive
https://mirror.fcix.net/fdroid/archive
https://mirror.ossplanet.net/fdroid/archive
https://plug-mirror.rcac.purdue.edu/fdroid/archive
</item>
<!-- description -->
<item>The archive repository of the F-Droid client. This contains older versions of
applications from the main repository.
@@ -25,7 +37,19 @@
<!-- name -->
<item>F-Droid</item>
<!-- address -->
<item>https://f-droid.org/repo</item>
<item>
https://f-droid.org/repo
http://fdroidorg6cooksyluodepej4erfctzk7rrjpjbbr6wx24jh3lqyfwyd.onion/fdroid/repo
http://ftpfaudev4triw2vxiwzf4334e3mynz7osqgtozhbc77fixncqzbyoyd.onion/fdroid/repo
https://fdroid.tetaneutral.net/fdroid/repo
https://ftp.agdsn.de/fdroid/repo
https://ftp.fau.de/fdroid/repo
https://ftp.lysator.liu.se/pub/fdroid/repo
https://mirror.cyberbits.eu/fdroid/repo
https://mirror.fcix.net/fdroid/repo
https://mirror.ossplanet.net/fdroid/repo
https://plug-mirror.rcac.purdue.edu/fdroid/repo
</item>
<!-- description -->
<item>The official F-Droid Free Software repository. Everything in this repository is always built from the source code.
</item>
@@ -43,7 +67,11 @@
<!-- name -->
<item>Guardian Project Archive</item>
<!-- address -->
<item>https://guardianproject.info/fdroid/archive</item>
<item>
https://guardianproject.info/fdroid/archive
https://s3.amazonaws.com/guardianproject/fdroid/archive
https://guardianproject.s3.amazonaws.com/fdroid/archive
</item>
<!-- description -->
<item>The official repository of The Guardian Project apps for use with F-Droid client. This
contains older versions of applications from the main repository.
@@ -62,7 +90,11 @@
<!-- name -->
<item>Guardian Project</item>
<!-- address -->
<item>https://guardianproject.info/fdroid/repo</item>
<item>
https://guardianproject.info/fdroid/repo
https://s3.amazonaws.com/guardianproject/fdroid/repo
https://guardianproject.s3.amazonaws.com/fdroid/repo
</item>
<!-- description -->
<item>The official app repository of The Guardian Project. Applications in this repository
are official binaries build by the original application developers and signed by the

View File

@@ -30,6 +30,7 @@ internal class RepositoryDaoTest : DbTest() {
val repo = InitialRepository(
name = getRandomString(),
address = getRandomString(),
mirrors = listOf(getRandomString(), getRandomString(), getRandomString()),
description = getRandomString(),
certificate = getRandomString(),
version = Random.nextLong(),
@@ -47,10 +48,17 @@ internal class RepositoryDaoTest : DbTest() {
assertEquals(repo.enabled, actualRepo.enabled)
assertEquals(repo.weight, actualRepo.weight)
assertEquals(-1, actualRepo.timestamp)
assertEquals(emptyList(), actualRepo.mirrors)
assertEquals(3, actualRepo.mirrors.size)
assertEquals(emptyList(), actualRepo.userMirrors)
assertEquals(emptyList(), actualRepo.disabledMirrors)
assertEquals(listOf(org.fdroid.download.Mirror(repo.address)), actualRepo.getMirrors())
assertEquals(
listOf(
org.fdroid.download.Mirror(repo.address),
org.fdroid.download.Mirror(repo.mirrors[0]),
org.fdroid.download.Mirror(repo.mirrors[1]),
org.fdroid.download.Mirror(repo.mirrors[2]),
).toSet(), actualRepo.getAllMirrors().toSet()
)
assertEquals(emptyList(), actualRepo.antiFeatures)
assertEquals(emptyList(), actualRepo.categories)
assertEquals(emptyList(), actualRepo.releaseChannels)

View File

@@ -375,9 +375,10 @@ internal data class RepositoryPreferences(
/**
* A reduced version of [Repository] used to pre-populate the [FDroidDatabase].
*/
public data class InitialRepository(
public data class InitialRepository @JvmOverloads constructor(
val name: String,
val address: String,
val mirrors: List<String> = emptyList(),
val description: String,
val certificate: String,
val version: Long,

View File

@@ -140,6 +140,7 @@ internal interface RepositoryDaoInt : RepositoryDao {
enabled = initialRepo.enabled,
)
insert(repositoryPreferences)
insertMirrors(initialRepo.mirrors.map { it -> Mirror(repoId, it, null) })
return repoId
}