support fake steps

main
mirkobrombin 2 years ago
parent b2c404477a
commit d9e15e3edb

@ -1,13 +1,18 @@
import logging
from ubuntu_smoother.utils import checks from ubuntu_smoother.utils import checks
from ubuntu_smoother.utils.apt import Apt from ubuntu_smoother.utils.apt import Apt
from ubuntu_smoother.utils.flatpak import Flatpak from ubuntu_smoother.utils.flatpak import Flatpak
from ubuntu_smoother.utils.snap import Snap from ubuntu_smoother.utils.snap import Snap
logger = logging.getLogger("UbuntuSmoother::Configurator")
class Configurator: class Configurator:
def __init__(self, config: 'Config'): def __init__(self, config: 'Config', fake: bool = False):
self.config = config self.config = config
self.fake = fake
def apply(self): def apply(self):
self.__enable_snap() if self.config.snap else self.__disable_snap() self.__enable_snap() if self.config.snap else self.__disable_snap()
@ -15,6 +20,10 @@ class Configurator:
self.__enable_apport() if self.config.apport else self.__disable_apport() self.__enable_apport() if self.config.apport else self.__disable_apport()
def __enable_snap(self): def __enable_snap(self):
if self.fake:
logger.info("Fake: Snap enabled")
return
pkgs = [] pkgs = []
if not checks.is_snap_installed(): if not checks.is_snap_installed():
pkgs += ['snapd', 'gnome-software-plugin-snap'] pkgs += ['snapd', 'gnome-software-plugin-snap']
@ -25,15 +34,44 @@ class Configurator:
Snap.install(['snap-store']) Snap.install(['snap-store'])
def __disable_snap(self): def __disable_snap(self):
if self.fake:
logger.info("Fake: Snap disabled")
return
if checks.is_snap_installed(): if checks.is_snap_installed():
Apt.purge(['snapd']) Apt.purge(['snapd'])
def __enable_flatpak(self): def __enable_flatpak(self):
if self.fake:
logger.info("Fake: Flatpak enabled")
return
if not checks.is_flatpak_installed(): if not checks.is_flatpak_installed():
Apt.install(['flatpak']) Apt.install(['flatpak'])
Flatpak.add_repo("https://flathub.org/repo/flathub.flatpakrepo") Flatpak.add_repo("https://flathub.org/repo/flathub.flatpakrepo")
Apt.update() Apt.update()
def __disable_flatpak(self): def __disable_flatpak(self):
if self.fake:
logger.info("Fake: Flatpak disabled")
return
if checks.is_flatpak_installed(): if checks.is_flatpak_installed():
Apt.purge(['flatpak']) Apt.purge(['flatpak'])
def __enable_apport(self):
if self.fake:
logger.info("Fake: Apport enabled")
return
if not checks.is_apport_installed():
Apt.install(['apport'])
Apt.update()
def __disable_apport(self):
if self.fake:
logger.info("Fake: Apport disabled")
return
if checks.is_apport_installed():
Apt.purge(['apport'])

Loading…
Cancel
Save