Use target_env calls in Python modules.

This commit is contained in:
Teo Mrnjavac 2015-08-06 12:13:21 +02:00
parent bf885d65db
commit 10ce42f35c
12 changed files with 75 additions and 75 deletions

View File

@ -28,7 +28,7 @@ import libcalamares
import os import os
import subprocess import subprocess
from libcalamares.utils import check_chroot_call from libcalamares.utils import check_target_env_call
def get_uuid(): def get_uuid():
@ -167,7 +167,7 @@ def install_grub(efi_directory, fw_type):
if fw_type == "efi": if fw_type == "efi":
print("Bootloader: grub (efi)") print("Bootloader: grub (efi)")
efi_directory_firmware = efi_directory + "/EFI" efi_directory_firmware = efi_directory + "/EFI"
check_chroot_call(["mkdir", "-p", "{!s}".format(efi_directory)]) check_target_env_call(["mkdir", "-p", "{!s}".format(efi_directory)])
if "efiBootloaderId" in libcalamares.job.configuration: if "efiBootloaderId" in libcalamares.job.configuration:
efi_bootloader_id = libcalamares.job.configuration["efiBootloaderId"] efi_bootloader_id = libcalamares.job.configuration["efiBootloaderId"]
@ -176,21 +176,21 @@ def install_grub(efi_directory, fw_type):
distribution = branding["bootloaderEntryName"] distribution = branding["bootloaderEntryName"]
file_name_sanitizer = str.maketrans(" /", "_-") file_name_sanitizer = str.maketrans(" /", "_-")
efi_bootloader_id = distribution.translate(file_name_sanitizer) efi_bootloader_id = distribution.translate(file_name_sanitizer)
check_chroot_call([libcalamares.job.configuration["grubInstall"], "--target=x86_64-efi", check_target_env_call([libcalamares.job.configuration["grubInstall"], "--target=x86_64-efi",
"--efi-directory={!s}".format(efi_directory), "--efi-directory={!s}".format(efi_directory),
"--bootloader-id={!s}".format(efi_bootloader_id), "--bootloader-id={!s}".format(efi_bootloader_id),
"--force"]) "--force"])
# Workaround for some UEFI firmwares # Workaround for some UEFI firmwares
check_chroot_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)]) check_target_env_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)])
check_chroot_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware, efi_bootloader_id), check_target_env_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware, efi_bootloader_id),
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)]) "{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
else: else:
print("Bootloader: grub (bios)") print("Bootloader: grub (bios)")
boot_loader = libcalamares.globalstorage.value("bootLoader") boot_loader = libcalamares.globalstorage.value("bootLoader")
check_chroot_call([libcalamares.job.configuration["grubInstall"], "--target=i386-pc", check_target_env_call([libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
"--recheck", "--force", boot_loader["installPath"]]) "--recheck", "--force", boot_loader["installPath"]])
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o", check_target_env_call([libcalamares.job.configuration["grubMkconfig"], "-o",
libcalamares.job.configuration["grubCfg"]]) libcalamares.job.configuration["grubCfg"]])

View File

