1 Star 0 Fork 23

庞庆/anaconda

forked from src-anolis-os/anaconda 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0012-anaconda-anolis-add-loongarch-pmon-support.patch 7.21 KB
一键复制 编辑 原始数据 按行查看 历史
From b2f3dad1bb1a4170262c874a5d35b35728e3bf7e Mon Sep 17 00:00:00 2001
From: yangxiaoxuan <yangxiaoxuan@openanolis.org>
Date: Wed, 15 Sep 2021 10:33:09 +0800
Subject: [PATCH] anaconda anolis add loongarch pmon support
---
data/product.d/centos.conf | 3 +
pyanaconda/modules/storage/bootloader/base.py | 5 +-
.../modules/storage/bootloader/factory.py | 4 +
pyanaconda/modules/storage/bootloader/pmon.py | 87 +++++++++++++++++++
.../modules/storage/devicetree/fsset.py | 6 +-
pyanaconda/modules/storage/platform.py | 5 +-
6 files changed, 107 insertions(+), 3 deletions(-)
create mode 100644 pyanaconda/modules/storage/bootloader/pmon.py
diff --git a/pyanaconda/modules/storage/bootloader/base.py b/pyanaconda/modules/storage/bootloader/base.py
index 819abaa..98d197d 100644
--- a/pyanaconda/modules/storage/bootloader/base.py
+++ b/pyanaconda/modules/storage/bootloader/base.py
@@ -735,7 +735,10 @@ class BootLoader(object):
# Choose the largest swap device for that.
if blivet.arch.is_x86() or blivet.arch.is_loongarch() and swap_devices:
resume_device = max(swap_devices, key=lambda x: x.size)
- self.boot_args.add("resume=%s" % resume_device.fstab_spec)
+ if not blivet.arch.is_efi() and blivet.arch.is_loongarch():
+ self.boot_args.add("resume=%s" % resume_device.path)
+ else:
+ self.boot_args.add("resume=%s" % resume_device.fstab_spec)
# Does /usr have its own device? If so, we need to tell dracut
usr_device = storage.mountpoints.get("/usr")
diff --git a/pyanaconda/modules/storage/bootloader/factory.py b/pyanaconda/modules/storage/bootloader/factory.py
index b0dcea3..215ebd4 100644
--- a/pyanaconda/modules/storage/bootloader/factory.py
+++ b/pyanaconda/modules/storage/bootloader/factory.py
@@ -142,6 +142,10 @@ class BootLoaderFactory(object):
from pyanaconda.modules.storage.bootloader.efi import LOONGARCHEFIGRUB
return LOONGARCHEFIGRUB
+ if platform_class is platform.LOONGARCHLEGACY:
+ from pyanaconda.modules.storage.bootloader.pmon import LOONGARCHPMON
+ return LOONGARCHPMON
+
if platform_class is platform.ARM:
from pyanaconda.modules.storage.bootloader.extlinux import EXTLINUX
return EXTLINUX
diff --git a/pyanaconda/modules/storage/bootloader/pmon.py b/pyanaconda/modules/storage/bootloader/pmon.py
new file mode 100644
index 0000000..7e02f61
--- /dev/null
+++ b/pyanaconda/modules/storage/bootloader/pmon.py
@@ -0,0 +1,87 @@
+#
+# Writer: Sun Haiyong (youbest@sina.com)
+#
+import os
+
+from pyanaconda.modules.storage.bootloader.base import BootLoader, Arguments, BootLoaderError
+from pyanaconda.core import util
+from pyanaconda.core.configuration.anaconda import conf
+from pyanaconda.product import productName
+
+from pyanaconda.anaconda_loggers import get_module_logger
+log = get_module_logger(__name__)
+
+__all__ = ["PMON", "LOONGARCHPMON"]
+
+
+class PMON(BootLoader):
+ name = "PMON"
+ _config_file = "boot.cfg"
+ _config_dir = "/boot"
+
+ stage2_format_types = ["ext3", "ext2"]
+ stage2_device_types = ["partition"]
+# stage2_bootable = True
+
+ @property
+ def config_file(self):
+ return "%s/%s" % (self._config_dir, self._config_file)
+
+ @property
+ def boot_prefix(self):
+ """ Prefix, if any, to paths in /boot. """
+ if self.stage2_device.format.mountpoint == "/":
+ prefix = "/boot"
+ else:
+ prefix = ""
+
+ return prefix
+
+ def write_config_console(self, config):
+ if not self.console:
+ return
+
+ console_arg = "console=%s" % self.console
+ if self.console_options:
+ console_arg += ",%s" % self.console_options
+ self.boot_args.add(console_arg)
+
+ def write_config_images(self, config):
+ self.write_config_console(config)
+ for image in self.images:
+ args = Arguments()
+ args.update(["root=%s" % image.device.path, "ro"])
+ args.update(self.boot_args)
+ log.info("bootloader.py: used boot args: %s ", args)
+
+ # extlinux labels cannot have spaces
+ label = "%s(%s)" % (self.image_label(image), image.version)
+ label = label.replace(" ", "")
+ stanza = ("title %(label)s\n"
+ "\tkernel /dev/fs/ext2@wd0%(boot_prefix)s/%(kernel)s\n"
+ "\tinitrd /dev/fs/ext2@wd0%(boot_prefix)s/%(initrd)s\n"
+ "\targs %(args)s\n\n"
+ % {"label": label,
+ "kernel": image.kernel,
+ "initrd": image.initrd,
+ "args": args,
+ "boot_prefix": self.boot_prefix})
+ config.write(stanza)
+
+ def write_config_header(self, config):
+ header = ("timeout %(timeout)d\n"
+ "showmenu 1\n"
+ % {"timeout": self.timeout})
+ config.write(header)
+ if self.default is not None:
+ config.write("default 0\n\n")
+
+ def install(self, args=None):
+ """installation should be a no-op, just writing the config is sufficient for the
+ firmware's bootloader (petitboot)
+ """
+ pass
+
+
+class LOONGARCHPMON(PMON):
+ """ LOONGARCHPMON """
diff --git a/pyanaconda/modules/storage/devicetree/fsset.py b/pyanaconda/modules/storage/devicetree/fsset.py
index 00aef10..ab7cd6f 100644
--- a/pyanaconda/modules/storage/devicetree/fsset.py
+++ b/pyanaconda/modules/storage/devicetree/fsset.py
@@ -24,6 +24,7 @@ import gi
gi.require_version("BlockDev", "2.0")
from gi.repository import BlockDev as blockdev
+from blivet import arch
from blivet.devices import NoDevice, DirectoryDevice, NFSDevice, FileDevice, MDRaidArrayDevice, \
NetworkStorageDevice, OpticalDevice
from blivet.errors import UnrecognizedFSTabEntryError, FSTabTypeMismatchError
@@ -764,7 +765,10 @@ class FSSet(object):
break
if device.encrypted:
options += ",x-systemd.device-timeout=0"
- devspec = device.fstab_spec
+ if not arch.is_efi() and arch.is_loongarch():
+ devspec = device.path
+ else:
+ devspec = device.fstab_spec
dump = device.format.dump
if device.format.check and mountpoint == "/":
passno = 1
diff --git a/pyanaconda/modules/storage/platform.py b/pyanaconda/modules/storage/platform.py
index 4678e73..9b730c1 100644
--- a/pyanaconda/modules/storage/platform.py
+++ b/pyanaconda/modules/storage/platform.py
@@ -187,6 +187,9 @@ class LOONGARCHEFI(EFI):
class ArmEFI(EFI):
_non_linux_format_types = ["vfat", "ntfs"]
+class LOONGARCHLEGACY(Platform):
+ _boot_stage1_device_types = ["partition"]
+ _boot_descriptions = {"partition": Platform._boot_partition_description}
class PPC(Platform):
_ppc_machine = arch.get_ppc_machine()
@@ -299,7 +302,7 @@ def get_platform():
elif arch.is_arm():
return ARM()
elif arch.is_loongarch():
- return LOONGARCHEFI()
+ return LOONGARCHLEGACY()
else:
raise SystemError("Could not determine system architecture.")
--
2.18.4
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pang-qing/anaconda.git
git@gitee.com:pang-qing/anaconda.git
pang-qing
anaconda
anaconda
a8

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385