コード例 #1
0
ファイル: bootloader.py プロジェクト: Tayyib/uludag
        def boot_parameters(root_label):
            """ Returns kernel parameters from cmd_line.
                It also cleans unnecessary options """

            def is_required(param):
                params = ["root","initrd","init","xorg","yali4","BOOT_IMAGE","lang","mudur",consts.kahya_param]
                for p in params:
                    if param.startswith("%s=" % p):
                        return False
                return True

            s = []
            # Add initramfs.conf config file support on 2009.1. But may be old system didnt have it(Like Pardus 2008)
            if not os.path.exists(os.path.join(consts.target_dir, "etc/initramfs.conf")):
                s.append("root=LABEL=%s" % (root_label))
                # a hack for http://bugs.pardus.org.tr/3345
                rt = request.mountRequestType
                pt = parttype.swap
                swap_part_req = partrequests.searchPartTypeAndReqType(pt, rt)
                if swap_part_req:
                    s.append("resume=%s" %(swap_part_req.partition().getPath()))

            # Get parameters from cmdline.
            for i in [x for x in open("/proc/cmdline", "r").read().split()]:
                if is_required(i):
                    s.append(i)

            return " ".join(s).strip()
コード例 #2
0
ファイル: bootloader.py プロジェクト: dhirajkhatiwada1/uludag
        def boot_parameters(root_label):
            """ Returns kernel parameters from cmd_line.
                It also cleans unnecessary options """

            def is_required(param):
                params = ["root","initrd","init","xorg","yali4","BOOT_IMAGE","lang","mudur",consts.kahya_param]
                for p in params:
                    if param.startswith("%s=" % p):
                        return False
                return True

            s = []
            s.append("root=LABEL=%s" % (root_label))
            # Get parameters from cmdline.
            for i in [x for x in open("/proc/cmdline", "r").read().split()]:
                if is_required(i):
                    s.append(i)

            # a hack for http://bugs.pardus.org.tr/3345
            rt = request.mountRequestType
            pt = parttype.swap
            swap_part_req = partrequests.searchPartTypeAndReqType(pt, rt)
            if swap_part_req:
                s.append("resume=%s" %(swap_part_req.partition().getPath()))

            return " ".join(s).strip()
コード例 #3
0
ファイル: bootloader.py プロジェクト: Tayyib/uludag
        def boot_parameters(root):
            """ Returns kernel parameters from cmd_line.
                It also cleans unnecessary options """
            s = []
            # Get parameters from cmdline.
            for i in [x for x in open("/proc/cmdline", "r").read().split() if not x.startswith("init=") and not x.startswith("xorg=") and not x.startswith("yali=") and not x.startswith(ctx.consts.kahyaParam)]:
                if i.startswith("root="):
                    s.append("root=/dev/%s" % (root))
                elif i.startswith("mudur="):
                    mudur = "mudur="
                    for p in i[len("mudur="):].split(','):
                        if p == "livecd" or p == "livedisk": continue
                        mudur += p
                    if not len(mudur) == len("mudur="):
                        s.append(mudur)
                else:
                    s.append(i)

            # a hack for http://bugs.pardus.org.tr/3345
            rt = request.mountRequestType
            pt = parttype.swap
            swap_part_req = partrequests.searchPartTypeAndReqType(pt, rt)
            if swap_part_req:
                s.append("resume=%s" %(swap_part_req.partition().getPath()))

            return " ".join(s).strip()
コード例 #4
0
        def boot_parameters(root_label):
            """ Returns kernel parameters from cmd_line.
                It also cleans unnecessary options """
            def is_required(param):
                params = [
                    "root", "initrd", "init", "xorg", "yali4", "BOOT_IMAGE",
                    "lang", "mudur", consts.kahya_param
                ]
                for p in params:
                    if param.startswith("%s=" % p):
                        return False
                return True

            s = []
            # Add initramfs.conf config file support on 2009.1. But may be old system didnt have it(Like Pardus 2008)
            #if not os.path.exists(os.path.join(consts.target_dir, "etc/initramfs.conf")):
            # Removing root=LABEL= from cmdline makes problem for suspend
            s.append("root=LABEL=%s" % (root_label))
            # a hack for http://bugs.pardus.org.tr/3345
            rt = request.mountRequestType
            pt = parttype.swap
            swap_part_req = partrequests.searchPartTypeAndReqType(pt, rt)
            if swap_part_req:
                s.append("resume=%s" % (swap_part_req.partition().getPath()))

            # Get parameters from cmdline.
            for i in [x for x in open("/proc/cmdline", "r").read().split()]:
                if is_required(i):
                    s.append(i)

            return " ".join(s).strip()
