<font size="2" face="&#39;courier new&#39;, monospace">I wasn&#39;t expecting the alpha to get committed yet, so here is a patch:</font><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, monospace; "><br>

</span></div><div><span class="Apple-style-span" style="font-family: &#39;courier new&#39;, 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: &#39;courier new&#39;, 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="&#39;courier new&#39;, monospace"><br></font></div><div><font size="2" face="&#39;courier new&#39;, monospace"><div>

Author: Frederick Grose &lt;<a href="mailto:fgrose@gmail.com">fgrose@gmail.com</a>&gt;</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>         &quot;&quot;&quot;A string of file or directory paths to include in __copy_img_root.&quot;&quot;&quot;</div>

<div> </div><div>-        self._builder = &quot;someone&quot;</div><div>-        &quot;&quot;&quot;The name of the Remix builder for _branding.&quot;&quot;&quot;</div><div>+        self._builder = os.getlogin()</div><div>

+        &quot;&quot;&quot;The name of the Remix builder for _branding.</div><div>+        Default = os.getlogin()&quot;&quot;&quot;</div><div> </div><div>         self.compress_type = None</div><div>         &quot;&quot;&quot;mksquashfs compressor to use. Use &#39;None&#39; to force reading of the</div>

<div>@@ -119,21 +120,7 @@ class LiveImageEditor(LiveImageCreator):</div><div>         rtn = self._LoopImageCreator__imagedir + &quot;/ext3fs.img&quot;</div><div>         return rtn</div><div>     _image = property(__get_image)</div>

