e2k implementation

Added ability to build images for e2k arch
This commit is contained in:
betcher 2022-05-18 06:26:41 +00:00
parent 5a73c2ccb2
commit 6ef68fdad7
2 changed files with 191 additions and 0 deletions

187
e2k-implementation.diff Normal file
View file

@ -0,0 +1,187 @@
diff --git a/imgcreate/live.py b/imgcreate/live.py
index a51834a..0fdc9ba 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -1496,6 +1496,174 @@ class ppc64LiveImageCreator(ppcLiveImageCreator):
return ["kernel.ppc"] + \
ppcLiveImageCreator._get_excluded_packages(self)
+class e2kLiveImageCreator(LiveImageCreatorBase):
+ """ImageCreator for e2k machines"""
+ def __init__(self, *args, **kwargs):
+ LiveImageCreatorBase.__init__(self, *args, **kwargs)
+ self._efiarch = None
+
+ def _get_xorrisofs_options(self, isodir):
+ options = ["-no-pad", '-append_partition', '2', '0x83', 'e2k.img', ]
+
+ options += ["-rational-rock", "-joliet", "-volid", self.fslabel]
+ return options
+
+ def _get_required_packages(self):
+ return LiveImageCreatorBase._get_required_packages(self)
+
+ def _get_isolinux_stanzas(self, isodir):
+ return ""
+
+ def _generate_grub2_bootimg(self, isodir):
+ return ""
+
+ def __copy_kernel_and_initramfs(self, isodir, version, index, bootdir):
+ shutil.copyfile(bootdir + "/vmlinuz-" + version,
+ isodir + "/vmlinuz" + index)
+
+ isDracut = False
+ if os.path.exists(self._instroot + "/usr/bin/dracut"):
+ isDracut = True
+
+ # FIXME: Implement a better check for how the initramfs is named...
+ if os.path.exists(bootdir + "/initramfs-" + version + ".img"):
+ shutil.copyfile(bootdir + "/initramfs-" + version + ".img",
+ isodir + "/initrd" + index + ".img")
+ elif os.path.exists(bootdir + "/initrd-" + version + ".img"):
+ shutil.copyfile(bootdir + "/initrd-" + version + ".img",
+ isodir + "/initrd" + index + ".img")
+ elif not self.base_on:
+ logging.error("No initramfs or initrd found for %s" % (version,))
+
+ is_xen = False
+ if os.path.exists(bootdir + "/xen.gz-" + version[:-3]):
+ shutil.copyfile(bootdir + "/xen.gz-" + version[:-3],
+ isodir + "/xen" + index + ".gz")
+ is_xen = True
+
+ return (is_xen, isDracut)
+
+ def __is_default_kernel(self, kernel, kernels):
+ if len(kernels) == 1:
+ return True
+
+ if kernel == self._default_kernel:
+ return True
+
+ if kernel.startswith(b"kernel-") and kernel[7:] == self._default_kernel:
+ return True
+
+ return False
+
+
+ def __get_kernel_initrd(self, isodir):
+ bootdir = self._instroot + "/boot"
+ kernels = self._get_kernel_versions()
+ kernel_options = self._get_kernel_options()
+ checkisomd5 = self._has_checkisomd5()
+ index="0"
+ for kernel, version in ((k,v) for k in kernels for v in kernels[k]):
+ (is_xen, isDracut) = self.__copy_kernel_and_initramfs(isodir, version, index, bootdir)
+ index = str(int(index) + 1)
+ if os.path.exists(bootdir + "/pcmemtest"):
+ shutil.copyfile(bootdir + "/pcmemtest",
+ isodir + "/pcmemtest")
+ else:
+ print('pcmemtest not found')
+
+ def __get_menuentry(self, **args):
+ args["rootlabel"] = "live:LABEL=%(isolabel)s" % args
+ menuentry = """
+label=%(entrylabel)s
+ partition=0
+ image=/vmlinuz%(index)s
+ initrd=/initrd%(index)s.img
+ cmdline=root=%(rootlabel)s %(liveargs)s
+""" %args
+ return menuentry
+
+ def __get_stanzas(self, isodir, isolabel):
+ kernel_options = self._get_kernel_options()
+ checkisomd5 = self._has_checkisomd5()
+ deflang = ' inst.lang=ru_RU.UTF-8 locale.LANG=ru_RU.UTF-8 locale.LANGUAGE=ru_RU.UTF-8 '
+ for index in range(0, 9):
+ # we don't support xen kernels
+ if os.path.exists("%s/EFI/BOOT/xen%d.gz" %(isodir, index)):
+ continue
+
+ cfg = self.__get_menuentry(entrylabel = isolabel,
+ isolabel = isolabel,
+ liveargs = kernel_options + deflang + " rhgb splash=silent logo.nologo",
+ index = index)
+
+ if not 'systemd.unit=anaconda.target' in kernel_options:
+ cfg += self.__get_menuentry(entrylabel = isolabel + '-install',
+ isolabel = isolabel,
+ liveargs = kernel_options + deflang + " systemd.unit=anaconda.target ",
+ index = index)
+
+ cfg += self.__get_menuentry(entrylabel = isolabel + '-install_cli',
+ isolabel = isolabel,
+ liveargs = kernel_options + deflang + " systemd.unit=anaconda.target inst.text",
+ index = index)
+
+ if checkisomd5:
+ cfg += self.__get_menuentry(entrylabel = isolabel + '-check',
+ isolabel = isolabel,
+ liveargs = kernel_options + deflang + " rd.live.check",
+ index = index)
+
+ cfg += self.__get_menuentry(entrylabel = isolabel + '-safe',
+ isolabel = isolabel,
+ liveargs = kernel_options + deflang + " nomodeset plymouth.enable=0 noapic acpi=off loglevel=5 vga=788",
+ index = index)
+ break
+ return cfg
+
+
+ def __get_config( self, **args ):
+ cfg = """default=%(isolabel)s
+timeout=%(timeout)d
+#####################################
+
+""" %args
+
+ return cfg
+
+ def _configure_bootcfg(self, isodir):
+ """Set up the configuration for e2k bootloader"""
+ self.__get_kernel_initrd(isodir)
+
+ cfg = self.__get_config(isolabel = self.fslabel,
+ timeout = self._timeout)
+ cfg += self.__get_stanzas(isodir, self.fslabel)
+ cfgf = open(isodir + "/boot.conf", "w")
+ cfgf.write(cfg)
+ cfgf.close()
+
+ def _generate_e2kimg(self, isodir):
+ os.mkdir('img_mount_point')
+ open('e2k.img', "w").truncate(10000 * 50000)
+ # zero is a 'False' for python
+ if not subprocess.call(['mkfs.vfat', 'e2k.img']):
+ for index in range(0, 9):
+ if not os.path.exists("%s/vmlinuz%d" %(isodir, index)):
+ continue
+ if not subprocess.call(['mount', '-o', 'loop', 'e2k.img', 'img_mount_point']):
+ shutil.copyfile('%s/vmlinuz%d' %(isodir, index), 'img_mount_point/vmlinuz%d' %(index) )
+ shutil.copyfile('%s/initrd%d.img' %(isodir, index), 'img_mount_point/initrd%d.img' %(index) )
+ shutil.copyfile('%s/boot.conf' %(isodir), 'img_mount_point/boot.conf' )
+ else:
+ print('Error. Can not mount image')
+ subprocess.call(['umount', 'img_mount_point'])
+ break
+ else:
+ print('Error. Can not format image')
+
+ def _configure_bootloader(self, isodir):
+ self._configure_bootcfg(isodir)
+ self._generate_e2kimg(isodir)
+
arch = dnf.rpm.basearch(hawkey.detect_arch())
if arch in ("i386", "x86_64"):
LiveImageCreator = x86LiveImageCreator
@@ -1509,5 +1677,7 @@ elif arch.startswith(("arm")):
LiveImageCreator = LiveImageCreatorBase
elif arch in ("riscv64",):
LiveImageCreator = LiveImageCreatorBase
+elif arch.startswith(("e2k")):
+ LiveImageCreator = e2kLiveImageCreator
else:
raise CreatorError("Architecture not supported!")

