<font size="2" face="'courier new', monospace">I wasn't expecting the alpha to get committed yet, so here is a patch:</font><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: 'courier new', monospace; ">Support attached LiveOS devices as well as image files for LiveOS editing.</span></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: 'courier new', monospace; "><div>
Adjust naming of iso, log the iso name, adjust usage text, restore script</div><div>option.</div></span><div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div><font size="2" face="'courier new', monospace"><div>
Author: Frederick Grose <<a href="mailto:fgrose@gmail.com">fgrose@gmail.com</a>></div><div>Date: Tue Feb 15 22:27:14 2011 -0500</div><div><br></div><div> Support attached LiveOS devices as well as image files for LiveOS editing.</div>
<div> Adjust naming of iso, log the iso name, adjust usage text, restore script</div><div> option.</div><div><br></div><div>diff --git a/tools/edit-livecd b/tools/edit-livecd</div><div>index 79a6061..659cfae 100755</div>
<div>--- a/tools/edit-livecd</div><div>+++ b/tools/edit-livecd</div><div>@@ -72,8 +72,9 @@ class LiveImageEditor(LiveImageCreator):</div><div> self._include = None</div><div> """A string of file or directory paths to include in __copy_img_root."""</div>
<div> </div><div>- self._builder = "someone"</div><div>- """The name of the Remix builder for _branding."""</div><div>+ self._builder = os.getlogin()</div><div>
+ """The name of the Remix builder for _branding.</div><div>+ Default = os.getlogin()"""</div><div> </div><div> self.compress_type = None</div><div> """mksquashfs compressor to use. Use 'None' to force reading of the</div>
<div>@@ -119,21 +120,7 @@ class LiveImageEditor(LiveImageCreator):</div><div> rtn = self._LoopImageCreator__imagedir + "/ext3fs.img"</div><div> return rtn</div><div> _image = property(__get_image)</div>
<div>- """The location of the image file or filesystem root."""</div><div>-</div><div>- def _get_fstype(self, filesystem):</div><div>- dev_null = os.open('/dev/null', os.O_WRONLY)</div>
<div>- args = ['/sbin/blkid', '-s', 'TYPE', '-o', 'value', filesystem]</div><div>- try:</div><div>- fs_type = subprocess.Popen(args,</div><div>- stdout=subprocess.PIPE,</div>
<div>- stderr=dev_null).communicate()[0]</div><div>- except IOError, e:</div><div>- raise CreatorError("Failed to determine fsimage TYPE: %s" % e )</div><div>
- finally:</div>
<div>- os.close(dev_null)</div><div>-</div><div>- return fs_type.rstrip()</div><div>+ """The location of the filesystem image file."""</div><div> </div><div> def _get_fslabel(self):</div>
<div> dev_null = os.open("/dev/null", os.O_WRONLY)</div><div>@@ -211,11 +198,11 @@ class LiveImageEditor(LiveImageCreator):</div><div> </div><div> if self.clone:</div><div> # Need to clone base_on into ext3fs.img at this point</div>
<div>- self._base_on(base_on)</div><div> self._LoopImageCreator__fslabel = <a href="http://self.name">self.name</a></div><div>+ self._base_on(base_on)</div><div> else:</div><div>
LiveImageCreator._base_on(self, base_on)</div>
<div>- self._LoopImageCreator__fstype = self._get_fstype(self._image)</div><div>+ self._LoopImageCreator__fstype = get_fsvalue(self._image, 'TYPE')</div><div> self._get_fslabel()</div>
<div> </div><div> self.fslabel = self._LoopImageCreator__fslabel</div><div>@@ -250,7 +237,6 @@ class LiveImageEditor(LiveImageCreator):</div><div> self.__copy_img_root(base_on)</div><div> self._brand(self._builder)</div>
<div> </div><div>-</div><div> def _base_on(self, base_on):</div><div> """Clone the running LiveOS image as the basis for the new image."""</div><div> </div><div>@@ -353,6 +339,7 @@ class LiveImageEditor(LiveImageCreator):</div>
<div> """Adjust the image branding to show its variation from original</div><div> source by builder and build date."""</div><div> </div><div>+ self.fslabel = <a href="http://self.name">self.name</a></div>
<div> dt = time.strftime('%d-%b-%Y')</div><div> </div><div> lst = ['isolinux/isolinux.cfg', 'syslinux/syslinux.cfg',</div><div>@@ -371,12 +358,11 @@ class LiveImageEditor(LiveImageCreator):</div>
<div> for line in cfgf:</div><div> i = line.find('Welcome to ')</div><div> if i > -1:</div><div>- <a href="http://self.name">self.name</a> = line[i+11:-2]</div>
<div>+ release = line[i+11:-2]</div><div> break</div><div> cfgf.close()</div><div> </div><div>- ntext = dt.translate(None,</div><div>- '-') + '-' + _builder + '-Remix-' + <a href="http://self.name">self.name</a></div>
<div>+ ntext = dt.translate(None, '-') + '-' + _builder + '-Remix-' + release</div><div> </div><div> # Update fedora-release message with Remix details.</div><div> releasefiles = '/etc/fedora-release, /etc/generic-release'</div>
<div>@@ -392,8 +378,8 @@ class LiveImageEditor(LiveImageCreator):</div><div> raise CreatorError("Failed to open or write '%s' : %s" %</div><div> (<a href="http://f.name">f.name</a>, e))</div>
<div> </div><div>- <a href="http://self.name">self.name</a> = ntext</div><div>- self.fslabel += '-' + os.uname()[4] + '-' + time.strftime('%Y%m%d.%H')</div><div>+ self._releasefile = ntext</div>
<div>+ <a href="http://self.name">self.name</a> += '-' + os.uname()[4] + '-' + time.strftime('%Y%m%d.%H%M')</div><div> </div><div> </div><div> def _configure_bootloader(self, isodir):</div>
<div>@@ -411,8 +397,8 @@ class LiveImageEditor(LiveImageCreator):</div><div> os.rename(src, cfgf)</div><div> </div><div> args = ['/bin/sed', '-i',</div><div>- '-e', 's/Welcome to .*/Welcome to ' + <a href="http://self.name">self.name</a> + '!/',</div>
<div>- '-e', 's/root=[^ ]*/root=live:CDLABEL=' + self.fslabel + '/',</div><div>+ '-e', 's/Welcome to .*/Welcome to ' + self._releasefile + '!/',</div>
<div>+ '-e', 's/root=[^ ]*/root=live:CDLABEL=' + <a href="http://self.name">self.name</a> + '/',</div><div> '-e', 's/rootfstype=[^ ]* [^ ]*/rootfstype=auto ro/',</div>
<div> '-e', 's/liveimg .* quiet/liveimg quiet/', cfgf]</div><div> </div><div>@@ -430,20 +416,21 @@ class LiveImageEditor(LiveImageCreator):</div><div> os.close(dev_null)</div><div>
</div><div> def parse_options(args):</div><div>- parser = optparse.OptionParser(usage = "\n %prog [-n=<name>]"</div><div>- "\n [-o=<output>]"</div>
<div>- "\n [-s=<script.sh>]"</div><div>- "\n [-t=<tmpdir>]"</div><div>- "\n [-e=<excludes>]"</div>
<div>- "\n [-f=<exclude-file>]"</div><div>- "\n [-i=<includes>]"</div><div>- "\n [-r=<releasefile>]"</div>
<div>- "\n [-b=<builder>]"</div><div>- "\n [--clone]"</div><div>- "\n [-c=<compress_type>]"</div>
<div>- "\n [--skip-compression]"</div><div>- "\n [--skip-minimize]"</div><div>- "\n <LIVEIMG.src>")</div>
<div>+ parser = optparse.OptionParser(usage = """</div><div>+ %prog [-n=<name>]</div><div>+ [-o=<output>]</div><div>+ [-s=<script.sh>]</div>
<div>+ [-t=<tmpdir>]</div><div>+ [-e=<excludes>]</div><div>+ [-f=<exclude-file>]</div><div>+ [-i=<includes>]</div>
<div>+ [-r=<releasefile>]</div><div>+ [-b=<builder>]</div><div>+ [--clone]</div><div>+ [-c=<compress_type>]</div><div>
+ [--skip-compression]</div>
<div>+ [--skip-minimize]</div><div>+ <LIVEIMG.src>""")</div><div> </div><div> parser.add_option("-n", "--name", type="string", dest="name",</div>
<div> help="name of new LiveOS (don't include .iso, it will "</div><div>@@ -476,7 +463,8 @@ def parse_options(args):</div><div> parser.add_option("-r", "--releasefile", type="string", dest="releasefile",</div>
<div> help="Specify release file/s for branding.")</div><div> </div><div>- parser.add_option("-b", "--builder", type="string", dest="builder",</div>
<div>+ parser.add_option("-b", "--builder", type="string",</div><div>+ dest="builder", default=os.getlogin(),</div><div> help="Specify the builder of a Remix.")</div>
<div> </div><div> parser.add_option("", "--clone", action="store_true", dest="clone",</div><div>@@ -507,6 +495,20 @@ def parse_options(args):</div><div> </div><div> return (args[0], options)</div>
<div> </div><div>+def get_fsvalue(filesystem, tag):</div><div>+ dev_null = os.open('/dev/null', os.O_WRONLY)</div><div>+ args = ['/sbin/blkid', '-s', tag, '-o', 'value', filesystem]</div>
<div>+ try:</div><div>+ fs_type = subprocess.Popen(args,</div><div>+ stdout=subprocess.PIPE,</div><div>+ stderr=dev_null).communicate()[0]</div><div>+ except IOError, e:</div>
<div>+ raise CreatorError("Failed to determine fs %s: %s" % value, e )</div><div>+ finally:</div><div>+ os.close(dev_null)</div><div>+</div><div>+ return fs_type.rstrip()</div><div>+</div><div>
def rebuild_iso_symlinks(isodir):</div><div> # remove duplicate files and rebuild symlinks to reduce iso size</div><div> efi_vmlinuz = "%s/EFI/boot/vmlinuz0" % isodir</div><div>@@ -528,7 +530,9 @@ def main():</div>
<div> print >> sys.stderr, "You must run edit-liveos as root"</div><div> return 1</div><div> </div><div>- if <a href="http://options.name">options.name</a> and <a href="http://options.name">options.name</a> != os.path.basename(LiveOS):</div>
<div>+ if stat.S_ISBLK(os.stat(LiveOS).st_mode):</div><div>+ name = get_fsvalue(LiveOS, 'LABEL') + '.edited'</div><div>+ elif <a href="http://options.name">options.name</a> and <a href="http://options.name">options.name</a> != os.path.basename(LiveOS):</div>
<div> name = <a href="http://options.name">options.name</a></div><div> else:</div><div> name = os.path.basename(LiveOS) + ".edited"</div><div>@@ -537,6 +541,8 @@ def main():</div><div> output = options.output</div>
<div> else:</div><div> output = os.path.dirname(LiveOS)</div><div>+ if output == '/dev':</div><div>+ output = options.tmpdir</div><div> </div><div> editor = LiveImageEditor(name)</div>
<div> editor._exclude = options.exclude</div><div>@@ -553,10 +559,17 @@ def main():</div><div> try:</div><div> editor.mount(LiveOS, cachedir = None)</div><div> editor._configure_bootloader(editor._LiveImageCreatorBase__isodir)</div>
<div>- <a href="http://editor.name">editor.name</a> = editor.fslabel</div><div>+ if options.script:</div><div>+ print "Running edit script '%s'" % options.script</div><div>+ editor._run_script(options.script)</div>
<div>+ else:</div><div>+ print "Launching shell. Exit to continue."</div><div>+ print "----------------------------------"</div><div>+ editor.launch_shell()</div>
<div> rebuild_iso_symlinks(editor._LiveImageCreatorBase__isodir)</div><div> editor.unmount()</div><div> editor.package(output)</div><div>+ <a href="http://logging.info">logging.info</a>("%s.iso saved to %s" % (<a href="http://editor.name">editor.name</a>, output))</div>
<div> except CreatorError, e:</div><div> logging.error(u"Error editing LiveOS : %s" % e)</div><div> return 1</div></font></div>