commit b6aae469b22647950b69c6c111acfb6029518073
Author: Dave Riches <dcr226(a)fedorapeople.org>
Date: Fri Jan 7 13:05:38 2011 +0000
refactoring and added build_filesystem()
multiboot-media-creator.py | 42 +++++++++++++++++++++++++++++++++++-------
1 files changed, 35 insertions(+), 7 deletions(-)
---
diff --git a/multiboot-media-creator.py b/multiboot-media-creator.py
index 6a7f18b..7ab78b1 100644
--- a/multiboot-media-creator.py
+++ b/multiboot-media-creator.py
@@ -30,32 +30,38 @@ path=os.getcwd() # ok, so this will need to change
mytemp=tempfile.mkdtemp(suffix=".mmc")
def getisos(isopath,isotype):
+ """getisos returns a list of isos inside a specific path
+based on a given type"""
isopath=os.path.join(isopath, "*.iso")
+ isos=[]
for i in glob.glob(isopath):
os.system("mount -o loop %s %s &>/dev/null" % (i, mytemp))
if os.path.isfile(os.path.join(mytemp+"/.discinfo")) == True:
info="dvd"
+ print i+" is dvd"
else:
info="live"
+ print i+" is live"
os.system("umount %s &>/dev/null" % i)
if info==isotype:
- print i,info
+ isos.append(os.path.basename(i))
+ return isos
def makedirs(iso):
- BN=iso.strip(".iso"+path)
+ 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,"images"))
os.makedirs(os.path.join(mytemp, BN,"CHECKSUM"))
os.makedirs(os.path.join(mytemp, BN,"tmp"))
print mytemp
def mount_iso(iso):
- BN=iso.strip(".iso"+path)
+ BN=iso.strip(".iso")
os.system("mount -o loop %s %s" % (iso, os.path.join(mytemp, BN,
"tmp")))
return os.path.join(mytemp, BN, "tmp")
def umount_iso(iso):
- BN=iso.strip(".iso"+path)
+ BN=iso.strip(".iso")
os.system("umount %s" % (iso))
def removetemps():
@@ -72,7 +78,7 @@ def mount_and_steal():
then mount the isos, then steal the kernels, then un-mount the isos. You get the
idea"""
for i in getisos(path):
makedirs(i)
- BN=i.strip(".iso"+path)
+ BN=os.path.basename(i)
mount_path=mount_iso(i)
print "Mounted iso: %s" % i
print "Mount point is: %s" % mount_path
@@ -82,4 +88,26 @@ then mount the isos, then steal the kernels, then un-mount the isos.
You get the
print "Un-mounted iso: %s" % i
make_iso()
-
+def build_filesystem():
+ try:
+ for i in getisos(path, "live"):
+ print "Building filesystem for: %s" % i
+ BN=i.strip(".iso")
+ makedirs(i)
+ tree_path=mount_iso(i)
+ shutil.copytree(tree_path,os.path.join(mytemp, BN,"images/"))
+ umount_iso(i)
+ except:
+ print "No live isos found"
+ try:
+ for i in getisos(path, "dvd"):
+ print "Building filesystem for: %s" % i
+ BN=i.strip(".iso")
+ makedirs(i)
+ 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/"))
+ umount_iso(i)
+ except:
+ print "No dvd isos found"
+ print "Done!"