Oliver Falk


Config::YUM - Perl extension for parsing yum.conf


  use Config::YUM;

  my $yp = new Config::YUM;
  my $yum_conf = $yp->parse();

  foreach(keys %{$yum_conf}) {
        print "Section: $_ is called " . $yum_conf->{$_}->{name} . "\n";

  $yum_conf will be a a hash, all INI sections are the primary hash keys.
  include= will be automatically downloaded merged with the local yum.conf
  mirrorlists will also be downloaded and saved as an array in $yum_conf->{somerepo}->{baseurls}
  the first url in mirrorlists will be safed as $yum_conf->{somerepo}->{baseurl}.
  exclude statements will be splited and safed to $yum_conf->{somerepo}->{exclude_hash}. Note that we
  safe a perl regex string as keys here.

  To say it with one sentence. Config::YUM automatically parses a yum.conf does the downloading and provides you
  with a ready to use perl hash. :-)

  You can define a few things @ new:
        - use_cache: 0/1 (1 will enable, default: 0; Uses Cache::File)
        - yum_conf: path to your yum.conf (default: /etc/yum.conf)
        - yum_repos_d: path to your yum.repos.d (default: /etc/yum.repos.d)
        - agent: You LWP::UserAgent agent string (default: Config::YUM/$VERSION)
        - releasever: Define your RH/FC release version (rpm -qf --queryformat %{VERSION} /etc/redhat-release; Default: automatically queried)
        - basearch: Define your basearch (uname -i; Default: automatically discovered)
        - download_primary: Define if we should download/parse the primary.xml.gz
  These arguments can be specified this way (don't forget the '{'!)
  my $yp = new Config::YUM({
          use_cache        => 1,
          yum_conf         => '/etc/yum.conf',
          yum_repos_d      => '/etc/yum.repos.d',
          agent            => 'MyProgram/$VERSION',
          relasever        => 4,
          basearch         => 'i386',
          download_primary => 1


This module provides you with a few functions,

parse() will return a hash containing the allready parsed local/remote yum.conf.

yumconf_local() will return a hash containing the allready parsed local yum.conf (Will run parse(), if you didn't yet)

yumconf_remote() will return a hash containing the allready parsed remote yum.conf (Will run parse(), if you didn't yet)




None, that I'm aware of.


Let me know, I like it as it is - currently.


Config::IniHash Hash::Merge RPM2 LWP::UserAgent FreezeThaw File::Temp Cache::File XML::LibXML Sort::Versions PerlIO::gzip


Oliver Falk, <oliver@linux-kernel.at> linux-kernel.at


Copyright (C) 2005 by Oliver Falk

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.