コード例 #5
0
        def boot_parameters(root_label):
            """ Returns kernel parameters from cmd_line.
                It also cleans unnecessary options """
            def is_required(param):
                params = [
                    "root", "initrd", "init", "xorg", "yali4", "BOOT_IMAGE",
                    "lang", "mudur", consts.kahya_param
                ]
                for p in params:
                    if param.startswith("%s=" % p):
                        return False
                return True

            s = []
            s.append("root=LABEL=%s" % (root_label))
            # Get parameters from cmdline.
            for i in [x for x in open("/proc/cmdline", "r").read().split()]:
                if is_required(i):
                    s.append(i)

            # a hack for http://bugs.pardus.org.tr/3345
            rt = request.mountRequestType
            pt = parttype.swap
            swap_part_req = partrequests.searchPartTypeAndReqType(pt, rt)
            if swap_part_req:
                s.append("resume=%s" % (swap_part_req.partition().getPath()))

            return " ".join(s).strip()
コード例 #6
0
ファイル: postinstall.py プロジェクト: pars-linux/uludag
def writeInitramfsConf(parameters=[]):
    path = os.path.join(consts.target_dir, "etc/initramfs.conf")

    rootPartitionRequest = ctx.partrequests.searchPartTypeAndReqType(parttype.root, request.mountRequestType)
    rootPartitionLabel = rootPartitionRequest.partition().getTempLabel()
    parameters.append("root=LABEL=%s" % rootPartitionLabel)

    swapPartitionRequest = partrequests.searchPartTypeAndReqType(parttype.swap, request.mountRequestType)

    if swapPartitionRequest:
        parameters.append("resume=%s" % swapPartitionRequest.partition().getPath())

    ctx.debugger.log("Configuring initramfs.conf file with parameters:%s" % " ".join(parameters))

    initramfsConf = open(path, 'w')

    for param in parameters:
        try:
            initramfsConf.write("%s\n" % param)
        except IOError, msg:
            ctx.debugger.log("Unexpected error: %s" % msg)
            raise IOError
