Hi all, I have boiled this problem down as much as possible, ie. down to a module that manages a file with a single word in it (I've learned some more notable things about that, which are listed in PS):
module Word = let lns = [ seq "words" . store Rx.word . Util.eol] When using this module to create new files, then we get an error: [root ~]# ls /tmp/word ls: cannot access /tmp/word: No such file or directory [root ~]# augtool -t "Word.lns incl /tmp/word" augtool> set /files/tmp/word/1 spam augtool> save error: Failed to execute command saving failed (run 'errors' for details) augtool> errors Error in /tmp/word:1.0 (parse_skel_failed) Input string does not match at all Lens: /usr/share/augeas/lenses/word.aug:4.12-.54: When there already is a valid file, the module works fine: [root ~]# echo spam >/tmp/word [root ~]# augtool -t "Word.lns incl /tmp/word" augtool> print /files/tmp/word /files/tmp/word /files/tmp/word/1 = "spam" augtool> set /files/tmp/word/1 eggs augtool> save Saved 1 file(s) [root ~]# cat /tmp/word eggs Honestly, to me this looks like a bug. Even making this sole lens optional, to make an empty file acceptable, doesn't make the module functional (albeit with different error message). module Word = let lns = [ seq "words" . store Rx.word . Util.eol ]? [root ~]# augtool -t "Word.lns incl /tmp/word" augtool> print /files/tmp/word augtool> set /files/tmp/word/1 spam augtool> save error: Failed to execute command saving failed (run 'errors' for details) augtool> errors Error in /tmp/word:1.0 (parse_skel_failed) parse can not process entire input Lens: /usr/share/augeas/lenses/word.aug:4.12-.55: Again, someone has an idea what I'm doing wrong? Ciao, Xavier. PS) * There must be a label for this node (either seq, key or label), or the Augeas tree doesn't keep the value and it cannot be altered, too. * The lens must match eol, even though the file might not have one - in that situation, end-of-file is matched instead. 'let lns = [ seq "words" . store Rx.word ]' always results in parsing errors ("Get did not match entire input"), even if files are created like 'echo -n word >file'. Though if there is a proper line break before the end of file (echo word >file), the outcome is identical. > -----Original Message----- > From: Mol, Xavier (SCC) > Sent: Thursday, December 17, 2015 1:36 PM > To: Mol, Xavier (SCC); augeas-devel@redhat.com > Subject: RE: Why does Augeas fail to create new files? > > > ---> Creating an empty node works fine, though this should actually fail in > > my opinion (an empty file is invalid according to the lens). > Sorry, I have to correct this. The attached lens definition does allow for an > empty file. However, setting lns like this: > > let lns = ( empty | comment )* . version . ( empty | comment | rule )* > > Hence, requiring at least a line with "version" in it, doesn't change the > reported behaviour at all for me. > > Ciao, > Xavier. > > > -----Original Message----- > > From: augeas-devel-boun...@redhat.com > > [mailto:augeas-devel-boun...@redhat.com] On Behalf Of Mol, Xavier (SCC) > > Sent: Thursday, December 17, 2015 1:33 PM > > To: augeas-devel@redhat.com > > Subject: [augeas-devel] Why does Augeas fail to create new files? > > > > Hello Augeas experts, > > > > attached you can find the source of a custom lens for Augeas and a file > > with get and put unit tests; either file is evaluated with augparse > > successfully. My question is, why can I not create a new file from scratch > > with that lens, while editing existing files works just fine? > > > > In order to test the steps in between, I used augeas-1.4 and augtool: > > > > [root ~]# augtool --version > > augtool 1.4.0 <http://augeas.net/> > > Copyright (C) 2007-2011 David Lutterkort > > License LGPLv2+: GNU LGPL version 2.1 or later > > <http://www.gnu.org/licenses/lgpl-2.1.html> > > This is free software: you are free to change and redistribute it. > > There is NO WARRANTY, to the extent permitted by law. > > > > Written by David Lutterkort > > > > [root ~]# augtool > > augtool> print /augeas/load/StorageAuthzdb/*[label() != "excl"] > > /augeas/load/StorageAuthzdb/lens = "@StorageAuthzdb" > > /augeas/load/StorageAuthzdb/incl = "/etc/grid-security/storage-authzdb" > > > > ---> Currently, the node included with that lens doesn't exist. > > augtool> ls /files/etc/grid-security/storage-authzdb > > augtool> dump-xml /files/etc/grid-security/storage-authzdb > > <augeas match="/files/etc/grid-security/storage-authzdb"/> > > > > ---> Creating an empty node works fine, though this should actually fail in > > my opinion (an empty file is invalid according to the lens). > > augtool> touch /files/etc/grid-security/storage-authzdb > > augtool> save > > Saved 1 file(s) > > augtool> ls /files/etc/grid-security > > storage-authzdb = (none) > > augtool> dump-xml /files/etc/grid-security/storage-authzdb > > <augeas match="/files/etc/grid-security/storage-authzdb"> > > <node label="storage-authzdb" > > path="/files/etc/grid-security/storage-authzdb"/> > > </augeas> > > > > ---> Saving the minimal change required for a valid storage-authzdb file > > fails. > > augtool> set /files/etc/grid-security/storage-authzdb/version "2.1" > > augtool> dump-xml /files/etc/grid-security/storage-authzdb > > <augeas match="/files/etc/grid-security/storage-authzdb"> > > <node label="storage-authzdb" > > path="/files/etc/grid-security/storage-authzdb"> > > <node label="version"> > > <value>2.1</value> > > </node> > > </node> > > </augeas> > > augtool> save > > error: Failed to execute command > > saving failed (run 'errors' for details) > > augtool> errors > > Error in /etc/grid-security/storage-authzdb:1.0 (parse_skel_failed) > > parse can not process entire input > > Lens: /usr/share/augeas/lenses/storageauthzdb.aug:34.12-.75: > > > > > > ---> Starting over... > > [root ~]# rm /etc/grid-security/storage-authzdb > > rm: remove regular empty file `/etc/grid-security/storage-authzdb'? y > > [root ~]# augtool > > > > ---> Create the desired tree > > augtool> set /files/etc/grid-security/storage-authzdb/version "2.1" > > > > ---> Review what the lens would put as a string, which matches what I > > expect. > > augtool> set /in "" > > augtool> retrieve StorageAuthzdb.lns /in > > /files/etc/grid-security/storage-authzdb /out > > augtool> print /out > > /out = "version 2.1\n" > > > > ---> Still saving that output fails > > augtool> save > > error: Failed to execute command > > saving failed (run 'errors' for details) > > augtool> errors > > Error in /etc/grid-security/storage-authzdb:1.0 (parse_skel_failed) > > parse can not process entire input > > Lens: /usr/share/augeas/lenses/storageauthzdb.aug:34.12-.75: > > > > ---> Though when the file exists before augtool is used, everything seems > > to work. > > [root ~]# echo version 2.1 >/etc/grid-security/storage-authzdb > > [root ~]# augtool > > augtool> ls /files/etc/grid-security/storage-authzdb > > version = 2.1 > > augtool> dump-xml /files/etc/grid-security/storage-authzdb > > <augeas match="/files/etc/grid-security/storage-authzdb"> > > <node label="storage-authzdb" > > path="/files/etc/grid-security/storage-authzdb"> > > <node label="version"> > > <value>2.1</value> > > </node> > > </node> > > </augeas> > > augtool> set /files/etc/grid-security/storage-authzdb/version "2.2" > > augtool> save > > Saved 1 file(s) > > [root ~]# cat /etc/grid-security/storage-authzdb > > version 2.2 > > > > > > > > What am I doing wrong here? > > > > Thank you for your time, > > Xavier. > > > > > > **** > > Karlsruher Institute of Technology (KIT) > > Steinbuch Centre for Computing (SCC) > > > > B. Sc. Xavier Mol > > GridKa Storage Administrator and Support Manager > > > > Hermann-von-Helmholtz-Platz 1 > > Geb. 449 > > 76344 Eggenstein-Leopoldshafen > > Phone: +49 721 608 23041 > > Email: xavier....@kit.edu > > www.kit.edu > > KIT - University of the State of Baden-Württemberg and National Large-scale > > Research Center of the Helmholtz Association > > "Since 2010, the KIT has been certified as a family-friendly university." > > ****
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ augeas-devel mailing list augeas-devel@redhat.com https://www.redhat.com/mailman/listinfo/augeas-devel