OpenNMS::Release::Repo(3pm)

NAME
OpenNMS::Release::Repo - Perl extension that represents a package repository

SYNOPSIS
  use OpenNMS::Release::Repo;

DESCRIPTION
This represents an individual package repository.

CONSTRUCTOR
OpenNMS::Release::Repo->new($base);

Create a new Repo object, based in path $base. You can add and remove packages to/from it, re-index it, and so on. The base will always be initialized as the absolute path.

METHODS

•   new_with_base($newbase)

    Given a new base path, construct a Repo object matching the current, but with the new base path.

•   base

    The base (root) path of this repository.

•   path

    The full path to the top-level directory of this repository. (Must be implemented in subclasses.)

•   copy($new_base_path)

    Given a new base path, copy this repository to the new path using rsync. Returns an OpenNMS::Release::Repo object, representing this new base path.

    If possible, it will create the new repository using hard links.

•   replace($target_repository)

    Given a target repository, replace the target repository with the contents of the current repository.

•   create_temporary

    Creates a temporary repository that is a copy of the current repository. This temporary repository is automatically deleted on exit of the calling program.

•   _packageset

    Returns a PackageSet of OpenNMS::Release::Package objects in this repository. This must be uncached, and implemented by subclasses.

•   delete

    Delete the repository from the filesystem.

•   install_package($package, $target_path)

    Given an package and an optional target path relative to the repository path, install the package into the repository.

    For example, "$repo->install_package($package, "opennms/i386")" will install the package into "$repo->path"/opennms/i386/"package_filename".

•   share_package($source_repo, $package)

    Given a source repository and an package object, hard link the package into the equivalent location in the current repository, if it is newer than the newest existing version of that package.

•   share_all_packages($source_repo)

    Given a source repository, share any package in that source repository that is newer than the equivalent package in the current repository. If no equivalent package exists, then share the newest package.

•   exclude_share

    A (reference to a) list of package names that should be ignored when sharing asource repository with this one.

•   find_all_packages

    Locate all Packages in the repository. Returns a list of OpenNMS::Release::Package objects.

•   find_newest_packages

    Locate the newest version of each package in the repository (based on the name of the package, not filesystem details). Returns a list of OpenNMS::Release::Package objects.

•   find_obsolete_packages

    Locate all but the newest version of each package in the repository. Returns a list of OpenNMS::Release::Package objects.

•   find_newest_package_by_name($name, $arch)

    Given a package name, returns the newest OpenNMS::Release::Package object by that name and architecture in the repository. If no package by that name exists, returns undef.

•   find_newest_packages_by_name

    Given a package name, returns the newest list f OpenNMS::Release::Package objects for each architecture by that name in the repository. If no package by that name exists, returns undef.

•   delete_obsolete_packages([\&subroutine])

    Removes all but the newest packages from the repository.

    Optionally, takes a subroutine reference. Each obsolete package object is passed to this subroutine, along with the repository object, and if it returns true (1), that package will be deleted.

    Examples:

    $repo->delete_obsolete_packages(sub { $_[0]->name eq "iplike" })
        Only delete obsolete packages named "iplike".

    $repo->delete_obsolete_packages(sub { $_[0]->path =~ /monkey/ })
        Only delete obsolete packages in a filesystem path containing the text "monkey".

    $repo->delete_obsolete_packages(sub { $_[0]->version =~ /^1/ })
        Only delete obsolete packages whose version starts with 1.

    $repo->delete_obsolete_packages(sub { $_[1]->release =~ /unstable/ })
        Only delete obsolete packages in the "unstable" repository.

•   sign_all_packages($signing_id, $signing_password, [\&sign], [\&status])

    Given a GPG id and password, (re-)sign all the packages in the repository.

    Takes 2 optional subroutines.

    The first, like delete_obsolete_packages, will receive as arguments the package object, and the repository object. If it returns 1, that package will be signed.

    The second receives as arguments the package, the current count, the total count of packages to be processed, and whether or not the package was chosen to be signed by the &sign method.

•   index_if_necessary

    Create the YUM indexes for this repository, if any changes have been made.

    Takes the same options as the index method.

•   begin

    Begin a transaction. Commit changes using commit(), otherwise, abort().

    Returns the repository object to be manipulated inside the transaction.

•   commit

    Called on the temporary object from begin(), commits the changes that have occurred since the start of the transaction.

    Returns the committed repository object.

•   abort

    Called on the temporary object from begin(), aborts the changes that have occurred since the start of the transaction.

    Returns the original, unmodified repository object.

AUTHOR
Benjamin Reed <ranger@opennms.org> Matt Brozowski <brozow@opennms.org>

COPYRIGHT AND LICENSE
Copyright (C) 2012 by The OpenNMS Group, Inc.

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.8 or, at your option, any later version of Perl 5 you may have available.