OpenBSD::PackingList(3p)

NAME
OpenBSD::PackingList - "pkg_add(1)" packing-list manipulations

SYNOPSIS
    use OpenBSD::PackingList;
    # different methods to create packing-lists
    my $p1 = OpenBSD::PackingList->new;         # empty
    my $p2 = OpenBSD::PackingList->read($fh);
    my $p3 = OpenBSD::PackingList->fromfile($filename);
    my $p4 = OpenBSD::PackingList->fromfile(\$scalar);
    my $p5 = OpenBSD::PackingList->from_installation($pkgname);

    # writing packing-lists
    $p2->write($fh);
    $p3->tofile($filename);
    $p4->to_installation;
    $p4->to_cache;

    # building up packing-lists
    OpenBSD::PackingElement::SUBCLASS->add($plist, @args);
    my $o = OpenBSD::PackingElement::SUBCLASS->new(@args);
    $o->add_object($plist);

    # tests and access
    $b = $p2->has($name);
    $b = $p2->get($name);
    # frequent accesses
    print $p3->pkgname, $p3->localbase, "\n";

    # processing packing-lists
    $p4->visit('method', @args);

    # auto visit
    $p4->method(@args);

    # signatures
    if ($p3->signature eq $p4->signature) {
    }

DESCRIPTION
"OpenBSD::PackingList" is the only supported interface for access to packing-list information. It includes conversion methods from an external textual representation (file) into an internal structured representation. Basically, a packing-list is a collection of strongly-typed objects. Some of these objects are just properties of the package (like the package name, or dependencies), some objects have long lists of properties (files come with MD5 checksums, sizes, or linknames), some objects represent state information (like file modes) and must be kept in the proper order. The "OpenBSD::PackingList" class handles all that.

Packing-lists can be obtained using the following methods: from an opened file handle using "OpenBSD::PackingList->read($fh)", from an existing file using "OpenBSD::PackingList->fromfile($filename)", from a scalar in memory using "OpenBSD::PackingList->fromfile(\$scalar)", or from an installed package using "OpenBSD::PackingList->from_installation($pkgname)".

Since building a full packing-list is a complex operation and can consume a large amount of memory, those methods may take an extra argument in order to obtain partial packing-lists with only some information:

SharedItemsOnly
    read only stuff that may be shared between packages, e.g., new users, groups and directories.

LibraryOnly
    read only shared library entries.

FilesOnly
    read only files without the associated annotations like size or MD5.

DependOnly
    read only dependency information.

ExtraInfoOnly
    read only the extra information field.

UpdateInfoOnly
    read only what is needed to decide to update a package.

PrelinkStuffOnly
    read only what is need to figure out all binary/library information, e.g., libraries, dependencies and binaries.

A complete packing-list $plist may be written to disk using the following methods: "$plist->write($fh)" will write a packing-list to an opened file handle $fh, "$plist->tofile($filename)" will write a packing-list to a file named $filename, and "$plist->to_installation" will write a packing-list during registration of a package.

In addition "$plist->to_cache" will register enough information from a package to let the framework believe the package has been installed. This is used for the simulation modes of pkg_add(1) and friends.

Since a packing-list is structured information, reading a packing-list from the disk and writing it back offers no guarantee the information will remain in the same order. It is a good way to validate packing-lists and normalize them, though.

Building packing-lists entails cooperation with "OpenBSD::PackingElement". Packing-lists are usually built by adding objects from an "OpenBSD::PackingElement" subclass to the packing-list, either with the "add" constructor: "OpenBSD::PackingElement::SUBCLASS->add($plist, $args)", which builds a packing element and adds it to the packing-list in one operation, or with the "add_object" method, which takes an existing packing element and adds it to the packing-list (note that "add_object" only makes sense for subclasses of "OpenBSD::PackingElement::Object"). See OpenBSD::PackingElement for more details.

"$plist->pkgname" retrieves a packing-list name (mandatory). "$plist->signature" retrieves a packing-list full signature, composed of the package name and dependency information.

"$plist->visit($method, @args)" is a visitor pattern, calling "method(@args)" on each element of the packing-list in a specific order.

As a feature, if "OpenBSD::PackingElement->can(method)", "$plist->method(@args)" will be turned into a visitor call automatically.