Joey Boggs
2010-Feb-19 19:25 UTC
[Ovirt-devel] [PATCH] Help reduce size of iso by symlinking initrd's from isolinux/ and EFI/boot if md5's match
116M ovirt-node-image/ovirt-node-image.iso 119M ovirt-node-image.iso.edited.iso --- edit-livecd.py | 24 +++++++++++++++++++++++- 1 files changed, 23 insertions(+), 1 deletions(-) diff --git a/edit-livecd.py b/edit-livecd.py index 279b225..ebcb7a6 100644 --- a/edit-livecd.py +++ b/edit-livecd.py @@ -26,7 +26,7 @@ import shutil import subprocess import optparse import logging - +import hashlib from imgcreate.debug import * from imgcreate.fs import * from imgcreate.live import * @@ -310,6 +310,28 @@ def main(): print "Launching shell. Exit to continue." print "----------------------------------" editor.launch_shell() + # reduce iso size by symlinking initrd's if they match + efi_initrd = "%s/EFI/boot/initrd0.img" % editor._LiveImageCreatorBase__isodir + isolinux_initrd = "%s/isolinux/initrd0.img" % editor._LiveImageCreatorBase__isodir + + def initrd_check(initrd_file): + m = hashlib.md5() + f = open(initrd_file,"r") + while 1: + chunk = f.read(65536) + if not chunk: + break + m.update(chunk) + checksum = m.hexdigest() + return checksum + try: + efi_initrd_csum = initrd_check(efi_initrd) + isolinux_initrd_csum = initrd_check(isolinux_initrd) + if efi_initrd_csum == isolinux_initrd_csum: + os.remove(efi_initrd) + os.symlink(isolinux_initrd,efi_initrd) + except: + pass editor.unmount() editor.package(output) except CreatorError, e: -- 1.6.6