[PEP 8] General Style Part 3
This commit is contained in:
parent
09dc6bb5d7
commit
5c1ee7bbcb
@ -50,6 +50,7 @@ def get_bootloader_entry_name():
|
|||||||
branding = libcalamares.globalstorage.value("branding")
|
branding = libcalamares.globalstorage.value("branding")
|
||||||
return branding["bootloaderEntryName"]
|
return branding["bootloaderEntryName"]
|
||||||
|
|
||||||
|
|
||||||
def create_conf(uuid, conf_path):
|
def create_conf(uuid, conf_path):
|
||||||
distribution = get_bootloader_entry_name()
|
distribution = get_bootloader_entry_name()
|
||||||
kernel = libcalamares.job.configuration["kernel"]
|
kernel = libcalamares.job.configuration["kernel"]
|
||||||
@ -128,9 +129,11 @@ def install_bootloader(boot_loader, fw_type):
|
|||||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||||
distribution_translated = distribution.translate(file_name_sanitizer)
|
distribution_translated = distribution.translate(file_name_sanitizer)
|
||||||
conf_path = os.path.join(
|
conf_path = os.path.join(
|
||||||
install_efi_directory, "loader", "entries", "{!s}.conf".format(distribution_translated))
|
install_efi_directory, "loader", "entries",
|
||||||
|
"{!s}.conf".format(distribution_translated))
|
||||||
fallback_path = os.path.join(
|
fallback_path = os.path.join(
|
||||||
install_efi_directory, "loader", "entries", "{!s}-fallback.conf".format(distribution_translated))
|
install_efi_directory, "loader", "entries",
|
||||||
|
"{!s}-fallback.conf".format(distribution_translated))
|
||||||
loader_path = os.path.join(
|
loader_path = os.path.join(
|
||||||
install_efi_directory, "loader", "loader.conf")
|
install_efi_directory, "loader", "loader.conf")
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
@ -142,17 +145,17 @@ def install_bootloader(boot_loader, fw_type):
|
|||||||
device = boot_device[:-1]
|
device = boot_device[:-1]
|
||||||
print(device)
|
print(device)
|
||||||
subprocess.call(["sgdisk", "--typecode={!s}:EF00".format(boot_p), "{!s}".format(device)])
|
subprocess.call(["sgdisk", "--typecode={!s}:EF00".format(boot_p), "{!s}".format(device)])
|
||||||
subprocess.call(
|
subprocess.call(["gummiboot", "--path={!s}".format(install_efi_directory), "install"])
|
||||||
["gummiboot", "--path={!s}".format(install_efi_directory), "install"])
|
|
||||||
create_conf(uuid, conf_path)
|
create_conf(uuid, conf_path)
|
||||||
create_fallback(uuid, fallback_path)
|
create_fallback(uuid, fallback_path)
|
||||||
create_loader(loader_path)
|
create_loader(loader_path)
|
||||||
else:
|
else:
|
||||||
install_path = boot_loader["installPath"]
|
install_path = boot_loader["installPath"]
|
||||||
check_chroot_call(
|
check_chroot_call(
|
||||||
[libcalamares.job.configuration["grubInstall"], "--target=i386-pc", install_path])
|
[libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
||||||
check_chroot_call([libcalamares.job.configuration[
|
install_path])
|
||||||
"grubMkconfig"], "-o", libcalamares.job.configuration["grubCfg"]])
|
check_chroot_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
||||||
|
libcalamares.job.configuration["grubCfg"]])
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
@ -43,17 +43,25 @@ desktop_environments = [
|
|||||||
DesktopEnvironment('/usr/bin/openbox-session', 'openbox')
|
DesktopEnvironment('/usr/bin/openbox-session', 'openbox')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def find_desktop_environment(root_mount_point):
|
def find_desktop_environment(root_mount_point):
|
||||||
for desktop_environment in desktop_environments:
|
for desktop_environment in desktop_environments:
|
||||||
if os.path.exists("{!s}{!s}".format(root_mount_point,desktop_environment.executable)) \
|
if os.path.exists(
|
||||||
and os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point,desktop_environment.desktop_file)):
|
"{!s}{!s}".format(root_mount_point, desktop_environment.executable)) \
|
||||||
|
and os.path.exists("{!s}/usr/share/xsessions/{!s}.desktop".format(root_mount_point,
|
||||||
|
desktop_environment.desktop_file)):
|
||||||
return desktop_environment
|
return desktop_environment
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def have_dm(dm_name, root_mount_point):
|
|
||||||
return os.path.exists("{!s}/usr/bin/{!s}".format(root_mount_point,dm_name)) or os.path.exists("{!s}/usr/sbin/{!s}".format(root_mount_point,dm_name))
|
|
||||||
|
|
||||||
def set_autologin(username, displaymanagers, default_desktop_environment, root_mount_point):
|
def have_dm(dm_name, root_mount_point):
|
||||||
|
return os.path.exists(
|
||||||
|
"{!s}/usr/bin/{!s}".format(root_mount_point, dm_name)) or os.path.exists(
|
||||||
|
"{!s}/usr/sbin/{!s}".format(root_mount_point, dm_name))
|
||||||
|
|
||||||
|
|
||||||
|
def set_autologin(username, displaymanagers, default_desktop_environment,
|
||||||
|
root_mount_point):
|
||||||
""" Enables automatic login for the installed desktop managers """
|
""" Enables automatic login for the installed desktop managers """
|
||||||
|
|
||||||
if "mdm" in displaymanagers:
|
if "mdm" in displaymanagers:
|
||||||
@ -95,12 +103,15 @@ def set_autologin(username, displaymanagers, default_desktop_environment, root_m
|
|||||||
gdm_conf.write('AutomaticLoginEnable=True\n')
|
gdm_conf.write('AutomaticLoginEnable=True\n')
|
||||||
if os.path.exists("{!s}/var/lib/AccountsService/users".format(root_mount_point)):
|
if os.path.exists("{!s}/var/lib/AccountsService/users".format(root_mount_point)):
|
||||||
os.system(
|
os.system(
|
||||||
"echo \"[User]\" > {!s}/var/lib/AccountsService/users/{!s}".format(root_mount_point,username))
|
"echo \"[User]\" > {!s}/var/lib/AccountsService/users/{!s}".format(
|
||||||
|
root_mount_point, username))
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
os.system(
|
os.system(
|
||||||
"echo \"XSession={!s}\" >> {!s}/var/lib/AccountsService/users/{!s}".format(default_desktop_environment.desktop_file,root_mount_point,username))
|
"echo \"XSession={!s}\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
||||||
|
default_desktop_environment.desktop_file, root_mount_point, username))
|
||||||
os.system(
|
os.system(
|
||||||
"echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(root_mount_point,username))
|
"echo \"Icon=\" >> {!s}/var/lib/AccountsService/users/{!s}".format(
|
||||||
|
root_mount_point, username))
|
||||||
|
|
||||||
if "kdm" in displaymanagers:
|
if "kdm" in displaymanagers:
|
||||||
# Systems with KDM as Desktop Manager
|
# Systems with KDM as Desktop Manager
|
||||||
@ -217,7 +228,8 @@ def run():
|
|||||||
|
|
||||||
if "default_desktop_environment" in libcalamares.job.configuration:
|
if "default_desktop_environment" in libcalamares.job.configuration:
|
||||||
entry = libcalamares.job.configuration["defaultDesktopEnvironment"]
|
entry = libcalamares.job.configuration["defaultDesktopEnvironment"]
|
||||||
default_desktop_environment = DesktopEnvironment(entry["executable"], entry["desktopFile"])
|
default_desktop_environment = DesktopEnvironment(entry["executable"],
|
||||||
|
entry["desktopFile"])
|
||||||
else:
|
else:
|
||||||
default_desktop_environment = find_desktop_environment(root_mount_point)
|
default_desktop_environment = find_desktop_environment(root_mount_point)
|
||||||
|
|
||||||
@ -247,7 +259,8 @@ def run():
|
|||||||
libcalamares.utils.chroot_call(
|
libcalamares.utils.chroot_call(
|
||||||
['groupadd', '-g', '620', 'lightdm'])
|
['groupadd', '-g', '620', 'lightdm'])
|
||||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'lightdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'lightdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['useradd', '-c', '"LightDM Display Manager"',
|
libcalamares.utils.chroot_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.chroot_call(['passwd', '-l', 'lightdm'])
|
||||||
@ -257,7 +270,8 @@ def run():
|
|||||||
['chmod', '+r' '/etc/lightdm/lightdm.conf'])
|
['chmod', '+r' '/etc/lightdm/lightdm.conf'])
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
os.system(
|
os.system(
|
||||||
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(default_desktop_environment.desktop_file,root_mount_point))
|
"sed -i -e \"s/^.*user-session=.*/user-session={!s}/\" {!s}/etc/lightdm/lightdm.conf".format(
|
||||||
|
default_desktop_environment.desktop_file, root_mount_point))
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("lightdm selected but not installed")
|
libcalamares.utils.debug("lightdm selected but not installed")
|
||||||
displaymanagers.remove("lightdm")
|
displaymanagers.remove("lightdm")
|
||||||
@ -269,7 +283,8 @@ def run():
|
|||||||
if libcalamares.utils.chroot_call(['getent', 'group', 'gdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'group', 'gdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['groupadd', '-g', '120', 'gdm'])
|
libcalamares.utils.chroot_call(['groupadd', '-g', '120', 'gdm'])
|
||||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'gdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'gdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['useradd', '-c', '"Gnome Display Manager"',
|
libcalamares.utils.chroot_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.chroot_call(['passwd', '-l', 'gdm'])
|
||||||
@ -286,7 +301,8 @@ def run():
|
|||||||
if libcalamares.utils.chroot_call(['getent', 'group', 'mdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'group', 'mdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['groupadd', '-g', '128', 'mdm'])
|
libcalamares.utils.chroot_call(['groupadd', '-g', '128', 'mdm'])
|
||||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'mdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'mdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['useradd', '-c', '"Linux Mint Display Manager"',
|
libcalamares.utils.chroot_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.chroot_call(['passwd', '-l', 'mdm'])
|
||||||
@ -295,7 +311,8 @@ def run():
|
|||||||
libcalamares.utils.chroot_call(['chmod', '1770', '/var/lib/mdm'])
|
libcalamares.utils.chroot_call(['chmod', '1770', '/var/lib/mdm'])
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
os.system(
|
os.system(
|
||||||
"sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(default_desktop_environment.desktop_file,root_mount_point))
|
"sed -i \"s|default.desktop|{!s}.desktop|g\" {!s}/etc/mdm/custom.conf".format(
|
||||||
|
default_desktop_environment.desktop_file, root_mount_point))
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("mdm selected but not installed")
|
libcalamares.utils.debug("mdm selected but not installed")
|
||||||
displaymanagers.remove("mdm")
|
displaymanagers.remove("mdm")
|
||||||
@ -314,7 +331,8 @@ def run():
|
|||||||
['chmod', '+r', '/etc/lxdm/lxdm.conf'])
|
['chmod', '+r', '/etc/lxdm/lxdm.conf'])
|
||||||
if default_desktop_environment is not None:
|
if default_desktop_environment is not None:
|
||||||
os.system(
|
os.system(
|
||||||
"sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(default_desktop_environment.executable,root_mount_point))
|
"sed -i -e \"s|^.*session=.*|session={!s}|\" {!s}/etc/lxdm/lxdm.conf".format(
|
||||||
|
default_desktop_environment.executable, root_mount_point))
|
||||||
else:
|
else:
|
||||||
libcalamares.utils.debug("lxdm selected but not installed")
|
libcalamares.utils.debug("lxdm selected but not installed")
|
||||||
displaymanagers.remove("lxdm")
|
displaymanagers.remove("lxdm")
|
||||||
@ -326,7 +344,8 @@ def run():
|
|||||||
if libcalamares.utils.chroot_call(['getent', 'group', 'kdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'group', 'kdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['groupadd', '-g', '135', 'kdm'])
|
libcalamares.utils.chroot_call(['groupadd', '-g', '135', 'kdm'])
|
||||||
if libcalamares.utils.chroot_call(['getent', 'passwd', 'kdm']) != 0:
|
if libcalamares.utils.chroot_call(['getent', 'passwd', 'kdm']) != 0:
|
||||||
libcalamares.utils.chroot_call(['useradd', '-u', '135', '-g', 'kdm', '-d',
|
libcalamares.utils.chroot_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(
|
libcalamares.utils.chroot_call(
|
||||||
['chown', '-R', '135:135', 'var/lib/kdm'])
|
['chown', '-R', '135:135', 'var/lib/kdm'])
|
||||||
|
@ -32,16 +32,13 @@ def run():
|
|||||||
accumulator += "This job's path: " + libcalamares.job.working_path + "\n"
|
accumulator += "This job's path: " + libcalamares.job.working_path + "\n"
|
||||||
accumulator += str(libcalamares.job.configuration)
|
accumulator += str(libcalamares.job.configuration)
|
||||||
accumulator += " *** globalstorage test ***\n"
|
accumulator += " *** globalstorage test ***\n"
|
||||||
accumulator += "lala: " + \
|
accumulator += "lala: " + str(libcalamares.globalstorage.contains("lala")) + "\n"
|
||||||
str(libcalamares.globalstorage.contains("lala")) + "\n"
|
accumulator += "foo: " + str(libcalamares.globalstorage.contains("foo")) + "\n"
|
||||||
accumulator += "foo: " + \
|
|
||||||
str(libcalamares.globalstorage.contains("foo")) + "\n"
|
|
||||||
accumulator += "count: " + str(libcalamares.globalstorage.count()) + "\n"
|
accumulator += "count: " + str(libcalamares.globalstorage.count()) + "\n"
|
||||||
libcalamares.globalstorage.insert("item2", "value2")
|
libcalamares.globalstorage.insert("item2", "value2")
|
||||||
libcalamares.globalstorage.insert("item3", 3)
|
libcalamares.globalstorage.insert("item3", 3)
|
||||||
accumulator += "keys: {}\n".format(str(libcalamares.globalstorage.keys()))
|
accumulator += "keys: {}\n".format(str(libcalamares.globalstorage.keys()))
|
||||||
accumulator += "remove: {}\n".format(
|
accumulator += "remove: {}\n".format(str(libcalamares.globalstorage.remove("item2")))
|
||||||
str(libcalamares.globalstorage.remove("item2")))
|
|
||||||
accumulator += "values: {} {} {}\n".format(
|
accumulator += "values: {} {} {}\n".format(
|
||||||
str(libcalamares.globalstorage.value("foo")),
|
str(libcalamares.globalstorage.value("foo")),
|
||||||
str(libcalamares.globalstorage.value("item2")),
|
str(libcalamares.globalstorage.value("item2")),
|
||||||
|
@ -26,13 +26,14 @@ import shutil
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from libcalamares.utils import check_chroot_call
|
from libcalamares.utils import check_chroot_call
|
||||||
|
|
||||||
|
|
||||||
def cpuinfo():
|
def cpuinfo():
|
||||||
''' Return the information in /proc/cpuinfo
|
"""
|
||||||
as a dictionary in the following format:
|
Return the information in /proc/cpuinfo as a dictionary in the following format:
|
||||||
cpu_info['proc0']={...}
|
cpu_info['proc0']={...}
|
||||||
cpu_info['proc1']={...}
|
cpu_info['proc1']={...}
|
||||||
|
|
||||||
'''
|
"""
|
||||||
|
|
||||||
cpuinfo = OrderedDict()
|
cpuinfo = OrderedDict()
|
||||||
procinfo = OrderedDict()
|
procinfo = OrderedDict()
|
||||||
@ -54,6 +55,7 @@ def cpuinfo():
|
|||||||
|
|
||||||
return cpuinfo
|
return cpuinfo
|
||||||
|
|
||||||
|
|
||||||
def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
||||||
""" Set up mkinitcpio.conf """
|
""" Set up mkinitcpio.conf """
|
||||||
|
|
||||||
@ -72,6 +74,7 @@ def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
|||||||
with open(path, "w") as mkinitcpio_file:
|
with open(path, "w") as mkinitcpio_file:
|
||||||
mkinitcpio_file.write("\n".join(mklins) + "\n")
|
mkinitcpio_file.write("\n".join(mklins) + "\n")
|
||||||
|
|
||||||
|
|
||||||
def modify_mkinitcpio_conf(partitions, root_mount_point):
|
def modify_mkinitcpio_conf(partitions, root_mount_point):
|
||||||
""" Modifies mkinitcpio.conf """
|
""" Modifies mkinitcpio.conf """
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ except ImportError:
|
|||||||
|
|
||||||
|
|
||||||
class Job:
|
class Job:
|
||||||
|
|
||||||
def __init__(self, working_path, doc, cfg_doc):
|
def __init__(self, working_path, doc, cfg_doc):
|
||||||
self.module_name = doc["name"]
|
self.module_name = doc["name"]
|
||||||
self.pretty_name = "Testing job " + doc["name"]
|
self.pretty_name = "Testing job " + doc["name"]
|
||||||
|
Loading…
Reference in New Issue
Block a user