View file

@ -16,6 +16,7 @@ Group: System/Base
URL: https://github.com/livecd-tools/livecd-tools
Source0: https://github.com/livecd-tools/livecd-tools/archive/refs/tags/%{name}-%{version}.tar.gz?/%{name}-%{name}-%{version}.tar.gz
Source1: grub2-everywhere.diff
Source8: e2k-implementation.diff
Source2: it_IT.po
Source3: fr_FR.po
@ -97,11 +98,13 @@ Requires: dumpet
Requires: cryptsetup
Requires: squashfs-tools
Requires: policycoreutils
%ifnarch %{e2k}
Requires: grub2
# shim binaries are copied into the LiveCD, shim of native arch is copied always
# and shim of the secondary arch is copied only if it exists;
# RPM file coloring should make coinstalling shims of different arches possible
Requires: (shim%{_isa} or shim-unsigned%{_isa})
%endif
%ifarch %{x86_64}
Recommends: (shim(x86-32) or shim-unsigned(x86-32))
%endif
@ -145,6 +148,7 @@ Tools for installing Live CD ISOs to different mediums
%prep
%autosetup -p1 -S git_am -n %{name}-%{name}-%{version}
patch -p1 < %{SOURCE1}
patch -p1 < %{SOURCE8}
%build
# Nothing to do