Merge pull request #121 from shadeslayer/master
Make sure executables and paths exist before using them
This commit is contained in:
commit
0436aa0ea0
@ -29,6 +29,9 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
|||||||
use_splash = ""
|
use_splash = ""
|
||||||
swap_uuid = ""
|
swap_uuid = ""
|
||||||
|
|
||||||
|
if not os.path.exists(default_dir):
|
||||||
|
return ("Directory does not exist", "The directory {} does not exist on
|
||||||
|
the target".format(default_dir))
|
||||||
if os.path.exists(plymouth_bin):
|
if os.path.exists(plymouth_bin):
|
||||||
use_splash = "splash"
|
use_splash = "splash"
|
||||||
|
|
||||||
@ -58,10 +61,10 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
|||||||
with open(default_grub, 'w') as grub_file:
|
with open(default_grub, 'w') as grub_file:
|
||||||
grub_file.write("\n".join(lines) + "\n")
|
grub_file.write("\n".join(lines) + "\n")
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
distributor = libcalamares.job.configuration["distributor"]
|
distributor = libcalamares.job.configuration["distributor"]
|
||||||
modify_grub_default(partitions, root_mount_point, distributor)
|
return modify_grub_default(partitions, root_mount_point, distributor)
|
||||||
return None
|
|
||||||
|
@ -20,19 +20,22 @@
|
|||||||
import libcalamares
|
import libcalamares
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import shutil
|
||||||
from libcalamares.utils import check_chroot_call
|
from libcalamares.utils import check_chroot_call
|
||||||
|
|
||||||
|
|
||||||
def get_cpu():
|
def get_cpu():
|
||||||
""" Check if system is an intel system. """
|
""" Check if system is an intel system. """
|
||||||
|
|
||||||
process1 = subprocess.Popen(["hwinfo", "--cpu"], stdout=subprocess.PIPE)
|
if shutil.which("hwinfo") != None:
|
||||||
process2 = subprocess.Popen(["grep", "Model:[[:space:]]"],
|
process1 = subprocess.Popen(["hwinfo", "--cpu"], stdout=subprocess.PIPE)
|
||||||
stdin=process1.stdout, stdout=subprocess.PIPE)
|
process2 = subprocess.Popen(["grep", "Model:[[:space:]]"],
|
||||||
process1.stdout.close()
|
stdin=process1.stdout, stdout=subprocess.PIPE)
|
||||||
out, err = process2.communicate()
|
process1.stdout.close()
|
||||||
return out.decode().lower()
|
out, err = process2.communicate()
|
||||||
|
return out.decode().lower()
|
||||||
|
|
||||||
|
return ""
|
||||||
|
|
||||||
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 """
|
||||||
|
@ -123,6 +123,10 @@ class UnpackOperation:
|
|||||||
fslist = ""
|
fslist = ""
|
||||||
|
|
||||||
if entry.sourcefs == "squashfs":
|
if entry.sourcefs == "squashfs":
|
||||||
|
if shutil.which("unsquashfs") == None:
|
||||||
|
return ("Failed to unpack image", "Failed to find unsquashfs, make sure you have
|
||||||
|
the squashfs-tools package installed")
|
||||||
|
|
||||||
fslist = subprocess.check_output(["unsquashfs",
|
fslist = subprocess.check_output(["unsquashfs",
|
||||||
"-l",
|
"-l",
|
||||||
entry.source])
|
entry.source])
|
||||||
|
Loading…
Reference in New Issue
Block a user