コード例 #7
0
ファイル: installer.py プロジェクト: dhirajkhatiwada1/uludag
    def installBootloader(self, pardusPart = None):
        if not ctx.installData.bootLoaderDev:
            ctx.debugger.log("Dont install bootloader selected; skipping.")
            return

        loader = yali4.bootloader.BootLoader()

        # Predefined Pardus path for rescue mode
        if pardusPart:
            _ins_part = pardusPart.getPath()
            _ins_part_label = pardusPart.getTempLabel() or pardusPart.getFSLabel()
            grubConfPath = os.path.join(ctx.consts.target_dir,"boot/grub/grub.conf")
            if os.path.exists(grubConfPath):
                # Rename the old config we will create a new one
                os.rename(grubConfPath, grubConfPath + ".old")
        else:
            root_part_req = ctx.partrequests.searchPartTypeAndReqType(parttype.root,
                                                                      request.mountRequestType)
            _ins_part = root_part_req.partition().getPath()
            _ins_part_label = root_part_req.partition().getTempLabel() or pardusPart.getFSLabel()

        loader.writeGrubConf(_ins_part, ctx.installData.bootLoaderDev, _ins_part_label)

        # If selected, Check for Windows Partitions
        # FIXME We need to use pardus.grubutils addEntry method for adding found Windows entries
        if ctx.installData.bootLoaderDetectOthers:

            ctx.debugger.log("Checking for Other Distros (Windows) ...")
            for d in yali4.storage.devices:
                for p in d.getPartitions():
                    fs = p.getFSName()
                    if fs in ("ntfs", "fat32"):
                        if yali4.sysutils.isWindowsBoot(p.getPath(), fs):
                            ctx.debugger.log("Windows Found on device %s partition %s " % (p.getDevicePath(), p.getPath()))
                            win_fs = fs
                            win_dev = os.path.basename(p.getDevicePath())
                            win_root = os.path.basename(p.getPath())
                            loader.grubConfAppendWin(ctx.installData.bootLoaderDev,
                                                     win_dev,
                                                     win_root,
                                                     win_fs)
                            continue

        # Pardus Grub utils
        import pardus.grubutils

        # Parse current grub.conf which includes installed release entry and Win entries if exists
        grubConf = pardus.grubutils.grubConf()
        grubConfPath = os.path.join(ctx.consts.target_dir,"boot/grub/grub.conf")
        grubConf.parseConf(grubConfPath)

        # If selected, Check for Linux Partitions
        if ctx.installData.bootLoaderDetectOthers:

            def _update_dev(old, new):
                # If it fails
                try:
                    return "(%s," % new + old.split(',')[1]
                except:
                    ctx.debugger.log("UD: Failed, new: %s -- old: %s" % (new, old))
                    ctx.debugger.log("UD: Failed, using old: %s" % old)
                    return old

            ctx.debugger.log("Checking for Other Distros (Linux) ...")
            for d in yali4.storage.devices:
                for p in d.getPartitions():
                    fs = p.getFSName()
                    if fs in ("ext4", "ext3", "reiserfs", "xfs") and not p.getPath() == _ins_part:
                        ctx.debugger.log("Partition found which has usable fs (%s)" % p.getPath())
                        guest_grub_conf = yali4.sysutils.isLinuxBoot(p.getPath(), fs)
                        if guest_grub_conf:
                            ctx.debugger.log("GRUB Found on device %s partition %s " % (p.getDevicePath(), p.getPath()))
                            guestGrubConf = pardus.grubutils.grubConf()
                            guestGrubConf.parseConf(guest_grub_conf)
                            for entry in guestGrubConf.entries:
                                # if entry has kernel value we can use it in our grub.conf
                                # some distros uses uuid instead of root
                                if entry.getCommand("kernel"):
                                    entry.title = entry.title + " [ %s ]" % p.getName()

                                    # if device order changed we should update device order in foreign grub.conf
                                    _grub_dev = yali4.bootloader.findGrubDev(p.getPath())

                                    if entry.getCommand("root"):
                                        # update device order for root command
                                        _root = entry.getCommand("root")
                                        if _root.value != '':
                                            _root.value = _update_dev(_root.value, _grub_dev)

                                        # update device order for kernel command if already defined
                                        _kernel = entry.getCommand("kernel")
                                        if _kernel and _root.value:
                                            if _kernel.value.startswith('('):
                                                _kernel.value = ''.join([_root.value, _kernel.value.split(')')[1]])

                                        # update device order for initrd command if already defined
                                        _initrd = entry.getCommand("initrd")
                                        if _initrd and _root.value:
                                            if _initrd.value.startswith('('):
                                                _initrd.value = ''.join([_root.value, _initrd.value.split(')')[1]])

                                    grubConf.addEntry(entry)
                        else:
                            # If not a proper grub.conf found umount the partition
                            yali4.sysutils.umount_()

        # write the new grub.conf
        grubConf.write(grubConfPath)

        # BUG:#11255 normal user doesn't mount /mnt/archive directory. 
        # We set new formatted partition priveleges as user=root group=disk and change mod as 0770
        # Check archive partition type
        archiveRequest = partrequests.searchPartTypeAndReqType(parttype.archive, request.mountRequestType)
        if archiveRequest:
            yali4.postinstall.setPartitionPrivileges(archiveRequest, 0770, 0, 6)

        # Umount system paths
        yali4.sysutils.umountSystemPaths()

        # GPT stuff
        gptsync_path = yali4.sysutils.find_executable("gptsync")
        if gptsync_path and not pardusPart:
            gptsync = os.popen("%s %s" % (gptsync_path, root_part_req.partition().getDevicePath()))
            for line in gptsync.readlines():
                if line.startswith("Status:"):
                    ctx.debugger.log("GPTSYNC: %s" % line.split("Status: ")[1])
            gptsync.close()
            time.sleep(1)
        else:
            ctx.debugger.log("GPTSYNC: Command Not Found !")

        # finally install it
        return loader.installGrub(ctx.installData.bootLoaderDev, _ins_part)