<div>-    &quot;&quot;&quot;The location of the image file or filesystem root.&quot;&quot;&quot;</div><div>-</div><div>-    def _get_fstype(self, filesystem):</div><div>-        dev_null = os.open(&#39;/dev/null&#39;, os.O_WRONLY)</div>

<div>-        args = [&#39;/sbin/blkid&#39;, &#39;-s&#39;, &#39;TYPE&#39;, &#39;-o&#39;, &#39;value&#39;, 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(&quot;Failed to determine fsimage TYPE: %s&quot; % e )</div><div>
-        finally:</div>
<div>-            os.close(dev_null)</div><div>-</div><div>-        return fs_type.rstrip()</div><div>+    &quot;&quot;&quot;The location of the filesystem image file.&quot;&quot;&quot;</div><div> </div><div>     def _get_fslabel(self):</div>

<div>         dev_null = os.open(&quot;/dev/null&quot;, 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, &#39;TYPE&#39;)</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>         &quot;&quot;&quot;Clone the running LiveOS image as the basis for the new image.&quot;&quot;&quot;</div><div> </div><div>@@ -353,6 +339,7 @@ class LiveImageEditor(LiveImageCreator):</div>

<div>         &quot;&quot;&quot;Adjust the image branding to show its variation from original</div><div>         source by builder and build date.&quot;&quot;&quot;</div><div> </div><div>+        self.fslabel = <a href="http://self.name">self.name</a></div>

<div>         dt = time.strftime(&#39;%d-%b-%Y&#39;)</div><div> </div><div>         lst = [&#39;isolinux/isolinux.cfg&#39;, &#39;syslinux/syslinux.cfg&#39;,</div><div>@@ -371,12 +358,11 @@ class LiveImageEditor(LiveImageCreator):</div>

<div>             for line in cfgf:</div><div>                 i = line.find(&#39;Welcome to &#39;)</div><div>                 if i &gt; -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>-                             &#39;-&#39;) + &#39;-&#39; + _builder + &#39;-Remix-&#39; + <a href="http://self.name">self.name</a></div>

<div>+        ntext = dt.translate(None, &#39;-&#39;) + &#39;-&#39; + _builder + &#39;-Remix-&#39; + release</div><div> </div><div>         # Update fedora-release message with Remix details.</div><div>         releasefiles = &#39;/etc/fedora-release, /etc/generic-release&#39;</div>

<div>@@ -392,8 +378,8 @@ class LiveImageEditor(LiveImageCreator):</div><div>                     raise CreatorError(&quot;Failed to open or write &#39;%s&#39; : %s&quot; %</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 += &#39;-&#39; + os.uname()[4] + &#39;-&#39; + time.strftime(&#39;%Y%m%d.%H&#39;)</div><div>+        self._releasefile = ntext</div>

<div>+        <a href="http://self.name">self.name</a> += &#39;-&#39; + os.uname()[4] + &#39;-&#39; + time.strftime(&#39;%Y%m%d.%H%M&#39;)</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 = [&#39;/bin/sed&#39;, &#39;-i&#39;,</div><div>-                &#39;-e&#39;, &#39;s/Welcome to .*/Welcome to &#39; + <a href="http://self.name">self.name</a> + &#39;!/&#39;,</div>

<div>-                &#39;-e&#39;, &#39;s/root=[^ ]*/root=live:CDLABEL=&#39; + self.fslabel + &#39;/&#39;,</div><div>+                &#39;-e&#39;, &#39;s/Welcome to .*/Welcome to &#39; + self._releasefile + &#39;!/&#39;,</div>

<div>+                &#39;-e&#39;, &#39;s/root=[^ ]*/root=live:CDLABEL=&#39; + <a href="http://self.name">self.name</a> + &#39;/&#39;,</div><div>                 &#39;-e&#39;, &#39;s/rootfstype=[^ ]* [^ ]*/rootfstype=auto ro/&#39;,</div>

<div>                 &#39;-e&#39;, &#39;s/liveimg .* quiet/liveimg quiet/&#39;, 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 = &quot;\n       %prog [-n=&lt;name&gt;]&quot;</div><div>-                            &quot;\n                      [-o=&lt;output&gt;]&quot;</div>

<div>-                            &quot;\n                      [-s=&lt;script.sh&gt;]&quot;</div><div>-                            &quot;\n                      [-t=&lt;tmpdir&gt;]&quot;</div><div>-                            &quot;\n                      [-e=&lt;excludes&gt;]&quot;</div>

<div>-                            &quot;\n                      [-f=&lt;exclude-file&gt;]&quot;</div><div>-                            &quot;\n                      [-i=&lt;includes&gt;]&quot;</div><div>-                            &quot;\n                      [-r=&lt;releasefile&gt;]&quot;</div>

<div>-                            &quot;\n                      [-b=&lt;builder&gt;]&quot;</div><div>-                            &quot;\n                      [--clone]&quot;</div><div>-                            &quot;\n                      [-c=&lt;compress_type&gt;]&quot;</div>

<div>-                            &quot;\n                      [--skip-compression]&quot;</div><div>-                            &quot;\n                      [--skip-minimize]&quot;</div><div>-                            &quot;\n                      &lt;LIVEIMG.src&gt;&quot;)</div>

<div>+    parser = optparse.OptionParser(usage = &quot;&quot;&quot;</div><div>+       %prog [-n=&lt;name&gt;]</div><div>+                      [-o=&lt;output&gt;]</div><div>+                      [-s=&lt;script.sh&gt;]</div>

<div>+                      [-t=&lt;tmpdir&gt;]</div><div>+                      [-e=&lt;excludes&gt;]</div><div>+                      [-f=&lt;exclude-file&gt;]</div><div>+                      [-i=&lt;includes&gt;]</div>

<div>+                      [-r=&lt;releasefile&gt;]</div><div>+                      [-b=&lt;builder&gt;]</div><div>+                      [--clone]</div><div>+                      [-c=&lt;compress_type&gt;]</div><div>
+                      [--skip-compression]</div>
<div>+                      [--skip-minimize]</div><div>+                      &lt;LIVEIMG.src&gt;&quot;&quot;&quot;)</div><div> </div><div>     parser.add_option(&quot;-n&quot;, &quot;--name&quot;, type=&quot;string&quot;, dest=&quot;name&quot;,</div>

<div>                       help=&quot;name of new LiveOS (don&#39;t include .iso, it will &quot;</div><div>@@ -476,7 +463,8 @@ def parse_options(args):</div><div>     parser.add_option(&quot;-r&quot;, &quot;--releasefile&quot;, type=&quot;string&quot;, dest=&quot;releasefile&quot;,</div>

<div>                       help=&quot;Specify release file/s for branding.&quot;)</div><div> </div><div>-    parser.add_option(&quot;-b&quot;, &quot;--builder&quot;, type=&quot;string&quot;, dest=&quot;builder&quot;,</div>

<div>+    parser.add_option(&quot;-b&quot;, &quot;--builder&quot;, type=&quot;string&quot;,</div><div>+                      dest=&quot;builder&quot;, default=os.getlogin(),</div><div>                       help=&quot;Specify the builder of a Remix.&quot;)</div>

<div> </div><div>     parser.add_option(&quot;&quot;, &quot;--clone&quot;, action=&quot;store_true&quot;, dest=&quot;clone&quot;,</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(&#39;/dev/null&#39;, os.O_WRONLY)</div><div>+    args = [&#39;/sbin/blkid&#39;, &#39;-s&#39;, tag, &#39;-o&#39;, &#39;value&#39;, 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(&quot;Failed to determine fs %s: %s&quot; % 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 = &quot;%s/EFI/boot/vmlinuz0&quot; % isodir</div><div>@@ -528,7 +530,9 @@ def main():</div>

<div>         print &gt;&gt; sys.stderr, &quot;You must run edit-liveos as root&quot;</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, &#39;LABEL&#39;) + &#39;.edited&#39;</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) + &quot;.edited&quot;</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 == &#39;/dev&#39;:</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 &quot;Running edit script &#39;%s&#39;&quot; % options.script</div><div>+            editor._run_script(options.script)</div>

<div>+        else:</div><div>+            print &quot;Launching shell. Exit to continue.&quot;</div><div>+            print &quot;----------------------------------&quot;</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>(&quot;%s.iso saved to %s&quot;  % (<a href="http://editor.name">editor.name</a>, output))</div>

<div>     except CreatorError, e:</div><div>         logging.error(u&quot;Error editing LiveOS : %s&quot; % e)</div><div>         return 1</div></font></div>