[PATCH] add code to handle liveimg --url=file:// as special case
Gene Czarcinski
gczarcinski at ec.rr.com
Tue Nov 4 21:19:47 UTC 2014
This patch addresses the problem in RHBZ#1140358.
The added code checks to see if --url=file:// was specified and,
if it was and if that file exists and if it is not a tarball,
then use the specified file directly rather than downloading
(copying) it.
Note: The file needs to be a squashfs file as created for a Live Install.
---
pyanaconda/packaging/livepayload.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/pyanaconda/packaging/livepayload.py b/pyanaconda/packaging/livepayload.py
index d6db00b..05d1afe 100644
--- a/pyanaconda/packaging/livepayload.py
+++ b/pyanaconda/packaging/livepayload.py
@@ -281,6 +281,28 @@ class LiveImageKSPayload(LiveImagePayload):
to grab the image. Download it to sysroot and provide feedback
during the download (using urlgrabber callback).
"""
+ # Handle the special case of liveimg --url=file:// and do not
+ # download. Instead, use the file directly.
+ test_special = not self.is_tarfile and self.data.method.url.startswith("file://")
+ test_special = test_special and os.path.exists(self.data.method.url[7:])
+ if test_special:
+ log.info("LiveImageKSPayload.preinstall handling special case of file://")
+ if not os.path.exists(IMAGE_DIR):
+ os.makedirs(IMAGE_DIR, 0O755)
+ blivet.util.mount(self.data.method.url[7:], IMAGE_DIR,
+ fstype="auto", options="ro")
+ if os.path.exists(IMAGE_DIR+"/LiveOS"):
+ img_files = glob.glob(IMAGE_DIR+"/LiveOS/*.img")
+ if img_files:
+ img_file = os.path.basename(sorted(img_files)[0])
+ blivet.util.mount(IMAGE_DIR+"/LiveOS/"+img_file,
+ INSTALL_TREE, fstype="auto", options="ro")
+ source = os.statvfs(INSTALL_TREE)
+ self.source_size = source.f_frsize * (source.f_blocks - source.f_bfree)
+ log.info("LiveImageKSPayload.preinstall for file:// is done")
+ return
+ else:
+ blivet.util.umount(IMAGE_DIR)
# Setup urlgrabber and call back to download image to sysroot
progress = URLGrabberProgress()
ugopts = {"ssl_verify_peer": not self.data.method.noverifyssl,
@@ -358,7 +380,9 @@ class LiveImageKSPayload(LiveImagePayload):
"""
# If it doesn't look like a tarfile use the super's install()
if not self.is_tarfile:
+ log.debug("LiveImageKSPayload.install starting")
super(LiveImageKSPayload, self).install()
+ log.debug("LiveImageKSPayload.install done")
return
# Use 2x the archive's size to estimate the size of the install
--
1.9.3
More information about the anaconda-patches
mailing list