Esempio n. 1
0
    def LastSteps(cls):
        Tools.Info("Performing finishing steps ...")

        # Create mtab file
        call(["touch", var.temp + "/etc/mtab"])

        if not os.path.isfile(var.temp + "/etc/mtab"):
            Tools.Fail("Error creating the mtab file. Exiting.")

        cls.CreateLibraryLinks()

        # Copy the init script
        Tools.SafeCopy(var.files_dir + "/init", var.temp)

        # Give execute permissions to the script
        cr = call(["chmod", "u+x", var.temp + "/init"])

        if cr != 0:
            Tools.Fail("Failed to give executive privileges to " + var.temp +
                       "/init")

        # Sets initramfs script version number
        cmd = f"echo {var.version} > {var.temp}/version.bliss"
        call(cmd, shell=True)

        # Copy all of the modprobe configurations
        if os.path.isdir("/etc/modprobe.d/"):
            shutil.copytree("/etc/modprobe.d/", var.temp + "/etc/modprobe.d/")

        cls.CopyUdevAndSupportFiles()
        cls.DumpSystemKeymap()

        # Any last substitutions or additions/modifications should be done here

        if Luks.IsEnabled():
            # Copy over our keyfile if the user activated it
            if Luks.IsKeyfileEnabled():
                Tools.Flag("Embedding our keyfile into the initramfs...")
                Tools.SafeCopy(Luks.GetKeyfilePath(), var.temp + "/etc",
                               "keyfile")

            # Copy over our detached header if the user activated it
            if Luks.IsDetachedHeaderEnabled():
                Tools.Flag(
                    "Embedding our detached header into the initramfs...")
                Tools.SafeCopy(Luks.GetDetachedHeaderPath(), var.temp + "/etc",
                               "header")

        # Add any modules needed into the initramfs
        requiredModules = ",".join(Modules.GetFiles())
        cmd = f"echo {requiredModules} > {var.temp}/modules.bliss"
        call(cmd, shell=True)

        cls.CopyLibGccLibrary()
Esempio n. 2
0
    def LastSteps(cls):
        Tools.Info("Performing finishing steps ...")

        # Create mtab file
        call(["touch", var.temp + "/etc/mtab"])

        if not os.path.isfile(var.temp + "/etc/mtab"):
            Tools.Fail("Error creating the mtab file. Exiting.")

        cls.CreateLibraryLinks()

        # Copy the init script
        Tools.SafeCopy(var.files_dir + "/init", var.temp)

        # Give execute permissions to the script
        cr = call(["chmod", "u+x", var.temp + "/init"])

        if cr != 0:
            Tools.Fail("Failed to give executive privileges to " + var.temp +
                       "/init")

        # Copy the bash related files
        bash_files = [
            var.files_dir + "/bash/profile", var.files_dir + "/bash/DIR_COLORS"
        ]

        for bash_file in bash_files:
            Tools.SafeCopy(bash_file, var.temp + "/etc/")

        Tools.SafeCopy(var.files_dir + "/bash/bashrc", var.temp + "/etc/bash")

        # Sets initramfs script version number
        call([
            "sed", "-i", "-e",
            var.initrdVersionLine + "s/0/" + var.version + "/",
            var.temp + "/init"
        ])

        # Copy all of the modprobe configurations
        if os.path.isdir("/etc/modprobe.d/"):
            shutil.copytree("/etc/modprobe.d/", var.temp + "/etc/modprobe.d/")

        cls.CopyUdevAndSupportFiles()
        cls.DumpSystemKeymap()

        # Any last substitutions or additions/modifications should be done here

        # Enable LUKS in the init if LUKS is being used
        if Luks.IsEnabled():
            Tools.ActivateTriggerInInit(var.useLuksLine)

            # Copy over our keyfile if the user activated it
            if Luks.IsKeyfileEnabled():
                Tools.Flag("Embedding our keyfile into the initramfs...")
                Tools.SafeCopy(Luks.GetKeyfilePath(), var.temp + "/etc",
                               "keyfile")

            # Copy over our detached header if the user activated it
            if Luks.IsDetachedHeaderEnabled():
                Tools.Flag(
                    "Embedding our detached header into the initramfs...")
                Tools.SafeCopy(Luks.GetDetachedHeaderPath(), var.temp + "/etc",
                               "header")

        # Enable RAID in the init if RAID is being used
        if Raid.IsEnabled():
            Tools.ActivateTriggerInInit(var.useRaidLine)

            # Make sure to copy the mdadm.conf from our current system.
            # If not, the kernel autodetection while assembling the array
            # will not know what name to give them, so it will name it something
            # like /dev/md126, /dev/md127 rather than /dev/md0, /dev/md1.

            # If the user didn't modify the default (all commented) mdadm.conf file,
            # then they will obviously get wrong raid array numbers being assigned
            # by the kernel. The user needs to run a "mdadm --examine --scan > /etc/mdadm.conf"
            # to fix this, and re-run the initramfs creator.
            mdadm_conf = "/etc/mdadm.conf"
            Tools.CopyConfigOrWarn(mdadm_conf)

        # Enable LVM in the init if LVM is being used
        if Lvm.IsEnabled():
            Tools.ActivateTriggerInInit(var.useLvmLine)

            lvm_conf = "/etc/lvm/lvm.conf"
            Tools.CopyConfigOrWarn(lvm_conf)

        # Enable ZFS in the init if ZFS is being used
        if Zfs.IsEnabled():
            Tools.ActivateTriggerInInit(var.useZfsLine)

        # Enable ADDON in the init and add our modules to the initramfs
        # if addon is being used
        if Addon.IsEnabled():
            Tools.ActivateTriggerInInit(var.useAddonLine)
            call([
                "sed", "-i", "-e", var.addonModulesLine + "s/\"\"/\"" +
                " ".join(Addon.GetFiles()) + "\"/", var.temp + "/init"
            ])

        cls.CopyLibGccLibrary()