<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># Copyright Â© 1998 Richard Braakman
# Copyright Â© 1999 Darren Benham
# Copyright Â© 2000 Sean 'Shaleh' Perry
# Copyright Â© 2004 Frank Lichtenheld
# Copyright Â© 2006 Russ Allbery
# Copyright Â© 2007-2009 RaphaÃ«l Hertzog &lt;hertzog@debian.org&gt;
# Copyright Â© 2008-2009, 2012-2014 Guillem Jover &lt;guillem@debian.org&gt;
#
# This program is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see &lt;https://www.gnu.org/licenses/&gt;.

=encoding utf8

=head1 NAME

Dpkg::Deps::Multiple - base module to represent multiple dependencies

=head1 DESCRIPTION

The Dpkg::Deps::Multiple module provides objects implementing various types
of dependencies. It is the base class for Dpkg::Deps::{AND,OR,Union}.

=cut

package Dpkg::Deps::Multiple 1.02;

use strict;
use warnings;

use Carp;

use Dpkg::ErrorHandling;

use parent qw(Dpkg::Interface::Storable);

=head1 METHODS

=over 4

=item $dep = Dpkg::Deps::Multiple-&gt;new(%opts);

Creates a new object.

=cut

sub new {
    my ($this, @deps) = @_;
    my $class = ref($this) || $this;
    my $self = { list =&gt; [ @deps ] };

    bless $self, $class;
    return $self;
}

=item $dep-&gt;reset()

Clears any dependency information stored in $dep so that $dep-&gt;is_empty()
returns true.

=cut

sub reset {
    my $self = shift;

    $self-&gt;{list} = [];
}

=item $dep-&gt;add(@deps)

Adds new dependency objects at the end of the list.

=cut

sub add {
    my ($self, @deps) = @_;

    push @{$self-&gt;{list}}, @deps;
}

=item $dep-&gt;get_deps()

Returns a list of sub-dependencies.

=cut

sub get_deps {
    my $self = shift;

    return grep { not $_-&gt;is_empty() } @{$self-&gt;{list}};
}

=item $dep-&gt;sort()

Sorts alphabetically the internal list of dependencies.

=cut

sub sort {
    my $self = shift;

    my @res = ();
    @res = sort { Dpkg::Deps::deps_compare($a, $b) } @{$self-&gt;{list}};
    $self-&gt;{list} = [ @res ];
}

=item $dep-&gt;arch_is_concerned($arch)

Returns true if at least one of the sub-dependencies apply to this
architecture.

=cut

sub arch_is_concerned {
    my ($self, $host_arch) = @_;

    my $res = 0;
    foreach my $dep (@{$self-&gt;{list}}) {
        $res = 1 if $dep-&gt;arch_is_concerned($host_arch);
    }
    return $res;
}

=item $dep-&gt;reduce_arch($arch)

Simplifies the dependencies to contain only information relevant to the
given architecture. The non-relevant sub-dependencies are simply removed.

This trims off the architecture restriction list of L&lt;Dpkg::Deps::Simple&gt;
objects.

=cut

sub reduce_arch {
    my ($self, $host_arch) = @_;

    my @new;
    foreach my $dep (@{$self-&gt;{list}}) {
        $dep-&gt;reduce_arch($host_arch);
        push @new, $dep if $dep-&gt;arch_is_concerned($host_arch);
    }
    $self-&gt;{list} = [ @new ];
}

=item $dep-&gt;has_arch_restriction()

Returns the list of package names that have such a restriction.

=cut

sub has_arch_restriction {
    my $self = shift;

    my @res;
    foreach my $dep (@{$self-&gt;{list}}) {
        push @res, $dep-&gt;has_arch_restriction();
    }
    return @res;
}

=item $dep-&gt;profile_is_concerned()

Returns true if at least one of the sub-dependencies apply to this profile.

=cut

sub profile_is_concerned {
    my ($self, $build_profiles) = @_;

    my $res = 0;
    foreach my $dep (@{$self-&gt;{list}}) {
        $res = 1 if $dep-&gt;profile_is_concerned($build_profiles);
    }
    return $res;
}

=item $dep-&gt;reduce_profiles()

Simplifies the dependencies to contain only information relevant to the
given profile. The non-relevant sub-dependencies are simply removed.

This trims off the profile restriction list of L&lt;Dpkg::Deps::Simple&gt; objects.

=cut

sub reduce_profiles {
    my ($self, $build_profiles) = @_;

    my @new;
    foreach my $dep (@{$self-&gt;{list}}) {
        $dep-&gt;reduce_profiles($build_profiles);
        push @new, $dep if $dep-&gt;profile_is_concerned($build_profiles);
    }
    $self-&gt;{list} = [ @new ];
}

=item $dep-&gt;is_empty()

Returns true if the dependency is empty and doesn't contain any useful
information. This is true when a (descendant of) L&lt;Dpkg::Deps::Multiple&gt;
contains an empty list of dependencies.

=cut

sub is_empty {
    my $self = shift;

    return scalar @{$self-&gt;{list}} == 0;
}

=item $dep-&gt;merge_union($other_dep)

This method is not meaningful for this object, and will always croak.

=cut

sub merge_union {
    croak 'method merge_union() is only valid for Dpkg::Deps::Simple';
}

=back

=head1 CHANGES

=head2 Version 1.02 (dpkg 1.17.10)

New methods: Add $dep-&gt;profile_is_concerned() and $dep-&gt;reduce_profiles().

=head2 Version 1.01 (dpkg 1.16.1)

New method: Add $dep-&gt;reset().

=head2 Version 1.00 (dpkg 1.15.6)

Mark the module as public.

=cut

1;
</pre></body></html>