mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
Move the Linux runtime to Ubuntu 26.04 LTS with a separate Kubuntu desktop (#1733)
This commit is contained in:
1 parent
5de690ef39
commit
29c83976d0
305 files changed
+9383
-462
No files matched your search
@@ -0,0 +1,47 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class AccountsMergeTest {
|
||||
private val own = "root:x:10123:10123:root:/root:/bin/bash"
|
||||
private val zero = "root:x:0:0:root:/root:/bin/bash"
|
||||
|
||||
@Test fun systemUsersSurvive() {
|
||||
val existing = "root:x:0:0:root:/root:/bin/bash\ndaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\n_apt:x:42:65534::/nonexistent:/usr/sbin/nologin\nmessagebus:x:100:102::/nonexistent:/usr/sbin/nologin\n"
|
||||
assertEquals("$own\n$zero\ndaemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin\n_apt:x:42:65534::/nonexistent:/usr/sbin/nologin\nmessagebus:x:100:102::/nonexistent:/usr/sbin/nologin\n",
|
||||
LinuxRuntime.mergedAccounts(existing, 2, own, zero, 10123))
|
||||
}
|
||||
|
||||
@Test fun anOldSingleLineFileIsReplacedOnce() {
|
||||
val merged = LinuxRuntime.mergedAccounts("$own\n", 2, own, zero, 10123)
|
||||
assertEquals("$own\n$zero\n", merged)
|
||||
assertEquals(merged, LinuxRuntime.mergedAccounts(merged, 2, own, zero, 10123))
|
||||
}
|
||||
|
||||
@Test fun anotherAppUidIsDropped() {
|
||||
assertEquals("$own\n$zero\n", LinuxRuntime.mergedAccounts("root:x:10099:10099:root:/root:/bin/bash\n", 2, own, zero, 10123))
|
||||
}
|
||||
|
||||
@Test fun noFileYet() {
|
||||
assertEquals("$own\n$zero\n", LinuxRuntime.mergedAccounts(null, 2, own, zero, 10123))
|
||||
}
|
||||
|
||||
@Test fun groupsKeepMembers() {
|
||||
val existing = "root:x:0:\nsudo:x:27:\naudio:x:29:pulse\n"
|
||||
assertEquals("root:x:10123:\nroot:x:0:\nsudo:x:27:\naudio:x:29:pulse\n",
|
||||
LinuxRuntime.mergedAccounts(existing, 2, "root:x:10123:", "root:x:0:", 10123))
|
||||
}
|
||||
|
||||
@Test fun storageGroupsAreAddedWithRoot() {
|
||||
assertEquals("root:x:0:\nsudo:x:27:\nsdcard_rw:x:1015:root\nmedia_rw:x:1023:root\neverybody:x:9997:root\n",
|
||||
LinuxRuntime.withStorageGroups("root:x:0:\nsudo:x:27:\n"))
|
||||
}
|
||||
|
||||
@Test fun existingStorageGroupsGainRootOnce() {
|
||||
val existing = "root:x:0:\nmedia_rw:x:1023:pulse\nsdcard_rw:x:1015:root\nshared:x:9997:\n"
|
||||
val updated = LinuxRuntime.withStorageGroups(existing)
|
||||
assertEquals("root:x:0:\nmedia_rw:x:1023:pulse,root\nsdcard_rw:x:1015:root\nshared:x:9997:root\n", updated)
|
||||
assertEquals(updated, LinuxRuntime.withStorageGroups(updated))
|
||||
}
|
||||
}
|
||||
@@ -160,4 +160,25 @@ class BwrapSpawnerPlanTest {
|
||||
assertFalse(plan.binds.any { it.guest.startsWith("/app/bin/") })
|
||||
assertFalse(File(dir, "zypak-wrapper").exists())
|
||||
}
|
||||
|
||||
@Test fun preloadsStayOutOfSandboxesWithAnOlderGlibc() {
|
||||
val base = Files.createTempDirectory("glibc").toFile()
|
||||
try {
|
||||
val rootfs = File(base, "rootfs")
|
||||
File(rootfs, "usr/local/lib").mkdirs()
|
||||
File(rootfs, "etc").mkdirs()
|
||||
File(rootfs, "etc/ld.so.preload").writeText("/usr/local/lib/libone.so\n/usr/local/lib/libtwo.so\n")
|
||||
File(rootfs, "usr/local/lib/libone.so").writeText("x GLIBC_2.17 y GLIBC_2.34 z")
|
||||
File(rootfs, "usr/local/lib/libtwo.so").writeText("GLIBC_2.38 GLIBC_2.25")
|
||||
val old = File(base, "old-libc").apply { writeText("GNU C Library (Ubuntu GLIBC 2.23-0ubuntu11) stable release version 2.23, by Roland") }
|
||||
val new = File(base, "new-libc").apply { writeText("GNU C Library (Ubuntu GLIBC 2.43-0ubuntu1) stable release version 2.43.") }
|
||||
val same = File(base, "same-libc").apply { writeText("stable release version 2.38.") }
|
||||
assertFalse(BwrapSpawner.preloadFits(rootfs.path, old.path))
|
||||
assertTrue(BwrapSpawner.preloadFits(rootfs.path, new.path))
|
||||
assertTrue(BwrapSpawner.preloadFits(rootfs.path, same.path))
|
||||
assertTrue(BwrapSpawner.preloadFits(rootfs.path, File(base, "missing").path))
|
||||
} finally {
|
||||
base.deleteRecursively()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,4 +76,22 @@ class DesktopFileRemovalTest {
|
||||
file("var/lib/pacman/local/base-1/files", "%FILES%\nusr/\nusr/bin/\nusr/bin/gamescope\n\n%BACKUP%\netc/config\n")
|
||||
assertEquals(setOf("usr/bin/gamescope"), DesktopFileRemoval.runtimeFiles(root))
|
||||
}
|
||||
|
||||
@Test fun desktopPackageRecordsAreNotRuntimeFilesAndAreRemovedWithTheDesktop() {
|
||||
file("var/lib/pacman/local/base-1/files", "%FILES%\nusr/bin/gamescope\n")
|
||||
file("var/lib/pacman/local/kate-26.04.3-1/files", "%FILES%\nusr/bin/kate\n")
|
||||
file("var/lib/pacman/local/kate-26.04.3-1/desc", "%NAME%\nkate\n")
|
||||
file("var/lib/pacman/local/htop-3.5.3-1/files", "%FILES%\nusr/bin/htop\n")
|
||||
file("var/lib/pacman/sync/droiddeck.db", "db")
|
||||
file("var/lib/pacman/droiddeck-desktop", "stamp")
|
||||
file("usr/share/droiddeck/pacman/desktop-packages.txt", "kate 26.04.3-1\n../../etc 1\n")
|
||||
val records = DesktopFileRemoval.desktopRecords(root)
|
||||
assertEquals(setOf("kate-26.04.3-1"), records)
|
||||
assertEquals(setOf("usr/bin/gamescope", "usr/bin/htop"), DesktopFileRemoval.runtimeFiles(root))
|
||||
DesktopFileRemoval.removeRecords(root, records)
|
||||
assertFalse(File(root, "var/lib/pacman/local/kate-26.04.3-1").exists())
|
||||
assertTrue(File(root, "var/lib/pacman/local/htop-3.5.3-1/files").exists())
|
||||
assertFalse(File(root, "var/lib/pacman/sync/droiddeck.db").exists())
|
||||
assertFalse(File(root, "var/lib/pacman/droiddeck-desktop").exists())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import com.droiddeck.launcher.core.Hashes
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.util.zip.GZIPOutputStream
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class DesktopPackTest {
|
||||
private val parent = Files.createTempDirectory("pack").toFile()
|
||||
private val root = File(parent, "root").apply { mkdirs() }
|
||||
|
||||
@After fun tearDown() { FileUtils.delete(parent) }
|
||||
|
||||
private fun file(path: String, text: String) = File(root, path).apply { parentFile?.mkdirs(); writeText(text) }
|
||||
|
||||
private fun line(kind: Char, path: String): String {
|
||||
val file = File(root, path)
|
||||
return when {
|
||||
Files.isSymbolicLink(file.toPath()) -> "$kind\tL\t0\t${Files.readSymbolicLink(file.toPath())}\t$path"
|
||||
file.isDirectory -> "$kind\tD\t0\t-\t$path"
|
||||
else -> "$kind\tF\t${file.length()}\t${Hashes.sha256(file)}\t$path"
|
||||
}
|
||||
}
|
||||
|
||||
private fun manifest(lines: List<String>) {
|
||||
val target = File(root, "${DesktopPack.META}/files.tsv.gz").apply { parentFile?.mkdirs() }
|
||||
GZIPOutputStream(target.outputStream()).bufferedWriter().use { w -> lines.forEach { w.write(it); w.write("\n") } }
|
||||
}
|
||||
|
||||
private fun installed(): List<String> {
|
||||
File(root, DesktopPack.INFO).apply { parentFile?.mkdirs() }
|
||||
.writeText("""{"tag":"ubuntu-r1-desktop","url":"https://example.invalid/d.tar.zst","sha256":"00","size":5}""")
|
||||
file("usr/bin/runtime-tool", "runtime")
|
||||
file("${DesktopPack.META}/originals/var/lib/dpkg/status", "Package: bash\n")
|
||||
file("${DesktopPack.META}/originals/etc/gone.conf", "removed by the desktop")
|
||||
file("${DesktopPack.META}/originals/etc/group", "root:x:0:")
|
||||
file("${DesktopPack.META}/originals/etc/hosts", "runtime hosts")
|
||||
file("etc/group", "root:x:0:\nsddm:x:120:")
|
||||
file("etc/hosts", "desktop hosts")
|
||||
file("var/lib/dpkg/status", "Package: bash\n\nPackage: kwin\n")
|
||||
file("usr/bin/kwin_wayland", "kwin")
|
||||
file("usr/share/kwin/effect.qml", "effect")
|
||||
file("usr/share/kwin/edited.qml", "original")
|
||||
Files.createSymbolicLink(File(root, "usr/bin/kwin").toPath(), File("kwin_wayland").toPath())
|
||||
val lines = listOf(
|
||||
line('N', "usr/share/kwin"), line('N', "usr/bin/kwin_wayland"), line('N', "usr/share/kwin/effect.qml"),
|
||||
line('N', "usr/share/kwin/edited.qml"), line('N', "usr/bin/kwin"), line('C', "var/lib/dpkg/status"), line('C', "etc/group"), line('C', "etc/hosts"),
|
||||
"R\tF\t22\tx\tetc/gone.conf", "N\tF\t1\tx\t../escape",
|
||||
)
|
||||
file("usr/share/kwin/edited.qml", "changed by the user")
|
||||
file("etc/hosts", "edited by the user")
|
||||
file("var/lib/dpkg/status", "Package: bash\n\nPackage: kwin\n\nPackage: vlc\n")
|
||||
return lines
|
||||
}
|
||||
|
||||
@Test fun readsThePackTheRuntimeNames() {
|
||||
installed()
|
||||
val info = DesktopPack.info(root)!!
|
||||
assertEquals("ubuntu-r1-desktop", info.tag)
|
||||
assertEquals(5L, info.size)
|
||||
}
|
||||
|
||||
@Test fun removingPutsTheRuntimeBackAndKeepsWhatTheUserChanged() {
|
||||
manifest(installed())
|
||||
val result = DesktopPack.remove(root)
|
||||
assertEquals("Package: bash\n", File(root, "var/lib/dpkg/status").readText())
|
||||
assertEquals("removed by the desktop", File(root, "etc/gone.conf").readText())
|
||||
assertEquals("root:x:0:", File(root, "etc/group").readText())
|
||||
assertEquals("edited by the user", File(root, "etc/hosts").readText())
|
||||
assertFalse(File(root, "usr/bin/kwin_wayland").exists())
|
||||
assertFalse(Files.exists(File(root, "usr/bin/kwin").toPath(), java.nio.file.LinkOption.NOFOLLOW_LINKS))
|
||||
assertFalse(File(root, "usr/share/kwin/effect.qml").exists())
|
||||
assertEquals("changed by the user", File(root, "usr/share/kwin/edited.qml").readText())
|
||||
assertTrue(File(root, "usr/share/kwin").isDirectory)
|
||||
assertEquals("runtime", File(root, "usr/bin/runtime-tool").readText())
|
||||
assertFalse(File(root, DesktopPack.META).exists())
|
||||
assertFalse(DesktopPack.installed(root))
|
||||
assertEquals(3, result.removed)
|
||||
assertEquals(3, result.restored)
|
||||
assertEquals(3, result.kept)
|
||||
}
|
||||
|
||||
@Test fun emptiedDirectoriesGoAway() {
|
||||
val lines = installed()
|
||||
File(root, "usr/share/kwin/edited.qml").delete()
|
||||
manifest(lines)
|
||||
DesktopPack.remove(root)
|
||||
assertFalse(File(root, "usr/share/kwin").exists())
|
||||
assertTrue(File(root, "usr/share").isDirectory)
|
||||
}
|
||||
|
||||
@Test fun finishingAnInstallDeletesWhatTheDesktopRemoved() {
|
||||
file("etc/gone.conf", "runtime copy")
|
||||
manifest(listOf("R\tF\t22\tx\tetc/gone.conf", "R\tF\t1\tx\t../outside"))
|
||||
File(root.parentFile, "outside").writeText("keep")
|
||||
DesktopPack.finishInstall(root)
|
||||
assertFalse(File(root, "etc/gone.conf").exists())
|
||||
assertTrue(File(root.parentFile, "outside").exists())
|
||||
File(root.parentFile, "outside").delete()
|
||||
}
|
||||
|
||||
@Test fun theDesktopKeepsPackagesTheUserInstalledBeforeIt() {
|
||||
val bash = "Package: bash\nArchitecture: arm64\nVersion: 5.2"
|
||||
val vim = "Package: vim\nArchitecture: arm64\nVersion: 9"
|
||||
val kwin = "Package: kwin\nArchitecture: arm64\nVersion: 6.6"
|
||||
file("var/lib/dpkg/status", "$bash\n\n$vim\n\n")
|
||||
DesktopPack.prepareInstall(root)
|
||||
file("${DesktopPack.META}/originals/var/lib/dpkg/status", "$bash\n\n")
|
||||
file("var/lib/dpkg/status", "$bash\n\n$kwin\n\n")
|
||||
manifest(listOf(line('C', "var/lib/dpkg/status")))
|
||||
DesktopPack.finishInstall(root)
|
||||
assertEquals("$bash\n\n$kwin\n\n$vim\n\n", File(root, "var/lib/dpkg/status").readText())
|
||||
assertFalse(File(root, "var/lib/dpkg/status.droiddeck").exists())
|
||||
|
||||
val vlc = "Package: vlc\nArchitecture: arm64\nVersion: 3"
|
||||
file("var/lib/dpkg/status", "$bash\n\n$kwin\n\n$vim\n\n$vlc\n\n")
|
||||
DesktopPack.remove(root)
|
||||
assertEquals("$bash\n\n$vim\n\n$vlc\n\n", File(root, "var/lib/dpkg/status").readText())
|
||||
}
|
||||
|
||||
@Test fun mergingKeepsTheTargetWhenBothSidesChangedAPackage() {
|
||||
val base = "Package: a\nVersion: 1\n\nPackage: b\nVersion: 1\n\nPackage: c\nVersion: 1\n"
|
||||
val target = "Package: a\nVersion: 2\n\nPackage: b\nVersion: 1\n\nPackage: c\nVersion: 1\n"
|
||||
val mine = "Package: a\nVersion: 3\n\nPackage: b\nVersion: 3\n"
|
||||
assertEquals("Package: a\nVersion: 2\n\nPackage: b\nVersion: 3\n\n", DesktopPack.mergeStatus(base, target, mine))
|
||||
}
|
||||
|
||||
@Test fun pathsMayNotLeaveTheRuntime() {
|
||||
assertNull(DesktopPack.inside(root, "../x"))
|
||||
assertNull(DesktopPack.inside(root, "/etc/passwd"))
|
||||
Files.createSymbolicLink(File(root, "link").toPath(), root.parentFile.toPath())
|
||||
assertNull(DesktopPack.inside(root, "link/x"))
|
||||
assertEquals(File(root, "usr/x"), DesktopPack.inside(root, "usr/./x"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class L2sLinkTest {
|
||||
private val dir = Files.createTempDirectory("l2s").toFile()
|
||||
|
||||
@After fun tearDown() { FileUtils.delete(dir) }
|
||||
|
||||
@Test fun aHardLinkBecomesProotsLinkLayout() {
|
||||
val bin = File(dir, "usr/bin").apply { mkdirs() }
|
||||
val coreutils = File(bin, "coreutils").apply { writeText("multicall") }
|
||||
val tail = File(bin, "tail")
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(coreutils, tail))
|
||||
val intermediate = File(bin, ".l2s.coreutils0001")
|
||||
assertEquals(intermediate.toPath(), Files.readSymbolicLink(coreutils.toPath()))
|
||||
assertEquals(intermediate.toPath(), Files.readSymbolicLink(tail.toPath()))
|
||||
assertEquals(File(bin, ".l2s.coreutils0001.0002").toPath(), Files.readSymbolicLink(intermediate.toPath()))
|
||||
assertEquals("multicall", tail.readText())
|
||||
assertEquals("multicall", coreutils.readText())
|
||||
}
|
||||
|
||||
@Test fun eachFurtherLinkRaisesTheCount() {
|
||||
val bin = File(dir, "usr/bin").apply { mkdirs() }
|
||||
val coreutils = File(bin, "coreutils").apply { writeText("multicall") }
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(coreutils, File(bin, "tail")))
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(coreutils, File(bin, "head")))
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(File(bin, "tail"), File(bin, "cat")))
|
||||
val final = File(bin, ".l2s.coreutils0001.0004")
|
||||
assertTrue(final.isFile)
|
||||
assertFalse(File(bin, ".l2s.coreutils0001.0002").exists())
|
||||
for (name in listOf("coreutils", "tail", "head", "cat")) assertEquals("multicall", File(bin, name).readText())
|
||||
}
|
||||
|
||||
@Test fun aSecondFileWithTheSameNameGetsItsOwnChain() {
|
||||
val a = File(dir, "a").apply { mkdirs() }
|
||||
val existing = File(a, ".l2s.tool0001").apply { writeText("taken") }
|
||||
val tool = File(a, "tool").apply { writeText("tool") }
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(tool, File(a, "alias")))
|
||||
assertEquals("taken", existing.readText())
|
||||
assertEquals(File(a, ".l2s.tool0002").toPath(), Files.readSymbolicLink(tool.toPath()))
|
||||
assertEquals("tool", File(a, "alias").readText())
|
||||
}
|
||||
|
||||
@Test fun linksMadeInStagingStillResolveAfterTheTreeIsRenamed() {
|
||||
val staging = File(dir, "linuxfs.new")
|
||||
val live = File(dir, "linuxfs")
|
||||
val bin = File(staging, "usr/bin").apply { mkdirs() }
|
||||
val cargo = File(staging, "usr/lib/cargo/bin/coreutils").apply { mkdirs() }
|
||||
val coreutils = File(bin, "coreutils").apply { writeText("multicall") }
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(coreutils, File(cargo, "echo"), staging, live))
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(File(cargo, "echo"), File(cargo, "cat"), staging, live))
|
||||
assertEquals(File(live, "usr/bin/.l2s.coreutils0001").toPath(), Files.readSymbolicLink(File(cargo, "echo").toPath()))
|
||||
assertTrue(File(staging, "usr/bin/.l2s.coreutils0001.0003").isFile)
|
||||
|
||||
assertTrue(staging.renameTo(live))
|
||||
|
||||
for (rel in listOf("usr/bin/coreutils", "usr/lib/cargo/bin/coreutils/echo", "usr/lib/cargo/bin/coreutils/cat"))
|
||||
assertEquals(rel, "multicall", File(live, rel).readText())
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(File(live, "usr/bin/coreutils"), File(live, "usr/bin/tail")))
|
||||
assertEquals("multicall", File(live, "usr/bin/tail").readText())
|
||||
assertTrue(File(live, "usr/bin/.l2s.coreutils0001.0004").isFile)
|
||||
}
|
||||
|
||||
@Test fun aHardLinkTargetMayAlreadyBeAnL2sLinkToTheFinalTree() {
|
||||
val staging = File(dir, "linuxfs.new")
|
||||
val live = File(dir, "linuxfs")
|
||||
val bin = File(staging, "usr/bin").apply { mkdirs() }
|
||||
File(bin, "coreutils").writeText("multicall")
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(File(bin, "coreutils"), File(bin, "["), staging, live))
|
||||
assertEquals(File(bin, "coreutils"), LinuxRuntimeInstaller.hardLinkTarget(staging, "./usr/bin/coreutils"))
|
||||
assertTrue(LinuxRuntimeInstaller.l2sLink(LinuxRuntimeInstaller.hardLinkTarget(staging, "./usr/bin/coreutils"), File(bin, "ls"), staging, live))
|
||||
assertTrue(staging.renameTo(live))
|
||||
assertEquals("multicall", File(live, "usr/bin/ls").readText())
|
||||
}
|
||||
|
||||
@Test fun aHardLinkTargetCannotLeaveTheTree() {
|
||||
val tree = File(dir, "tree").apply { mkdirs() }
|
||||
val outside = File(dir, "outside").apply { mkdirs() }
|
||||
Files.createSymbolicLink(File(tree, "escape").toPath(), outside.toPath())
|
||||
assertEquals(null, LinuxRuntimeInstaller.hardLinkTarget(tree, "../outside/x"))
|
||||
assertEquals(null, LinuxRuntimeInstaller.hardLinkTarget(tree, "escape/x"))
|
||||
assertEquals(null, LinuxRuntimeInstaller.hardLinkTarget(tree, ".."))
|
||||
assertEquals(File(tree, "x"), LinuxRuntimeInstaller.hardLinkTarget(tree, "./x"))
|
||||
}
|
||||
|
||||
@Test fun directoriesAndPlainSymlinksAreLeftAlone() {
|
||||
val d = File(dir, "d").apply { mkdirs() }
|
||||
assertFalse(LinuxRuntimeInstaller.l2sLink(d, File(dir, "e")))
|
||||
val target = File(dir, "t").apply { writeText("t") }
|
||||
val link = File(dir, "link")
|
||||
Files.createSymbolicLink(link.toPath(), target.toPath())
|
||||
assertFalse(LinuxRuntimeInstaller.l2sLink(link, File(dir, "other")))
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,47 @@ class RuntimeUserDataCarryTest {
|
||||
assertFalse("only DroidDeck's own menu entries are user data", File(staging, "usr/local/share/applications/other.desktop").exists())
|
||||
}
|
||||
|
||||
@Test fun aMenuEntryTheNewRuntimeShipsIsNotCarried() {
|
||||
val old = tmp.newFolder("old").also {
|
||||
put(it, "root/save.dat", "mine")
|
||||
put(it, "usr/share/applications/droiddeck-return-gaming.desktop", "old runtime")
|
||||
put(it, "usr/share/applications/droiddeck-steam-x64.desktop", "made by the old desktop")
|
||||
}
|
||||
val staging = tmp.newFolder("new").also {
|
||||
put(it, "root/.bashrc", "shipped")
|
||||
put(it, "usr/share/applications/droiddeck-return-gaming.desktop", "new runtime")
|
||||
}
|
||||
|
||||
val paths = RuntimeFileTree.existingUserPaths(old, staging)
|
||||
|
||||
assertTrue("root" in paths)
|
||||
assertTrue("usr/share/applications/droiddeck-steam-x64.desktop" in paths)
|
||||
assertFalse("usr/share/applications/droiddeck-return-gaming.desktop" in paths)
|
||||
RuntimeFileTree.carryUserData(old, staging, false, paths)
|
||||
assertEquals("new runtime", File(staging, "usr/share/applications/droiddeck-return-gaming.desktop").readText())
|
||||
}
|
||||
|
||||
@Test fun cachesTiedToThePreviousRuntimeAreDropped() {
|
||||
val root = tmp.newFolder("rt")
|
||||
val keep = listOf("root/.cache/mozilla/cache2/entry", "root/.cache/droiddeck/session.log",
|
||||
"root/.local/share/droiddeck/apt/packages.txt", "root/.local/share/Steam/steam.sh", "root/.config/kwinrc")
|
||||
val drop = listOf("root/.local/share/droiddeck/pacman/packages.txt", "root/.cache/droiddeck/pacman-restore.log",
|
||||
"root/.cache/mesa_shader_cache_db/index", "root/.cache/mesa_shader_cache/a/b", "root/.cache/appstream/x.xb",
|
||||
"root/.cache/discover/c", "root/.cache/ksycoca6_en-POSIX_abc", "root/.cache/plasma_theme_Vapor.kcache",
|
||||
"root/.cache/kwinsession.kcache", "root/.cache/qtshadercache-arm64-little_endian-lp64/s",
|
||||
"root/.cache/event-sound-cache.tdb.1.aarch64-unknown-linux-gnu", "root/.cache/fontconfig/x.cache-9")
|
||||
(keep + drop).forEach { put(root, it) }
|
||||
|
||||
RuntimeFileTree.dropStaleState(root)
|
||||
|
||||
keep.forEach { assertTrue(it, File(root, it).exists()) }
|
||||
drop.forEach { assertFalse(it, File(root, it).exists()) }
|
||||
}
|
||||
|
||||
@Test fun droppingStateWithoutAHomeDoesNothing() {
|
||||
RuntimeFileTree.dropStaleState(tmp.newFolder("empty"))
|
||||
}
|
||||
|
||||
@Test fun aFailureHalfwayPutsEverythingBack() {
|
||||
val old = userTree()
|
||||
val staging = tmp.newFolder("new")
|
||||
|
||||
Reference in new issue
Block a user