NAME

LCFG::RPMCache::Utils - parse rpm lists and download rpms

SYNOPSIS

use LCFG::RPMCache::Utils;

# Create an RPM cache object
$c = new LCFG::RPMCache::Utils( option, ... );

# Read and parse rpmcfg file
$c->ReadRPMs( $filename, option, ... );

# Get RPM locations and explicit versions from server
$c->FetchLocations( $rpmpath, option, ... );

# Download new/updated RPMs as necessary to update cache
$c->FillCache ( $cachedir, option, ... );

# Extract RPM header information
$c->GetRPMInfo();

# Remove stale entries from the cache
$c->CleanCache( $cachedir, option, ... );

# Read username/passwd stored by LCFG client
($userid,$passwd) = $c->GetPasswd();

# Create srpm cache from rpm cache
$srpms = $c->SRPMList();

DESCRIPTION

This module provides functions for manipulating lists of RPMs, and downloading RPMs, as used by the lcfg-rpmcache component: All routines set $@ and return undef on error.

The constructor accepts the following options:

VERBOSE  => verbose output
PREFIX   => print this prefix on all log messages

ReadRPMs reads the given rpmcfg file (or URL) and creates a structure in the following format, representing the list of RPMs:

{
  'rpmname1' => {

     '2.3.6-1/i386' =>   {

       CATEGORY => category (from #pragma LCFG category)
       DERIVE   => derivation (from #pragma LCFG derive)
       CONTEXT  => context (from #pragma LCFG context)
       OPTS     => RPM option flags
       SOURCE   => source file
       LINE     => source file line number

     }

     '1.2.5-4/noarch' => {
       ...
     }

   }

  'rpmname2' => {
     ...
   }

   ...
}

This structure can be retrieved using the accessor function RPMs();

The following options are supported:

ADDMETA  => true to add the meta information (category etc.)
PASSWD   => password for remote fetch
USERID   => user id for remote fetch
SRPMS    => use the SRPM structure, rather than the RPM one
CPPOPTS  => additional CPP options
DEFARCH  => The default architecture, if not specified the current
             platform architecture is used as a default.

The password and user id may be obtained from the LCFG profile (requires root permission) by using:

($userid,$passwd) = $c->GetPasswd();

The FetchLocations function retrieves the rpmlist from the repository, instantiates any wildcards in the versions, and adds the URL to the RPM structure in the {U} field.

The following options are supported:

PASSWD   => password for remote fetch
USERID   => user id for remote fetch
SRPMS       => use the SRPM structure, rather than the RPM one

The FillCache routine downloads RPMs as necessary to update the cache. The rpmcache parameter specifies a comma-separated list of filenames or URLs for repository directories. Each directory must contain an rpmlist file containing the list of RPMs. The following options are accepted:

PASSWD      => password for remote fetch
USERID      => user id for remote fetch
GENHDFILE   => true to run genhdfile on downloaded files
RPMLIST     => name of rpmlist file to create
TEST        => test only
SRPMS       => use the SRPM structure, rather than the RPM one

The GetRPMInfo routine extracts information from the headers of the downloaded RPMs and adds the following additional fields to the rpm structure:

NAME      => RPM name
VERSION   => RPM version/release
ARCH      => RPM architecture
GROUP     => RPM group
PACKAGER  => RPM packager
BUILDDATE => Build date
SUMMARY   => RPM summary
SRPM      => SRPM
PATHNAME  => Pathname of RPM in local cache

CleanCache removes stale entries from the cache directory. The following options are accepted:

RPMLIST     => name of rpmlist file to create
PRESERVE    => log instead of deleting
TEST        => test only
SRPMS       => use the SRPM structure, rather than the RPM one

The SRPMList function creates a similar structure to the RPM structure for all the SRPMs corresponding to the RPMs. The RPM cache object must have the info present (ie. GetRPMInfo has been called).

PLATFORMS

Redhat7, Redhat9, Solaris9

AUTHOR

Paul Anderson <dcspaul@inf.ed.ac.uk>