@ -254,7 +254,7 @@ def set_autologin(username, displaymanagers, default_desktop_environment, root_m
if os.path.isfile(sddm_conf_path): if os.path.isfile(sddm_conf_path):
libcalamares.utils.debug('SDDM config file exists') libcalamares.utils.debug('SDDM config file exists')
else: else:
libcalamares.utils.check_chroot_call(["sh", "-c", "sddm --example-config > /etc/sddm.conf"]) libcalamares.utils.check_target_env_call(["sh", "-c", "sddm --example-config > /etc/sddm.conf"])
text = [] text = []
@ -332,19 +332,19 @@ def run():
if "lightdm" in displaymanagers: if "lightdm" in displaymanagers:
if have_dm("lightdm", root_mount_point): if have_dm("lightdm", root_mount_point):
if enable_basic_setup: if enable_basic_setup:
libcalamares.utils.chroot_call(['mkdir', '-p', '/run/lightdm']) libcalamares.utils.target_env_call(['mkdir', '-p', '/run/lightdm'])
if libcalamares.utils.chroot_call(['getent', 'group', 'lightdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'group', 'lightdm']) != 0:
libcalamares.utils.chroot_call(['groupadd', '-g', '620', 'lightdm']) libcalamares.utils.target_env_call(['groupadd', '-g', '620', 'lightdm'])
if libcalamares.utils.chroot_call(['getent', 'passwd', 'lightdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'passwd', 'lightdm']) != 0:
libcalamares.utils.chroot_call(['useradd', '-c', '"LightDM Display Manager"', libcalamares.utils.target_env_call(['useradd', '-c', '"LightDM Display Manager"',
'-u', '620', '-g', 'lightdm', '-d', '/var/run/lightdm', '-u', '620', '-g', 'lightdm', '-d', '/var/run/lightdm',
'-s', '/usr/bin/nologin', 'lightdm']) '-s', '/usr/bin/nologin', 'lightdm'])
libcalamares.utils.chroot_call(['passwd', '-l', 'lightdm']) libcalamares.utils.target_env_call(['passwd', '-l', 'lightdm'])
libcalamares.utils.chroot_call(['chown', '-R', 'lightdm:lightdm', '/run/lightdm']) libcalamares.utils.target_env_call(['chown', '-R', 'lightdm:lightdm', '/run/lightdm'])
libcalamares.utils.chroot_call(['chmod', '+r' '/etc/lightdm/lightdm.conf']) libcalamares.utils.target_env_call(['chmod', '+r' '/etc/lightdm/lightdm.conf'])
if default_desktop_environment is not None: if default_desktop_environment is not None:
os.system("sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format( os.system("sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(
@ -357,16 +357,16 @@ def run():
if "gdm" in displaymanagers: if "gdm" in displaymanagers:
if have_dm("gdm", root_mount_point): if have_dm("gdm", root_mount_point):
if enable_basic_setup: if enable_basic_setup:
if libcalamares.utils.chroot_call(['getent', 'group', 'gdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'group', 'gdm']) != 0:
libcalamares.utils.chroot_call(['groupadd', '-g', '120', 'gdm']) libcalamares.utils.target_env_call(['groupadd', '-g', '120', 'gdm'])
if libcalamares.utils.chroot_call(['getent', 'passwd', 'gdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'passwd', 'gdm']) != 0:
libcalamares.utils.chroot_call(['useradd', '-c', '"Gnome Display Manager"', libcalamares.utils.target_env_call(['useradd', '-c', '"Gnome Display Manager"',
'-u', '120', '-g', 'gdm', '-d', '/var/lib/gdm', '-u', '120', '-g', 'gdm', '-d', '/var/lib/gdm',
'-s', '/usr/bin/nologin', 'gdm']) '-s', '/usr/bin/nologin', 'gdm'])
libcalamares.utils.chroot_call(['passwd', '-l', 'gdm']) libcalamares.utils.target_env_call(['passwd', '-l', 'gdm'])
libcalamares.utils.chroot_call(['chown', '-R', 'gdm:gdm', '/var/lib/gdm']) libcalamares.utils.target_env_call(['chown', '-R', 'gdm:gdm', '/var/lib/gdm'])
else: else:
libcalamares.utils.debug("gdm selected but not installed") libcalamares.utils.debug("gdm selected but not installed")
displaymanagers.remove("gdm") displaymanagers.remove("gdm")
@ -375,17 +375,17 @@ def run():
if "mdm" in displaymanagers: if "mdm" in displaymanagers:
if have_dm("mdm", root_mount_point): if have_dm("mdm", root_mount_point):
if enable_basic_setup: if enable_basic_setup:
if libcalamares.utils.chroot_call(['getent', 'group', 'mdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'group', 'mdm']) != 0:
libcalamares.utils.chroot_call(['groupadd', '-g', '128', 'mdm']) libcalamares.utils.target_env_call(['groupadd', '-g', '128', 'mdm'])
if libcalamares.utils.chroot_call(['getent', 'passwd', 'mdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'passwd', 'mdm']) != 0:
libcalamares.utils.chroot_call(['useradd', '-c', '"Linux Mint Display Manager"', libcalamares.utils.target_env_call(['useradd', '-c', '"Linux Mint Display Manager"',
'-u', '128', '-g', 'mdm', '-d', '/var/lib/mdm', '-u', '128', '-g', 'mdm', '-d', '/var/lib/mdm',
'-s', '/usr/bin/nologin', 'mdm']) '-s', '/usr/bin/nologin', 'mdm'])
libcalamares.utils.chroot_call(['passwd', '-l', 'mdm']) libcalamares.utils.target_env_call(['passwd', '-l', 'mdm'])
libcalamares.utils.chroot_call(['chown', 'root:mdm', '/var/lib/mdm']) libcalamares.utils.target_env_call(['chown', 'root:mdm', '/var/lib/mdm'])
libcalamares.utils.chroot_call(['chmod', '1770', '/var/lib/mdm']) libcalamares.utils.target_env_call(['chmod', '1770', '/var/lib/mdm'])
if default_desktop_environment is not None: if default_desktop_environment is not None:
os.system("sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format( os.system("sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(
@ -398,12 +398,12 @@ def run():
if "lxdm" in displaymanagers: if "lxdm" in displaymanagers:
if have_dm("lxdm", root_mount_point): if have_dm("lxdm", root_mount_point):
if enable_basic_setup: if enable_basic_setup:
if libcalamares.utils.chroot_call(['getent', 'group', 'lxdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'group', 'lxdm']) != 0:
libcalamares.utils.chroot_call(['groupadd', '--system', 'lxdm']) libcalamares.utils.target_env_call(['groupadd', '--system', 'lxdm'])
libcalamares.utils.chroot_call(['chgrp', '-R', 'lxdm', '/var/lib/lxdm']) libcalamares.utils.target_env_call(['chgrp', '-R', 'lxdm', '/var/lib/lxdm'])
libcalamares.utils.chroot_call(['chgrp', 'lxdm', '/etc/lxdm/lxdm.conf']) libcalamares.utils.target_env_call(['chgrp', 'lxdm', '/etc/lxdm/lxdm.conf'])
libcalamares.utils.chroot_call(['chmod', '+r', '/etc/lxdm/lxdm.conf']) libcalamares.utils.target_env_call(['chmod', '+r', '/etc/lxdm/lxdm.conf'])
if default_desktop_environment is not None: if default_desktop_environment is not None:
os.system("sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format( os.system("sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(
@ -416,14 +416,14 @@ def run():
if "kdm" in displaymanagers: if "kdm" in displaymanagers:
if have_dm("kdm", root_mount_point): if have_dm("kdm", root_mount_point):
if enable_basic_setup: if enable_basic_setup:
if libcalamares.utils.chroot_call(['getent', 'group', 'kdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'group', 'kdm']) != 0:
libcalamares.utils.chroot_call(['groupadd', '-g', '135', 'kdm']) libcalamares.utils.target_env_call(['groupadd', '-g', '135', 'kdm'])
if libcalamares.utils.chroot_call(['getent', 'passwd', 'kdm']) != 0: if libcalamares.utils.target_env_call(['getent', 'passwd', 'kdm']) != 0:
libcalamares.utils.chroot_call(['useradd', '-u', '135', '-g', 'kdm', '-d', libcalamares.utils.target_env_call(['useradd', '-u', '135', '-g', 'kdm', '-d',
'/var/lib/kdm', '-s', '/bin/false', '-r', '-M', 'kdm']) '/var/lib/kdm', '-s', '/bin/false', '-r', '-M', 'kdm'])
libcalamares.utils.chroot_call(['chown', '-R', '135:135', 'var/lib/kdm']) libcalamares.utils.target_env_call(['chown', '-R', '135:135', 'var/lib/kdm'])
else: else:
libcalamares.utils.debug("kdm selected but not installed") libcalamares.utils.debug("kdm selected but not installed")
displaymanagers.remove("kdm") displaymanagers.remove("kdm")

View File

@ -20,7 +20,7 @@
# along with Calamares. If not, see <http://www.gnu.org/licenses/>. # along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import libcalamares import libcalamares
from libcalamares.utils import chroot_call from libcalamares.utils import target_env_call
def run_dracut(): def run_dracut():
@ -28,7 +28,7 @@ def run_dracut():
:return: :return:
""" """
return chroot_call(['dracut', '-f']) return target_env_call(['dracut', '-f'])
def run(): def run():

View File

@ -35,7 +35,7 @@ def modify_grub_default(partitions, root_mount_point, distributor):
default_dir = os.path.join(root_mount_point, "etc/default") default_dir = os.path.join(root_mount_point, "etc/default")
default_grub = os.path.join(default_dir, "grub") default_grub = os.path.join(default_dir, "grub")
distributor_replace = distributor.replace("'", "'\\''") distributor_replace = distributor.replace("'", "'\\''")
plymouth_bin = libcalamares.utils.chroot_call(["sh", "-c", "which plymouth"]) plymouth_bin = libcalamares.utils.target_env_call(["sh", "-c", "which plymouth"])
use_splash = "" use_splash = ""
swap_uuid = "" swap_uuid = ""

View File

@ -19,13 +19,13 @@
# along with Calamares. If not, see <http://www.gnu.org/licenses/>. # along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import libcalamares import libcalamares
from libcalamares.utils import check_chroot_call from libcalamares.utils import check_target_env_call
def run_mkinitcpio(): def run_mkinitcpio():
""" Runs mkinitcpio with given kernel profile """ """ Runs mkinitcpio with given kernel profile """
kernel = libcalamares.job.configuration['kernel'] kernel = libcalamares.job.configuration['kernel']
check_chroot_call(['mkinitcpio', '-p', kernel]) check_target_env_call(['mkinitcpio', '-p', kernel])
def run(): def run():

View File

@ -22,7 +22,7 @@
import libcalamares import libcalamares
import os import os
from collections import OrderedDict from collections import OrderedDict
from libcalamares.utils import check_chroot_call from libcalamares.utils import check_target_env_call
def cpuinfo(): def cpuinfo():

View File

@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>. # along with Calamares. If not, see <http://www.gnu.org/licenses/>.
from libcalamares.utils import chroot_call from libcalamares.utils import target_env_call
def run(): def run():
@ -26,7 +26,7 @@ def run():
:return: :return:
""" """
return_code = chroot_call(["update-initramfs", "-k", "all", "-u"]) return_code = target_env_call(["update-initramfs", "-k", "all", "-u"])
if return_code != 0: if return_code != 0:
return "Failed to run update-initramfs on the target", "The exit code was {}".format(return_code) return "Failed to run update-initramfs on the target", "The exit code was {}".format(return_code)

View File

@ -60,7 +60,7 @@ def run():
gen.write(line) gen.write(line)
libcalamares.utils.chroot_call(['locale-gen']) libcalamares.utils.target_env_call(['locale-gen'])
print('locale.gen done') print('locale.gen done')
locale_conf_path = os.path.join(install_path, "etc/locale.conf") locale_conf_path = os.path.join(install_path, "etc/locale.conf")

View File

@ -20,7 +20,7 @@
import libcalamares import libcalamares
import os import os
from libcalamares.utils import check_chroot_call from libcalamares.utils import check_target_env_call
def run(): def run():
@ -38,7 +38,7 @@ def run():
if os.path.exists(target_systemd_machineid_file): if os.path.exists(target_systemd_machineid_file):
os.remove(target_systemd_machineid_file) os.remove(target_systemd_machineid_file)
check_chroot_call("systemd-machine-id-setup") check_target_env_call("systemd-machine-id-setup")
if enable_dbus: if enable_dbus:
target_dbus_machineid_file = "{}/var/lib/dbus/machine-id".format(root_mount_point) target_dbus_machineid_file = "{}/var/lib/dbus/machine-id".format(root_mount_point)
@ -47,8 +47,8 @@ def run():
os.remove(target_dbus_machineid_file) os.remove(target_dbus_machineid_file)
if enable_symlink and os.path.exists(target_systemd_machineid_file): if enable_symlink and os.path.exists(target_systemd_machineid_file):
check_chroot_call(["ln", "-s", "/etc/machine-id", "/var/lib/dbus/machine-id"]) check_target_env_call(["ln", "-s", "/etc/machine-id", "/var/lib/dbus/machine-id"])
else: else:
check_chroot_call(["dbus-uuidgen", "--ensure"]) check_target_env_call(["dbus-uuidgen", "--ensure"])
return None return None

View File

@ -19,7 +19,7 @@
# along with Calamares. If not, see <http://www.gnu.org/licenses/>. # along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import libcalamares import libcalamares
from libcalamares.utils import check_chroot_call, chroot_call from libcalamares.utils import check_target_env_call, target_env_call
class PackageManager: class PackageManager:
@ -38,30 +38,30 @@ class PackageManager:
""" """
if self.backend == "packagekit": if self.backend == "packagekit":
for pkg in pkgs: for pkg in pkgs:
check_chroot_call(["pkcon", "-py", "install", pkg]) check_target_env_call(["pkcon", "-py", "install", pkg])
elif self.backend == "zypp": elif self.backend == "zypp":
check_chroot_call(["zypper", "--non-interactive", "--quiet-install", "install", check_target_env_call(["zypper", "--non-interactive", "--quiet-install", "install",
"--auto-agree-with-licenses", "install"] + pkgs) "--auto-agree-with-licenses", "install"] + pkgs)
elif self.backend == "yum": elif self.backend == "yum":
check_chroot_call(["yum", "install", "-y"] + pkgs) check_target_env_call(["yum", "install", "-y"] + pkgs)
elif self.backend == "dnf": elif self.backend == "dnf":
check_chroot_call(["dnf", "install", "-y"] + pkgs) check_target_env_call(["dnf", "install", "-y"] + pkgs)
elif self.backend == "urpmi": elif self.backend == "urpmi":
check_chroot_call(["urpmi", "--download-all", "--no-suggests", "--no-verify-rpm", check_target_env_call(["urpmi", "--download-all", "--no-suggests", "--no-verify-rpm",
"--fastunsafe", "--ignoresize", "--nolock", "--auto"] + pkgs) "--fastunsafe", "--ignoresize", "--nolock", "--auto"] + pkgs)
elif self.backend == "apt": elif self.backend == "apt":
check_chroot_call(["apt-get", "-q", "-y", "install"] + pkgs) check_target_env_call(["apt-get", "-q", "-y", "install"] + pkgs)
elif self.backend == "pacman": elif self.backend == "pacman":
if from_local: if from_local:
pacman_flags = "-U" pacman_flags = "-U"
else: else:
pacman_flags = "-Sy" pacman_flags = "-Sy"
check_chroot_call(["pacman", pacman_flags, "--noconfirm"] + pkgs) check_target_env_call(["pacman", pacman_flags, "--noconfirm"] + pkgs)
elif self.backend == "portage": elif self.backend == "portage":
check_chroot_call(["emerge", "-v"] + pkgs) check_target_env_call(["emerge", "-v"] + pkgs)
elif self.backend == "entropy": elif self.backend == "entropy":
check_chroot_call(["equo", "i"] + pkgs) check_target_env_call(["equo", "i"] + pkgs)
def remove(self, pkgs): def remove(self, pkgs):
""" Removes packages. """ Removes packages.
@ -70,25 +70,25 @@ class PackageManager:
""" """
if self.backend == "packagekit": if self.backend == "packagekit":
for pkg in pkgs: for pkg in pkgs:
check_chroot_call(["pkcon", "-py", "remove", pkg]) check_target_env_call(["pkcon", "-py", "remove", pkg])
elif self.backend == "zypp": elif self.backend == "zypp":
check_chroot_call(["zypper", "--non-interactive", "remove"] + pkgs) check_target_env_call(["zypper", "--non-interactive", "remove"] + pkgs)
elif self.backend == "yum": elif self.backend == "yum":
check_chroot_call(["yum", "--disablerepo=*", "-C", "-y", "remove"] + pkgs) check_target_env_call(["yum", "--disablerepo=*", "-C", "-y", "remove"] + pkgs)
elif self.backend == "dnf": elif self.backend == "dnf":
# ignore the error code for now because dnf thinks removing a nonexistent package is an error # ignore the error code for now because dnf thinks removing a nonexistent package is an error
chroot_call(["dnf", "--disablerepo=*", "-C", "-y", "remove"] + pkgs) target_env_call(["dnf", "--disablerepo=*", "-C", "-y", "remove"] + pkgs)
elif self.backend == "urpmi": elif self.backend == "urpmi":
check_chroot_call(["urpme", "--auto"] + pkgs) check_target_env_call(["urpme", "--auto"] + pkgs)
elif self.backend == "apt": elif self.backend == "apt":
check_chroot_call(["apt-get", "--purge", "-q", "-y", "remove"] + pkgs) check_target_env_call(["apt-get", "--purge", "-q", "-y", "remove"] + pkgs)
check_chroot_call(["apt-get", "--purge", "-q", "-y", "autoremove"]) check_target_env_call(["apt-get", "--purge", "-q", "-y", "autoremove"])
elif self.backend == "pacman": elif self.backend == "pacman":
check_chroot_call(["pacman", "-Rs", "--noconfirm"] + pkgs) check_target_env_call(["pacman", "-Rs", "--noconfirm"] + pkgs)
elif self.backend == "portage": elif self.backend == "portage":
check_chroot_call(["emerge", "-C"] + pkgs) check_target_env_call(["emerge", "-C"] + pkgs)
elif self.backend == "entropy": elif self.backend == "entropy":
check_chroot_call(["equo", "rm"] + pkgs) check_target_env_call(["equo", "rm"] + pkgs)
def run_operations(pkgman, entry): def run_operations(pkgman, entry):

View File

@ -27,7 +27,7 @@ def run():
username = libcalamares.job.configuration["username"] username = libcalamares.job.configuration["username"]
try: try:
libcalamares.utils.check_chroot_call(["userdel", "-f", "-r", username]) libcalamares.utils.check_target_env_call(["userdel", "-f", "-r", username])
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
libcalamares.utils.debug("Cannot remove user.", "'userdel' terminated with exit code {}.".format(e.returncode)) libcalamares.utils.debug("Cannot remove user.", "'userdel' terminated with exit code {}.".format(e.returncode))

View File

@ -30,7 +30,7 @@ def run():
# enable services # enable services
for svc in services: for svc in services:
ec = libcalamares.utils.chroot_call(['systemctl', 'enable', '{}.service'.format(svc['name'])]) ec = libcalamares.utils.target_env_call(['systemctl', 'enable', '{}.service'.format(svc['name'])])
if ec != 0: if ec != 0:
if svc['mandatory']: if svc['mandatory']:
@ -42,7 +42,7 @@ def run():
# enable targets # enable targets
for tgt in targets: for tgt in targets:
ec = libcalamares.utils.chroot_call(['systemctl', 'enable', '{}.target'.format(tgt['name'])]) ec = libcalamares.utils.target_env_call(['systemctl', 'enable', '{}.target'.format(tgt['name'])])
if ec != 0: if ec != 0:
if tgt['mandatory']: if tgt['mandatory']: