Compare commits
2 Commits
ee1e8e0ce1
...
a4dfae1286
Author | SHA1 | Date |
---|---|---|
David Abdurachmanov | a4dfae1286 | |
David Abdurachmanov | 7913f0ca22 |
|
@ -0,0 +1,84 @@
|
|||
diff --git a/appcreate/appliance.py b/appcreate/appliance.py
|
||||
index c6706cb..6276600 100644
|
||||
--- a/appcreate/appliance.py
|
||||
+++ b/appcreate/appliance.py
|
||||
@@ -47,7 +47,7 @@ class ApplianceImageCreator(ImageCreator):
|
||||
|
||||
"""
|
||||
|
||||
- def __init__(self, ks, name, disk_format, vmem, vcpu, releasever=None, no_compress=False):
|
||||
+ def __init__(self, ks, name, disk_format, vmem, vcpu, releasever=None, no_compress=False, zstd=False, zstd_level=None):
|
||||
"""Initialize a ApplianceImageCreator instance.
|
||||
|
||||
This method takes the same arguments as ImageCreator.__init__()
|
||||
@@ -60,6 +60,8 @@ class ApplianceImageCreator(ImageCreator):
|
||||
self.__disks = {}
|
||||
self.__disk_format = disk_format
|
||||
self.__compress = not no_compress
|
||||
+ self.__zstd = zstd
|
||||
+ self.__zstd_level = zstd_level
|
||||
|
||||
#appliance parameters
|
||||
self.vmem = vmem
|
||||
@@ -657,14 +659,29 @@ class ApplianceImageCreator(ImageCreator):
|
||||
dst = "%s/%s-%s.%s" % (self._outdir, self.name, name, self.__disk_format)
|
||||
|
||||
if self.__compress:
|
||||
- # Compress with xz using 16 MiB block size for seekability
|
||||
- rc = subprocess.call(["xz", "-z", "--block-size=16777216", "-T 0", src])
|
||||
- if rc == 0:
|
||||
- logging.debug("compression successful")
|
||||
- if rc != 0:
|
||||
- raise CreatorError("Unable to compress disk to %s" % self.__disk_format)
|
||||
- src = "%s.xz" % (src)
|
||||
- dst = "%s.xz" % (dst)
|
||||
+ if self.__zstd:
|
||||
+ # Compress with zstd using 16MiB blocks size (for future seekability)
|
||||
+ zstd_cmd = ["zstd", "-z", "--block-size=16777216", "-T0", src]
|
||||
+ # Use custom compression level if specified
|
||||
+ if self.__zstd_level:
|
||||
+ zstd_cmd.append("-%s" % self.__zstd_level)
|
||||
+ zstd_cmd.append(src)
|
||||
+ rc = subprocess.call(zstd_cmd)
|
||||
+ if rc == 0:
|
||||
+ logging.debug("compression successful")
|
||||
+ if rc != 0:
|
||||
+ raise CreatorError("Unable to compress disk to %s, command: %s" % (self.__disk_format, zstd_cmd))
|
||||
+ src = "%s.zst" % (src)
|
||||
+ dst = "%s.zst" % (dst)
|
||||
+ else:
|
||||
+ # Compress with xz using 16 MiB block size for seekability
|
||||
+ rc = subprocess.call(["xz", "-z", "--block-size=16777216", "-T 0", src])
|
||||
+ if rc == 0:
|
||||
+ logging.debug("compression successful")
|
||||
+ if rc != 0:
|
||||
+ raise CreatorError("Unable to compress disk to %s" % self.__disk_format)
|
||||
+ src = "%s.xz" % (src)
|
||||
+ dst = "%s.xz" % (dst)
|
||||
|
||||
logging.debug("moving %s to %s" % (src, dst))
|
||||
shutil.move(src, dst)
|
||||
diff --git a/tools/appliance-creator b/tools/appliance-creator
|
||||
index eef1ede..6a0cf1c 100755
|
||||
--- a/tools/appliance-creator
|
||||
+++ b/tools/appliance-creator
|
||||
@@ -61,6 +61,10 @@ def parse_options(args):
|
||||
help="Disk format (default: raw)")
|
||||
appopt.add_option("", "--no-compress", action="store_true", dest="no_compress", default=False,
|
||||
help="Avoid compressing the image")
|
||||
+ appopt.add_option("", "--zstd", action="store_true", dest="zstd", default=False,
|
||||
+ help="Compress the image using zstd instead of xz")
|
||||
+ appopt.add_option("", "--zstd-level", type="int", dest="zstd_level",
|
||||
+ help="Compress using specified compression level for zstd")
|
||||
parser.add_option_group(appopt)
|
||||
|
||||
|
||||
@@ -134,7 +138,7 @@ def main():
|
||||
if options.name:
|
||||
name = options.name
|
||||
|
||||
- creator = appcreate.ApplianceImageCreator(ks, name, options.disk_format, options.vmem, options.vcpu, releasever=options.version, no_compress=options.no_compress)
|
||||
+ creator = appcreate.ApplianceImageCreator(ks, name, options.disk_format, options.vmem, options.vcpu, releasever=options.version, no_compress=options.no_compress, zstd=options.zstd, zstd_level=options.zstd_level)
|
||||
creator.tmpdir = options.tmpdir
|
||||
creator.checksum = options.checksum
|
||||
|
|
@ -22,8 +22,9 @@ Source0: https://releases.pagure.org/%{name}/%{name}-%{version}.tar.bz2
|
|||
Patch0001: 0001-fstype-is-optional-for-swap-check-mountpoint-also.patch
|
||||
Patch0002: 0001-Leave-more-space-4MB-for-uboot-before-the-first-part.patch
|
||||
|
||||
# Patches for U-Boot RISC-V (riscv64) extlinux support
|
||||
Patch0020: uboot-riscv.patch
|
||||
# NOT upstream
|
||||
# Add support for zstd compression instead of xz (optional)
|
||||
Patch0010: appliance-tools-add-zstd.patch
|
||||
|
||||
# Ensure system deps are installed (rhbz#1409536)
|
||||
Requires: python%{python_pkgversion}-imgcreate >= 1:25.0-2
|
||||
|
@ -33,6 +34,7 @@ Requires: curl rsync kpartx
|
|||
Requires: zlib
|
||||
Requires: qemu-img
|
||||
Requires: xz
|
||||
Requires: zstd
|
||||
Requires: xfsprogs
|
||||
Requires: sssd-client
|
||||
BuildRequires: python%{python_pkgversion}-devel
|
||||
|
@ -68,10 +70,8 @@ rm -rf %{buildroot}%{_datadir}/doc/%{name}
|
|||
%{python_sitelib}/ec2convert/
|
||||
|
||||
%changelog
|
||||
* Sun Aug 18 2019 David Abdurachmanov <david.abdurachmanov@sifive.com> - 009.0-7.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
|
||||
* Wed Oct 02 2019 David Abdurachmanov <david.abdurachmanov@sifive.com> - 009.0-7.0.riscv64
|
||||
- Add support for zstd compression for images (optional)
|
||||
|
||||
* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 009.0-7
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
diff --git a/appcreate/appliance.py b/appcreate/appliance.py
|
||||
index c6706cb..86b4437 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,18 +352,39 @@ class ApplianceImageCreator(ImageCreator):
|
||||
for version in kernels[kernel]:
|
||||
versions.append(version)
|
||||
|
||||
- if int(subprocess.Popen("ls " + self._instroot + "/boot/initramfs* | wc -l", shell=True, stdout=subprocess.PIPE).communicate()[0].decode("utf-8").strip()) > 0:
|
||||
+ # 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/uInitrd* | wc -l", shell=True, stdout=subprocess.PIPE).communicate()[0].decode("utf-8").strip()) > 0:
|
||||
+ # U-Boot wrapped ramdisk
|
||||
+ initrd = "uInitrd"
|
||||
+ initrd_ext = ""
|
||||
+ elif int(subprocess.Popen("ls " + self._instroot + "/boot/initramfs* | wc -l", shell=True, stdout=subprocess.PIPE).communicate()[0].decode("utf-8").strip()) > 0:
|
||||
initrd = "initramfs"
|
||||
+ initrd_ext = ".img"
|
||||
else:
|
||||
initrd = "initrd"
|
||||
+ initrd_ext = ".img"
|
||||
+
|
||||
+ 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)
|
||||
- extlinux += "\tinitrd %s/%s-%s.img\n\n" % (prefix, initrd, v)
|
||||
+ logging.debug("Checking for %s/dtb-%s/" % (self._instroot + prefix, v))
|
||||
+ if os.path.exists("%s/dtb-%s/" % (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%s\n\n" % (prefix, initrd, initrd_ext, v)
|
||||
|
||||
|
||||
logging.debug("Writing extlinux config %s/boot/extlinux/extlinux.conf" % self._instroot)
|
Loading…
Reference in New Issue