[augeas-devel] Augeas to parse informational files from install CDs?

Owen Mann owen-javanet at rcn.com
Sat Jan 29 02:16:58 UTC 2011


Owen Mann wrote:
> David Lutterkort wrote:
>> Hi Rich,
>>
>> On Mon, 2011-01-17 at 18:10 +0000, Richard W.M. Jones wrote:
>>> These files are not in a fixed location, but found relative to the
>>> mountpoint of the CD.
>>
>> That means you'll have to set up where to read the files by
>> manipulating /augeas/load and then issuing an aug_load[1]
>>
>>> Assuming it is in scope, then here are some examples:
>>>
>>> (1) From Fedora DVD:
>>>
>>> Two files of interest, '/.discinfo' and '/.treeinfo', examples
>>> attached. There are many interesting fields, but particularly we'd
>>> like to read the OS name, version, architecture and disk number.
>>
>> I am attaching the lens for .discinfo; .treeinfo seems to be a INI-file.
>> I'll try and cobble sth together from the IniFile module tomorrow
>> (unless somebody beats me to it).
>>
>> Basically, entries will go to .treeinfo/$section/$key except for the
>> stuff in the 'checksums' section since the keys there contain slashes.
>> That section will need to be treated special.
>>
>>> (2) From Windows XP - 2003 install CDs:
>>>
>>> We parse a file called '/i386/txtsetup.sif' ('/amd64/txtsetup.sif' on
>>> x86-64). These huge text files contain several interesting fields
>>> describing the CD including:
>>
>> What a beauty. This should also be tractable with a fairly generic INI
>> lens.
>>
>> David
>>
>> [1] http://augeas.net/page/Loading_specific_files
>>
>>
>>
>>
>> _______________________________________________
>> augeas-devel mailing list
>> augeas-devel at redhat.com
>> https://www.redhat.com/mailman/listinfo/augeas-devel
>
>
> Oddly, I was just working on this recently, but got stuck.
> Using Augeas to modify this file, combined with the new template-able
> tftpd.py in Cobbler, has the potential to make a killer
> Windows deployment system (if there is such a thing).
>
> Starting from the IniFile lens, I had to change some things to be
> compatible with this file, including:
>
> - DOS-format CRLF's
> - some LHS settings are quoted, with spaces. Either side may have
> underscores or percents.
>
> The part that stumped me is the [Files.DeleteOnUpgrade] sections:
>
> [Files.DeleteOnUpgrade]
> msilrai.dll , 2
> 1394vdbg.inf , 20
> 1394vdbg.sys , 4
> 15_16wdm.sys , 4
> [...]
>
> I haven't been able to figure out a lens/regexp/whatever to just add
> these lines as-is (i.e. no values). Anybody have some advice?
> Here's what I've got so far (I haven't tackled CRLF's yet):
>
> ----8<------------------------------------------------------------------
> module Txtsetup =
> autoload xfm
>
> let comment = Util.comment_generic /[ \t]*;[ \t]*/ "; "
> let sep = IniFile.sep "=" "="
> let sto_to_comment_re = /[^; \t\n][^;\n]*[^; \t\n]|[^; \t\n]/
> let sto_to_comment = Util.del_opt_ws "" . store (sto_to_comment_re | /"/
> . sto_to_comment_re . /"/)
>
> let entry_re = ( /[A-Za-z0-9\._%,-]+/ )
> let dqentry_re = /"[ A-Za-z#0-9\._-]+"/
> let entry_uq = [ key entry_re . sep . sto_to_comment? .
> (comment|Util.eol) ]
> let entry_dq = [ key dqentry_re . sep . sto_to_comment? .
> (comment|Util.eol) ]
> let entry = Util.empty | entry_uq | entry_dq | comment
>
> let title = Util.del_str "[" . key IniFile.record_re . Util.del_str "]"
> . Util.eol
>
> let record = IniFile.record_noempty title entry
>
> let lns = IniFile.lns record comment
>
> let filter = (incl "/tftpboot/w2k3SESP2-32/i386/aug/*")
> let xfm = transform lns filter
> ----8<------------------------------------------------------------------
>
> I've tried adding a third "entry" type:
> let entry_new = [ key entry_re . (comment|Util.eol) ]
>
> but it complains that this overlaps with the entry_uq lens.
> I've tinkered like crazy, but I can't figure out how to make this lens
> unique. Basically I want it to match a
> non-{empty,entry_uq,entry_dq,comment} line without an '='. What am I
> missing?
>
> Any help appreciated!
>
> -Owen Mann
>
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel
>

Okay, while working on this, I've found the following oddness:

let foo = [ key /A/ | key /B/ ]

...yields:
/usr/share/augeas/lenses/txtsetup.aug:19.0-.31:Failed to compile foo
/usr/share/augeas/lenses/txtsetup.aug:19.12-.29:exception: overlapping lenses in tree union.put
     Example matched by both:
     First lens: /usr/share/augeas/lenses/txtsetup.aug:19.12-.19:
     Second lens: /usr/share/augeas/lenses/txtsetup.aug:19.22-.29:

Notice "Example matched by both:" is null.

According to http://augeas.net/docs/lenses.html#lens-combinators (as I understand it), this should work.
Is this a bug?




More information about the augeas-devel mailing list