<div dir="ltr"><div>Hi Rich,</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 5, 2018 at 3:43 AM, Richard W.M. Jones <span dir="ltr"><<a href="mailto:rjones@redhat.com" target="_blank">rjones@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Mon, Jun 04, 2018 at 11:30:52AM -0700, David Lutterkort wrote:<br>
> I've opened a PR (<a href="https://github.com/hercules-team/augeas/pull/562" rel="noreferrer" target="_blank">https://github.com/hercules-<wbr>team/augeas/pull/562</a>) with a<br>
> modified Grub lens that is more tolerant of these kinds of errors. Lines<br>
> like the 'acpi=off' in your example will now be mapped into the tree as<br>
> '#error' nodes, rather than refusing to parse such a file outright. Let me<br>
> know if that does what you need it to do, or if it needs to be changed<br>
> further.<br>
<br>
</span>I tried to test this, but I couldn't get augtool to do anything when<br>
run from the local tree.<br></blockquote><div><br></div><div>The easiest way to test this is to put the modified grub.aug somewhere (say /tmp) and the</div><div> grub.conf you want to try it out with somewhere else (say, also /tmp) and then run</div><div><br></div><div>    augtool -I /tmp -At 'Grub.lns incl /tmp/grub.conf'</div><div><br></div><div>(that's a capital i as the first option and lets you pass dirs to load lenses from)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

After patching my git copy of augeas with the patch above and<br>
compiling it, augtool could never load any files:<br>
<br>
  $ PATH=`pwd`/src:$PATH LENS_DIR=`pwd`/lenses augtool -r /var/tmp/root/<br>
  augtool> ls /files<br>
  [nothing]<br></blockquote><div><br></div><div>The environment variable to add dirs to the lens search path is called AUGEAS_LENS_LIB,</div><div>but '-I' will have the same effect.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

Even without the -r parameter it did nothing.<br>
<br>
In libvirt & libguestfs we generate a ‘./run’ script in the top build<br>
directory which sets up the environment right so you could do<br>
something like:<br>
<br>
  $ ./run augtool [...]<br>
<br>
and have it just do the right thing.<br>
<br>
Anyway if I understand the proposed patch from reading the source, it<br>
wouldn't fail to parse the original file (which is progress) however<br>
if we rewrote the file then any unparsable lines would be deleted, is<br>
that correct?</blockquote><div><br></div><div>The bad lines will show up in the tree as '#error' nodes; as long as you leave them in the tree,</div><div>they will be preserved and show up in the output again. As an example (I have the modified grub.aug</div><div> in $PWD/lenses/grub.aug):</div><div><br></div><div style="margin-left:40px">> cat /tmp/grub.conf</div><div style="margin-left:40px">timeout=5<br>acpi=off<br>default=0</div><div style="margin-left:40px"><br></div><div style="margin-left:40px">> augtool -I lenses/ -At 'Grub.lns incl /tmp/grub.conf' set /files/tmp/grub.conf/timeout 7</div><div style="margin-left:40px">Saved 1 file(s)</div><div style="margin-left:40px"><br></div><div style="margin-left:40px">> cat /tmp/grub.conf</div><div style="margin-left:40px">timeout=7<br>acpi=off<br>default=0<br></div></div><div class="gmail_quote"><br></div><div class="gmail_quote">If you want to remove bad lines explicitly, you can do:</div><div class="gmail_quote" style="margin-left:40px"><br></div><div class="gmail_quote" style="margin-left:40px">> augtool -I lenses/ -At 'Grub.lns incl /tmp/grub.conf' rm /files/tmp/grub.conf/#error</div><div class="gmail_quote" style="margin-left:40px">rm : /files/tmp/grub.conf/#error 1<br>Saved 1 file(s)<br></div><div class="gmail_quote" style="margin-left:40px"><br></div><div class="gmail_quote" style="margin-left:40px">> cat /tmp/grub.conf <br>timeout=7<br>default=0<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">David<br></div><div class="gmail_quote"><br></div></div></div>