commit d66e1236d7017bed5607e197c739e9bc8a56bc7f Author: Dave Riches dcr226@fedorapeople.org Date: Fri Jan 7 19:03:16 2011 +0000
builds filesystem for both lives and dvds, creates iso. This time i've added if __name__==__main__ so it functions the same as the bash script. needs testing, I'm tired
multiboot-media-creator.py | 36 ++++++++++++++++++++++++++++++------ 1 files changed, 30 insertions(+), 6 deletions(-) --- diff --git a/multiboot-media-creator.py b/multiboot-media-creator.py index 2285a28..4aa8cab 100644 --- a/multiboot-media-creator.py +++ b/multiboot-media-creator.py @@ -47,12 +47,13 @@ based on a given type""" isos.append(os.path.basename(i)) return isos
-def makedirs(iso): +def makedirs(iso,filesys): BN=iso.strip(".iso") os.makedirs(os.path.join(mytemp, BN,"boot")) -# os.makedirs(os.path.join(mytemp, BN,"images")) os.makedirs(os.path.join(mytemp, BN,"CHECKSUM")) os.makedirs(os.path.join(mytemp, BN,"tmp")) + if filesys=="dvd": + os.makedirs(os.path.join(mytemp, BN,"images")) print mytemp
def mount_iso(iso): @@ -68,7 +69,6 @@ def removetemps(): shutil.rmtree(mytemp)
def make_iso(): - os.makedirs(os.path.join(mytemp, "boot/grub")) shutil.copy2('/usr/share/grub/i386-redhat/stage2_eltorito', os.path.join(mytemp, "boot/grub/")) mkisocmd='mkisofs -R -v -V "Multi-Boot" -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -allow-limited-size -o Multi-Boot.iso %s' % mytemp os.system(mkisocmd) @@ -78,7 +78,7 @@ def build_filesystem(): for i in getisos(path, "live"): print "Building filesystem for: %s" % i BN=i.strip(".iso") - makedirs(i) + makedirs(i, "live") tree_path=mount_iso(i) shutil.copytree(tree_path,os.path.join(mytemp, BN,"images/")) umount_iso(i) @@ -87,12 +87,36 @@ def build_filesystem(): try: for i in getisos(path, "dvd"): print "Building filesystem for: %s" % i - BN=i.strip(".iso") - makedirs(i) + BN=os.path.basename(i.strip(".iso")) + makedirs(i, "dvd") tree_path=mount_iso(i) shutil.copy2(os.path.join(tree_path, "isolinux/vmlinuz"),os.path.join(mytemp, BN,"boot/")) shutil.copy2(os.path.join(tree_path, "isolinux/initrd.img"),os.path.join(mytemp, BN,"boot/")) + shutil.copy2(os.path.join(tree_path, "images/install.img"),os.path.join(mytemp, BN,"images/")) + shutil.copy2(os.path.join(path, i),os.path.join(mytemp, BN)) umount_iso(i) except: print "No dvd isos found" + os.makedirs(os.path.join(mytemp, "boot/grub")) print "Done!" + +def create_grub(): + grub=open(os.path.join(mytemp, "boot/grub/grub.conf"), "w") + grub.write("splashimage=/boot/grub/splash.xpm.gz\ntimeout=10\ndefault=0\n\n") + for lives in getisos(path,"live"): + BN=lives.strip(".iso") + grub.write("title %s\n" % BN) + grub.write(" kernel /%s/images/isolinux/vmlinuz0 root=live:LABEL=Multi-Boot live_dir=/%s/images/LiveOS/ rootfstype=auto ro liveimg quiet rhgb\n" % (BN,BN)) + grub.write(" initrd /%s/images/isolinux/initrd0.img\n\n" % BN) + for dvds in getisos(path,"dvd"): + BN=dvds.strip(".iso") + grub.write("title %s\n" % BN) + grub.write(" kernel /%s/boot/vmlinuz repo=hd:LABEL=Multi-Boot:/%s/\n" % (BN,BN)) + grub.write(" initrd /%s/boot/initrd.img\n\n" % BN) + grub.close() + +if __name__=="__main__": + build_filesystem() + create_grub() + make_iso() + removetemps()
multiboot-media-creator@lists.fedorahosted.org