Dpkg

 view release on metacpan or  search on metacpan

lib/Dpkg/Deps.pm  view on Meta::CPAN

    }

    return;
}

=item $dep = deps_concat(@dep_list)

This function concatenates multiple dependency lines into a single line,
joining them with ", " if appropriate, and always returning a valid string.

=cut

sub deps_concat {
    my (@dep_list) = @_;

    return join ', ', grep { defined } @dep_list;
}

=item $dep = deps_parse($line, %opts)

This function parses the dependency line and returns an object, either a
L<Dpkg::Deps::AND> or a L<Dpkg::Deps::Union>. Various options can alter the
behavior of that function.

=over 4

=item use_arch (defaults to 1)

Take into account the architecture restriction part of the dependencies.
Set to 0 to completely ignore that information.

=item host_arch (defaults to the current architecture)

Define the host architecture. By default it uses
Dpkg::Arch::get_host_arch() to identify the proper architecture.

=item build_arch (defaults to the current architecture)

Define the build architecture. By default it uses
Dpkg::Arch::get_build_arch() to identify the proper architecture.

=item reduce_arch (defaults to 0)

If set to 1, ignore dependencies that do not concern the current host
architecture. This implicitly strips off the architecture restriction
list so that the resulting dependencies are directly applicable to the
current architecture.

=item use_profiles (defaults to 1)

Take into account the profile restriction part of the dependencies. Set
to 0 to completely ignore that information.

=item build_profiles (defaults to no profile)

Define the active build profiles. By default no profile is defined.

=item reduce_profiles (defaults to 0)

If set to 1, ignore dependencies that do not concern the current build
profile. This implicitly strips off the profile restriction formula so
that the resulting dependencies are directly applicable to the current
profiles.

=item reduce_restrictions (defaults to 0)

If set to 1, ignore dependencies that do not concern the current set of
restrictions. This implicitly strips off any architecture restriction list
or restriction formula so that the resulting dependencies are directly
applicable to the current restriction.
This currently implies C<reduce_arch> and C<reduce_profiles>, and overrides
them if set.

=item union (defaults to 0)

If set to 1, returns a L<Dpkg::Deps::Union> instead of a L<Dpkg::Deps::AND>.
Use this when parsing non-dependency fields like Conflicts.

=item virtual (defaults to 0)

If set to 1, allow only virtual package version relations, that is none,
or "=".
This should be set whenever working with Provides fields.

=item build_dep (defaults to 0)

If set to 1, allow build-dep only arch qualifiers, that is ":native".
This should be set whenever working with build-deps.

=item tests_dep (defaults to 0)

If set to 1, allow tests-specific package names in dependencies, that is
"@" and "@builddeps@" (since dpkg 1.18.7). This should be set whenever
working with dependency fields from F<debian/tests/control>.

This option implicitly (and forcibly) enables C<build_dep> because test
dependencies are based on build dependencies (since dpkg 1.22.1).

=back

=cut

sub deps_parse {
    my ($dep_line, %opts) = @_;

    # Validate arguments.
    croak "invalid host_arch $opts{host_arch}"
        if defined $opts{host_arch} and not defined debarch_to_debtuple($opts{host_arch});
    croak "invalid build_arch $opts{build_arch}"
        if defined $opts{build_arch} and not defined debarch_to_debtuple($opts{build_arch});

    $opts{use_arch} //= 1;
    $opts{reduce_arch} //= 0;
    $opts{use_profiles} //= 1;
    $opts{reduce_profiles} //= 0;
    $opts{reduce_restrictions} //= 0;
    $opts{union} //= 0;
    $opts{virtual} //= 0;
    $opts{build_dep} //= 0;
    $opts{tests_dep} //= 0;

    if ($opts{reduce_restrictions}) {
        $opts{reduce_arch} = 1;
        $opts{reduce_profiles} = 1;
    }
    if ($opts{reduce_arch}) {
        $opts{host_arch} //= get_host_arch();
        $opts{build_arch} //= get_build_arch();
    }



( run in 1.611 second using v1.01-cache-2.11-cpan-39bf76dae61 )