livemedia-creator: add location option

--location specifies an iso directory tree to be used by virt-install
instead of the iso. This allows you to update the initrd in the tree for
debugging.

virt-install uses the images/pxeboot/ directory for initrd.img and
vmlinux.

An iso is still required for the LiveOS/squashfs.img stage2 file.
This commit is contained in:
Brian C. Lane 2012-08-16 15:03:58 -07:00
parent 42e3d27ff1
commit 91ff02eae3

View File

@ -170,15 +170,27 @@ class IsoMountpoint(object):
vmlinuz and initrd.img files exist vmlinuz and initrd.img files exist
Check the iso for a LiveOS directory and set a flag. Check the iso for a LiveOS directory and set a flag.
Extract the iso's label. Extract the iso's label.
initrd_path can be used to point to a boot.iso tree with a newer
initrd.img than the iso has. The iso is still used for stage2.
""" """
def __init__( self, iso_path ): def __init__( self, iso_path, initrd_path=None ):
""" iso_path is the path to a boot.iso
initrd_path overrides mounting the iso for access to
initrd and vmlinuz.
"""
self.label = None self.label = None
self.iso_path = iso_path self.iso_path = iso_path
self.mount_dir = tempfile.mkdtemp() self.initrd_path = initrd_path
if not self.mount_dir:
raise Exception("Error creating temporary directory")
execWithRedirect("mount", ["-o", "loop", self.iso_path, self.mount_dir]) if not self.initrd_path:
self.mount_dir = tempfile.mkdtemp()
if not self.mount_dir:
raise Exception("Error creating temporary directory")
execWithRedirect("mount", ["-o", "loop", self.iso_path, self.mount_dir])
else:
self.mount_dir = self.initrd_path
self.kernel = self.mount_dir+"/isolinux/vmlinuz" self.kernel = self.mount_dir+"/isolinux/vmlinuz"
self.initrd = self.mount_dir+"/isolinux/initrd.img" self.initrd = self.mount_dir+"/isolinux/initrd.img"
@ -200,8 +212,9 @@ class IsoMountpoint(object):
self.get_iso_label() self.get_iso_label()
def umount( self ): def umount( self ):
execWithRedirect("umount", [self.mount_dir]) if not self.initrd_path:
os.rmdir( self.mount_dir ) execWithRedirect("umount", [self.mount_dir])
os.rmdir( self.mount_dir )
def get_iso_label( self ): def get_iso_label( self ):
""" """
@ -580,6 +593,10 @@ if __name__ == '__main__':
parser.add_argument( "--armplatform", parser.add_argument( "--armplatform",
help="the platform to use when creating images for ARM, " help="the platform to use when creating images for ARM, "
"i.e., highbank, mvebu, omap, tegra, etc." ) "i.e., highbank, mvebu, omap, tegra, etc." )
parser.add_argument( "--location", default=None, type=os.path.abspath,
help="location of iso directory tree with initrd.img "
"and vmlinuz. Used to run virt-install with a "
"newer initrd than the iso." )
parser.add_argument( "--logfile", default="./livemedia.log", parser.add_argument( "--logfile", default="./livemedia.log",
type=os.path.abspath, type=os.path.abspath,
@ -771,7 +788,7 @@ if __name__ == '__main__':
loop_detach(get_loop_name(disk_img)) loop_detach(get_loop_name(disk_img))
else: else:
iso_mount = IsoMountpoint( opts.iso ) iso_mount = IsoMountpoint( opts.iso, opts.location )
log_monitor = LogMonitor( install_log ) log_monitor = LogMonitor( install_log )
kernel_args = "" kernel_args = ""