Merge branch 'master' into refactor-git-trust
commit
4f79f933b5
@ -1,42 +1,61 @@
|
||||
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.installFirefox() = 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"),
|
||||
sudo = true
|
||||
)
|
||||
createFile("/etc/apt/preferences.d/mozillateam", mozillaTeamFileContent, sudo = true)
|
||||
|
||||
aptInstallFromPpa("mozillateam", "ppa", "firefox")
|
||||
|
||||
addTextToFile(
|
||||
"""Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${'$'}{distro_codename}";""",
|
||||
File("/etc/apt/preferences.d/mozilla-firefox"),
|
||||
createFile(
|
||||
unattendeUpgradesForPpaFirefox,
|
||||
"Unattended-Upgrade::Allowed-Origins:: \"LP-PPA-mozillateam:\${distro_codename}\";\n",
|
||||
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
|
||||
|
||||
Package: thunderbird*
|
||||
Pin: release o=LP-PPA-mozillateam
|
||||
Pin-Priority: 1001
|
||||
|
||||
Package: thunderbird*
|
||||
Pin: release o=Ubuntu
|
||||
Pin-Priority: -1
|
||||
""".trimIndent()
|
Loading…
Reference in New Issue