Changes for U-Boot RISC-V extlinux support

- Allow user to override partition layout (msdos default) via clearpart
  kickstart command.
- Check boot prefix (usually /boot) for DTB directory. If does not exist
  skip fdtdir entry in extlinux.conf
- Detect U-Boot uImage / uInitrd images for extlinux.conf

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
This commit is contained in:
David Abdurachmanov 2019-03-30 21:21:18 +01:00
parent 32d524791c
commit d1dccea49d
Signed by: davidlt
GPG Key ID: 7108702C938B13C1
2 changed files with 77 additions and 1 deletions

View File

@ -12,7 +12,7 @@
Name: appliance-tools
Summary: Tools for building Appliances
Version: 009.0
Release: 5%{?dist}
Release: 5.0.riscv64%{?dist}
License: GPLv2
URL: https://pagure.io/appliance-tools
@ -21,6 +21,9 @@ Source0: https://releases.pagure.org/%{name}/%{name}-%{version}.tar.bz2
# Patches backported from upstream
Patch0001: 0001-fstype-is-optional-for-swap-check-mountpoint-also.patch
# Patches for U-Boot RISC-V (riscv64) extlinux support
Patch0020: uboot-riscv.patch
# Ensure system deps are installed (rhbz#1409536)
Requires: python%{python_pkgversion}-imgcreate >= 1:25.0-2
Requires: python%{python_pkgversion}-progress
@ -64,6 +67,11 @@ rm -rf %{buildroot}%{_datadir}/doc/%{name}
%{python_sitelib}/ec2convert/
%changelog
* Sat Mar 30 2019 David Abdurachmanov <david.abdurachmanov@gmail.com> - 009.0-5.0.riscv64
- Allow user to override partition layout (clearpart kickstart command)
- Detect if DTB is available in boot prefix (usually /boot) for extlinux.conf
- Detect uImage / uInitrd for extlinux.conf
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 009.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

68
uboot-riscv.patch Normal file
View File

@ -0,0 +1,68 @@
diff --git a/appcreate/appliance.py b/appcreate/appliance.py
index c6706cb..b90d6da 100644
--- a/appcreate/appliance.py
+++ b/appcreate/appliance.py
@@ -169,7 +169,7 @@ class ApplianceImageCreator(ImageCreator):
packages = kickstart.get_packages(self.ks)
# make this the default
partition_layout = 'msdos'
- # set bootloader only if it is enabled and use user specified partition_layout
+ # set bootloader only if it is enabled
if ((not hasattr(self.ks.handler.bootloader, "disabled")) or
(hasattr(self.ks.handler.bootloader, "disabled") and self.ks.handler.bootloader.disabled is False)):
# check for extlinux in kickstart then grub2 and falling back to grub
@@ -188,11 +188,11 @@ class ApplianceImageCreator(ImageCreator):
self.bootloader = 'grub'
else:
logging.warning("WARNING! grub package not found.")
- else:
- # user explicitly disabled bootloader (i.e. not part of disk image)
- if hasattr(self.ks.handler.clearpart, "disklabel"):
- logging.debug("Using user set default disk label: {}".format(self.ks.handler.clearpart.disklabel))
- partition_layout = self.ks.handler.clearpart.disklabel
+
+ # user explicitly selected partition layout thus overrride the current selected
+ if hasattr(self.ks.handler.clearpart, "disklabel"):
+ logging.debug("Using user set default disk label: {}".format(self.ks.handler.clearpart.disklabel))
+ partition_layout = self.ks.handler.clearpart.disklabel
self.__instloop = PartitionedMount(self.__disks,
self._instroot,
@@ -352,17 +352,35 @@ class ApplianceImageCreator(ImageCreator):
for version in kernels[kernel]:
versions.append(version)
+ # Find kernel filename
+ if int(subprocess.Popen("ls " + self._instroot + "/boot/uImage* | wc -l", shell=True, stdout=subprocess.PIPE).communicate()[0].decode("utf-8").strip()) > 0:
+ # U-Boot wrapped kernel
+ kernelfn = "uImage"
+ else:
+ kernelfn = "vmlinuz"
+
+ logging.debug("Found kernel filename: %s" % kernelfn)
+
+ # Find ramdisk filename
if int(subprocess.Popen("ls " + self._instroot + "/boot/initramfs* | wc -l", shell=True, stdout=subprocess.PIPE).communicate()[0].decode("utf-8").strip()) > 0:
initrd = "initramfs"
+ elif int(subprocess.Popen("ls " + self._instroot + "/boot/uInitrd* | wc -l", shell=True, stdout=subprocess.PIPE).communicate()[0].decode("utf-8").strip()) > 0:
+ # U-Boot wrapped ramdisk
+ initrd = "uInitrd"
else:
initrd = "initrd"
+ logging.debug("Found ramdisk filename: %s" % initrd)
+
for v in versions:
extlinux += "label %s (%s)\n" % (self.name, v)
- extlinux += "\tkernel %s/vmlinuz-%s\n" % (prefix, v)
+ extlinux += "\tkernel %s/%s-%s\n" % (prefix, kernelfn, v)
extlinux += "\tappend ro root=%s %s\n" % (rootdev, options)
if 'extlinux-bootloader' in packages:
- extlinux += "\tfdtdir %s/dtb-%s/\n" % (prefix, v)
+ logging.debug("Checking for %s/dtb-%s/" % (self.self._instroot + prefix, v))
+ if os.path.exists("%s/dtb-%s/" % (self.self._instroot + prefix, v)):
+ logging.debug("Found, adding fdtdir entry to extlinux.conf")
+ extlinux += "\tfdtdir %s/dtb-%s/\n" % (prefix, v)
extlinux += "\tinitrd %s/%s-%s.img\n\n" % (prefix, initrd, v)