From 9d66a17a1bc9456d503c968c8009fcdc83a3a87d Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 28 Jul 2023 14:31:59 +0200 Subject: [PATCH 1/4] [Skip-CI] Add Development and mirrors section --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index d6dcf35..03c0cb9 100644 --- a/README.md +++ b/README.md @@ -144,3 +144,11 @@ Or to get help for subcommands e.g. provs-desktop.jar ide -h provs-server.jar k3s -h ``` +## Development & mirrors +Development happens at: https://repo.prod.meissa.de/meissa/provs + +Mirrors are: +* https://gitlab.com/domaindrivenarchitecture/provs (CI issues and PR) +* https://github.com/DomainDrivenArchitecture/provs + +For more details about our repository model see: https://repo.prod.meissa.de/meissa/federate-your-repos From 32840cdd46c8409ed75c3e58e6ee6d19531fe542 Mon Sep 17 00:00:00 2001 From: ansgarz Date: Sun, 30 Jul 2023 10:21:12 +0200 Subject: [PATCH 2/4] rename isntallFirefox to installPpaFirefox --- .../provs/desktop/domain/DesktopService.kt | 8 ++++---- .../provs/desktop/infrastructure/Firefox.kt | 2 +- .../provs/desktop/infrastructure/FirefoxKtTest.kt | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt index 1080535..778e341 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt @@ -86,7 +86,7 @@ fun Prov.provisionIdeDesktop(onlyModules: List? = null) { } else if (onlyModules.contains(DesktopOnlyModule.VERIFY.name.lowercase())) { verifyIdeSetup() } else if (onlyModules.contains(DesktopOnlyModule.FIREFOX.name.lowercase())) { - installFirefox() + installPpaFirefox() } } @@ -109,7 +109,7 @@ fun Prov.provisionOfficeDesktop(onlyModules: List? = null) { } else if (onlyModules.contains(DesktopOnlyModule.VERIFY.name.lowercase())) { verifyOfficeSetup() } else if (onlyModules.contains(DesktopOnlyModule.FIREFOX.name.lowercase())) { - installFirefox() + installPpaFirefox() } } @@ -140,7 +140,7 @@ fun Prov.provisionBasicDesktop( provisionKeys(gpg, ssh) provisionGit(gitUserName ?: whoami(), gitEmail, gpg?.let { gpgFingerprint(it.publicKey.plain()) }) - installFirefox() + installPpaFirefox() installGopass() configureGopass(publicGpgKey = gpg?.publicKey) installGopassJsonApi() @@ -153,6 +153,6 @@ fun Prov.provisionBasicDesktop( configureBash() installVirtualBoxGuestAdditions() } else if (onlyModules.contains(DesktopOnlyModule.FIREFOX.name.lowercase())) { - installFirefox() + installPpaFirefox() } } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt index 6ce584a..7056fe5 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt @@ -9,7 +9,7 @@ import java.io.File /** * Installs non-snap firefox, removing a firefox snap-installation if existing */ -fun Prov.installFirefox() = task { +fun Prov.installPpaFirefox() = task { // inspired by: https://www.omgubuntu.co.uk/2022/04/how-to-install-firefox-deb-apt-ubuntu-22-04 diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt index 666782f..8a30473 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt @@ -17,7 +17,7 @@ internal class FirefoxKtTest { fun installFirefox() { // when val result = defaultTestContainer().session { - installFirefox() + installPpaFirefox() checkPackageInstalled("firefox") } @@ -39,7 +39,7 @@ internal class FirefoxKtTest { /* remove for ssh authentication */ PromptSecretSource("Remote password for user $user").secret() ).session { - installFirefox() + installPpaFirefox() firefoxVersion = cmd("apt list firefox --installed").out ?: "" checkPackageInstalled("firefox") } From e8fcdae778c6ee53609291b53e585e2258453822 Mon Sep 17 00:00:00 2001 From: ansgarz Date: Sun, 30 Jul 2023 19:45:35 +0200 Subject: [PATCH 3/4] improve installPpaFirefox to set priority for ppa above default (snap) installation and allow unattended upgrades --- .../provs/desktop/infrastructure/Firefox.kt | 65 +++++++++++-------- .../desktop/infrastructure/FirefoxKtTest.kt | 38 +++++++++-- 2 files changed, 71 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt index 7056fe5..c785b7c 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt @@ -1,42 +1,53 @@ package org.domaindrivenarchitecture.provs.desktop.infrastructure import org.domaindrivenarchitecture.provs.framework.core.Prov -import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.addTextToFile -import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall -import java.io.File +import org.domaindrivenarchitecture.provs.framework.core.ProvResult +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.checkFile +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createFile +import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstallFromPpa /** - * Installs non-snap firefox, removing a firefox snap-installation if existing + * Installs ppa firefox (i.e. non-snap), removing snap-firefox if existing. */ -fun Prov.installPpaFirefox() = task { +fun Prov.installPpaFirefox() = taskWithResult { - // inspired by: https://www.omgubuntu.co.uk/2022/04/how-to-install-firefox-deb-apt-ubuntu-22-04 + // inspired by: https://wiki.ubuntuusers.de/Firefox/Installation/PPA/ - task("remove snap firefox") { - if (chk("snap list | grep firefox")) { - cmd("snap remove firefox", sudo = true) - } + val unattendeUpgradesForPpaFirefox = "/etc/apt/apt.conf.d/51unattended-upgrades-firefox" + + val preCondition = checkFile(unattendeUpgradesForPpaFirefox) + if (preCondition) { + return@taskWithResult ProvResult(true, out = "Firefox already installed with ppa") } - aptInstall("software-properties-common") - cmd("add-apt-repository -y ppa:mozillateam/ppa", sudo = true) + cmd("sudo apt-get -qy remove firefox", sudo = true) + optional { + cmd("snap remove firefox", sudo = true) + } - // set prio in order to use ppa-firefox above snap - addTextToFile( - "\nPackage: *\n" + - "Pin: release o=LP-PPA-mozillateam\n" + - "Pin-Priority: 1001\n", - File("/etc/apt/preferences.d/mozilla-firefox"), + createFile("/etc/apt/preferences.d/mozillateam", mozillaTeamFileContent, sudo = true) + + aptInstallFromPpa("mozillateam", "ppa", "firefox") + + createFile( + unattendeUpgradesForPpaFirefox, + "Unattended-Upgrade::Allowed-Origins:: \"LP-PPA-mozillateam:\${distro_codename}\";\n", sudo = true ) - - addTextToFile( - """Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${'$'}{distro_codename}";""", - File("/etc/apt/preferences.d/mozilla-firefox"), - sudo = true - ) - - aptInstall("firefox") - cmd("apt-get upgrade -y --allow-downgrades firefox", sudo = true) } + + +private val mozillaTeamFileContent = """ + Package: * + Pin: release o=LP-PPA-mozillateam + Pin-Priority: 100 + + Package: firefox* + Pin: release o=LP-PPA-mozillateam + Pin-Priority: 1001 + + Package: firefox* + Pin: release o=Ubuntu + Pin-Priority: -1 +""".trimIndent() \ No newline at end of file diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt index 8a30473..88b7290 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/FirefoxKtTest.kt @@ -1,32 +1,60 @@ package org.domaindrivenarchitecture.provs.desktop.infrastructure import org.domaindrivenarchitecture.provs.framework.core.remote +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.deleteFile +import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileContainsText import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.checkPackageInstalled +import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.isPackageInstalled import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.secretSources.PromptSecretSource import org.domaindrivenarchitecture.provs.test.defaultTestContainer import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test internal class FirefoxKtTest { - // Attention: this test does not test full functionality of installFirefox, e.g. does not test - // remove snap, as this test runs against a container which does not have snap-firefox installed + // Attention: this test does not test full functionality of installPpaFirefox, e.g. does not test + // remove snap-firefox, as this test runs against a container, which does have neither snap nor snap-firefox installed @ExtensiveContainerTest fun installFirefox() { + // given + val prov = defaultTestContainer() + // when - val result = defaultTestContainer().session { + val result = prov.session { + deleteFile("/etc/apt/apt.conf.d/51unattended-upgrades-firefox", sudo = true) + deleteFile("/etc/apt/preferences.d/mozillateam", sudo = true) installPpaFirefox() - checkPackageInstalled("firefox") } + val result2 = prov.installPpaFirefox() // then assertTrue(result.success) + assertEquals("Firefox already installed with ppa", result2.out) + + assertTrue(prov.isPackageInstalled("firefox")) + assertTrue( + prov.fileContainsText( + "/etc/apt/apt.conf.d/51unattended-upgrades-firefox", + "Unattended-Upgrade::Allowed-Origins:: \"LP-PPA-mozillateam:\${distro_codename}\";\n", + sudo = true + ) + ) + val expectedPolicyLine = Regex("1001? https?://ppa.launchpad(?:content)?.net/mozillateam/ppa/ubuntu") + val policy = prov.cmd("apt policy firefox").out + assertTrue( + policy?.contains(expectedPolicyLine) ?: false, + "$expectedPolicyLine was not found in $policy" + ) } + /** + * Tests installing firefox on a remote machine, e.g. a virtual machine + */ @Test - @Disabled("Update connection details,then enable and run manually") + @Disabled("Update connection details, then enable the test and run manually") fun installFirefox_remotely() { val host = "192.168.56.123" val user = "user" From c1ceff0f94cc9e8fe89d820f19395907eefb02f2 Mon Sep 17 00:00:00 2001 From: Michael Jerger Date: Tue, 1 Aug 2023 09:03:38 +0200 Subject: [PATCH 4/4] we can handle also thunderbird this way --- .../provs/desktop/infrastructure/Firefox.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt index c785b7c..86d7a06 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/Firefox.kt @@ -50,4 +50,12 @@ private val mozillaTeamFileContent = """ Package: firefox* Pin: release o=Ubuntu Pin-Priority: -1 + + Package: thunderbird* + Pin: release o=LP-PPA-mozillateam + Pin-Priority: 1001 + + Package: thunderbird* + Pin: release o=Ubuntu + Pin-Priority: -1 """.trimIndent() \ No newline at end of file