[yast-devel] ini-agent vs Augeas, Re: [yast-commit] r62714
On Tue, Nov 02, 2010 at 01:03:09PM -0000, lslezak@svn2.opensuse.org wrote:
Author: lslezak Date: Tue Nov 2 14:03:08 2010 New Revision: 62714
URL: http://svn.opensuse.org/viewcvs/yast?rev=62714&view=rev Log: - correctly display download progress in DownloadInAdvance libzypp mode (bnc#616708)
Ah, nice to see this fixed :-)
Added: trunk/packager/agents/etc_zypp_conf.scr
[...] But this reminds me that it is high time to replace the Ini Agent (and mostly all agents) with something more modern and maintained, namely Augeas (already used by zypper). See what it can parse (and write!) http://git.fedorahosted.org/git/?p=augeas.git;a=tree;f=lenses;h=60be35d5c8a5... (or rpm -ql augeas-lenses ) and how it can define macros for the regexes seen below http://git.fedorahosted.org/git/?p=augeas.git;a=blob;f=lenses/sep.aug;h=c499... http://git.fedorahosted.org/git/?p=augeas.git;a=blob;f=lenses/rx.aug;h=95df7... Anyone interested in playing with it? Of course it has scripting bindings so we can use it in the Lighter WebYaST.
+.etc.zypp_conf + +`ag_ini( + `IniAgent( "/etc/zypp/zypp.conf" , $[ + "options" : [ "no_nested_sections", "line_can_continue", "comments_last" ], + "comments": [ + "^[ \t]*$", // empty line + "^[ \t]*#.*$", // comment char + ], + "sections" : [ + $[ + "begin" : [ "^[ \t]*\\[[ \t]*(.*[^ \t])[ \t]*\\][ \t]*", "[%s]" ], + ] + ], + "params" : [ + $[ + "match" : [ "^[ \t]*([^=]*[^ \t=])[ \t]*=[ \t]*(.*[^ \t]|)[ \t]*$" , "%s=%s"], + ] + ] + ] + ) +) -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner
Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
URL: http://svn.opensuse.org/viewcvs/yast?rev=62759&view=rev Log: update fstab options (bnc#649497)
@@ -5178,6 +5178,25 @@ } }
+global define void UpdateFstabOptions() { + y2milestone( "UpdateFstabOptions" ); + string tabpath = PathToDestdir( "/etc/fstab" ); + map fstab = Partitions::GetFstab( tabpath ); + integer line = 0; + string n = ""; + while( line<=AsciiFile::NumLines( fstab ) ) + { + map l = AsciiFile::GetLine( fstab, line ); + string options = l["fields", 3]:""; + if (regexpmatch (options, "^\(.*,\)\?hotplug\(,.*\)\?$")) { + options = regexpsub (options, "^\(.*,\)\?hotplug\(,.*\)\?$", "\\1nofail\\2"); + AsciiFile::ChangeLineField( fstab, line, 3, options ); + } + line = line+1; + } + AsciiFile::RewriteFile( fstab, tabpath ); +} +
My new favorite hammer can do this in one line ;-) int aug_setm(augeas *aug, const char *base, const char *sub, const char *value) aug_setm(context, "/files/etc/fstab/*/opt[. = 'hotplug']", NULL, "nofail"); Or in Ruby: http://git.fedorahosted.org/git/?p=ruby-augeas.git;a=blobdiff;f=tests/tc_aug... -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
Am Mon 08 Nov 2010 04:15:01 PM CET schrieb Martin Vidner <mvidner@suse.cz>:
But this reminds me that it is high time to replace the Ini Agent (and mostly all agents) with something more modern and maintained, namely Augeas (already used by zypper).
See what it can parse (and write!) http://git.fedorahosted.org/git/?p=augeas.git;a=tree;f=lenses;h=60be35d5c8a5... (or rpm -ql augeas-lenses ) and how it can define macros for the regexes seen below http://git.fedorahosted.org/git/?p=augeas.git;a=blob;f=lenses/sep.aug;h=c499... http://git.fedorahosted.org/git/?p=augeas.git;a=blob;f=lenses/rx.aug;h=95df7...
I read the "Creating a lens" tutorial and I realize that augeas is an actual parsing tool (and not only a heap of regexps). Using it will actually improve yast2. If zypper already has a dependency on Augeas, that's all the more reason for doing this change.
Anyone interested in playing with it?
I'm all in. Can you suggest a place in yast2, where I can start? Martin Kudlvasr -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Tue, Nov 09, 2010 at 02:51:21PM +0100, Martin Kudlvasr wrote:
I read the "Creating a lens" tutorial and I realize that augeas is an actual parsing tool (and not only a heap of regexps). Using it will actually improve yast2. If zypper already has a dependency on Augeas, that's all the more reason for doing this change.
Anyone interested in playing with it?
I'm all in. Can you suggest a place in yast2, where I can start?
One thing is enabling the use of Augeas. I think we should use the existing Perl or Ruby bindings (we don't have RPMs yet) and write some helper/wrapper for the YCP modules. Also we can look at the current agent usage: grep -h '^`ag_' /usr/share/YaST2/scrconf/*.scr | sort | uniq -c (spoiler alert: Ini is the most popular, with Any the second) and decide where the low hanging fruits are for replacement. -- Martin Vidner, YaST developer http://en.opensuse.org/User:Mvidner Kuracke oddeleni v restauraci je jako fekalni oddeleni v bazenu
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dne 9.11.2010 16:57, Martin Vidner napsal(a):
On Tue, Nov 09, 2010 at 02:51:21PM +0100, Martin Kudlvasr wrote:
I read the "Creating a lens" tutorial and I realize that augeas is an actual parsing tool (and not only a heap of regexps). Using it will actually improve yast2. If zypper already has a dependency on Augeas, that's all the more reason for doing this change.
Anyone interested in playing with it?
I'm all in. Can you suggest a place in yast2, where I can start?
One thing is enabling the use of Augeas. I think we should use the existing Perl or Ruby bindings (we don't have RPMs yet) and write some helper/wrapper for the YCP modules.
Please, as 'Ini' and 'Any' agents are widely used by the installation workflow and modules used by the installation workflow, make sure that we don't need to add too much (Ruby) to the inst-sys. From this PoV, Perl sounds a bit better, we already have it there.
Also we can look at the current agent usage: grep -h '^`ag_' /usr/share/YaST2/scrconf/*.scr | sort | uniq -c (spoiler alert: Ini is the most popular, with Any the second) and decide where the low hanging fruits are for replacement.
Low hanging fruit is for losers :D Think big! :D Bye Lukas - -- Lukas Ocilka, Appliances Department, Novell Inc. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.12 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iD8DBQFM2XbjVSqMdRCqTiwRAt8RAJ9oFEEhlu7GNhFpMuMwkJvIJRP/pQCeOkK6 C8T8cvFo9/lpOSP57KgZY6g= =MFHU -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On 11/09/2010 04:57 PM, Martin Vidner wrote:
On Tue, Nov 09, 2010 at 02:51:21PM +0100, Martin Kudlvasr wrote:
I read the "Creating a lens" tutorial and I realize that augeas is an actual parsing tool (and not only a heap of regexps). Using it will actually improve yast2. If zypper already has a dependency on Augeas, that's all the more reason for doing this change.
Anyone interested in playing with it?
I'm all in. Can you suggest a place in yast2, where I can start?
One thing is enabling the use of Augeas. I think we should use the existing Perl or Ruby bindings (we don't have RPMs yet) and write some helper/wrapper for the YCP modules.
Also we can look at the current agent usage: grep -h '^`ag_' /usr/share/YaST2/scrconf/*.scr | sort | uniq -c (spoiler alert: Ini is the most popular, with Any the second) and decide where the low hanging fruits are for replacement.
Is the current INI agent is plain C++ right now? I saw more naturally a design where the basic augeas agent is built as a C++ agent linking to libaugeas, and then the derived agents are specified as an .scr referencing ag_augeas and adding additional information like inlining the lense description. -- Duncan Mac-Vicar P. - Novell® Making IT Work As One™ SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (4)
-
Duncan Mac-Vicar P.
-
Lukas Ocilka
-
Martin Kudlvasr
-
Martin Vidner