The following patch will support better user feedback for customization scripts, such as edit-livecd.
commit 44cdc19b436008f03af3c1c4f5c82fa0ce8a26e6 Author: Frederick Grose fgrose@sugarlabs.org Date: Sat Sep 17 12:35:03 2011 -0400
Enable resize and squashing progress reporting option.
Provide optional parameter to package(), _stage_final_image(), and mksquashfs() and 'show-squashing' code to mksquashfs() to permit progress reporting to the terminal. Insert the '-p' option for percentage completion reporting in the resize2fs call arguments.
diff --git a/imgcreate/creator.py b/imgcreate/creator.py index deb9d95..a6a1b39 100644 --- a/imgcreate/creator.py +++ b/imgcreate/creator.py @@ -729,7 +729,7 @@ class ImageCreator(object): """ subprocess.call(["/bin/bash"], preexec_fn = self._chroot)
- def package(self, destdir = "."): + def package(self, destdir = ".", ops=None): """Prepares the created image for final delivery.
In its simplest form, this method merely copies the install root to the @@ -740,8 +740,11 @@ class ImageCreator(object): destdir -- the directory into which the final image should be moved; this defaults to the current directory.
+ ops -- options, e.g., 'show-squashing', passed to subsequent + procedures. + """ - self._stage_final_image() + self._stage_final_image(ops)
for f in os.listdir(self._outdir): shutil.move(os.path.join(self._outdir, f), diff --git a/imgcreate/fs.py b/imgcreate/fs.py index a387f51..69fb5f1 100644 --- a/imgcreate/fs.py +++ b/imgcreate/fs.py @@ -70,7 +70,7 @@ def squashfs_compression_type(sqfs_img): break return compress_type
-def mksquashfs(in_img, out_img, compress_type): +def mksquashfs(in_img, out_img, compress_type, ops=None): # Allow gzip to work for older versions of mksquashfs if compress_type == "gzip": args = ["/sbin/mksquashfs", in_img, out_img] @@ -80,11 +80,18 @@ def mksquashfs(in_img, out_img, compress_type): if not sys.stdout.isatty(): args.append("-no-progress")
- ret = call(args) + if ops == 'show-squashing': + p = subprocess.Popen(args, stdout=None, stderr=subprocess.STDOUT) + p.wait() + ret = p.returncode + else: + ret = call(args) + if ret != 0: raise SquashfsError("'%s' exited with error (%d)" % (string.join(args, " "), ret))
+ def resize2fs(fs, size = None, minimal = False, tmpdir = "/tmp"): if minimal and size is not None: raise ResizeError("Can't specify both minimal and a size for resize!") @@ -94,7 +101,7 @@ def resize2fs(fs, size = None, minimal = False, tmpdir = "/tmp"): e2fsck(fs)
logging.info("resizing %s" % (fs,)) - args = ["/sbin/resize2fs", fs] + args = ["/sbin/resize2fs", '-p', fs] if minimal: args.append("-M") else: diff --git a/imgcreate/live.py b/imgcreate/live.py index 721b609..7aff50d 100755 --- a/imgcreate/live.py +++ b/imgcreate/live.py @@ -320,7 +320,7 @@ class LiveImageCreatorBase(LoopImageCreator):
subprocess.call([implantisomd5, iso])
- def _stage_final_image(self): + def _stage_final_image(self, ops=None): try: makedirs(self.__ensure_isodir() + "/LiveOS")
@@ -343,7 +343,7 @@ class LiveImageCreatorBase(LoopImageCreator): "LiveOS", "ext3fs.img")) mksquashfs(os.path.dirname(self._image), self.__isodir + "/LiveOS/squashfs.img", - self.compress_type) + self.compress_type, ops) if os.stat(self.__isodir + "/LiveOS/squashfs.img").st_size
= 4*1024*1024*1024:
self._isofstype = "udf" logging.warn("Switching to UDF due to size of LiveOS/squashfs.img")
livecd@lists.fedoraproject.org