Hello, Is there a standard programmatic way to manipulate yum configuration files, particularly the .repo files? I want to add things like "priority=..." per repo, or "check_obsoletes=1" to the priorities plugin config. I can cook specific search/append using perl or sed but was wondering whether there is a more elegant way. I found Perl's Conf::INI module but it expects comments beginning with ";", not "#". Thanks, --Amos
On Thu, Jan 08, 2009 at 11:11:53AM +1100, Amos Shapira wrote:> Hello, > > Is there a standard programmatic way to manipulate yum configuration > files, particularly the .repo files? > > I want to add things like "priority=..." per repo, or > "check_obsoletes=1" to the priorities plugin config. > > I can cook specific search/append using perl or sed but was wondering > whether there is a more elegant way. > > I found Perl's Conf::INI module but it expects comments beginning with > ";", not "#". >Not that I'm aware of, but sounds like an interesting idea. You also might ask on the yum or yum development mailing list. Let us know what you find out! Ray
Amos Shapira wrote:> Is there a standard programmatic way to manipulate yum configuration > files, particularly the .repo files?Puppet has a yum module, which is quite capable and what I use. -- Karanbir Singh CentOS Project { http://www.centos.org/ } irc: z00dax, #centos at irc.freenode.net
Filipe Brandenburger
2009-Jan-08 01:45 UTC
[CentOS] Scriptable way to edit yum .repo files?
On Wed, Jan 7, 2009 at 19:11, Amos Shapira <amos.shapira at gmail.com> wrote:> I found Perl's Conf::INI module but it expects comments beginning with > ";", not "#".Why don't you use Python's ConfigParser? That's what yum itself actually uses (AFAIK). http://docs.python.org/library/configparser.html With that module, you can read a file, modify the objects, and then write it to a new file. HTH, Filipe
On Thu, 8 Jan 2009, Amos Shapira wrote:> I found Perl's Conf::INI module but it expects comments beginning with > ";", not "#".and | sed -e 's@^#@;@g' cannot cure that bad habit on generated files or an input stream? [herrold at centos-5 ~]$ cat - << END | sed -e 's@^#@;@g'> one > two#two > $three#three > #four;four > #five#five > ;six#six > ENDone two#two ;three ;four;four ;five#five ;six#six [herrold at centos-5 ~]$ -- Russ herrold