File: DebHelperFile.pm

package info (click to toggle)
libconfig-model-dpkg-perl 3.017
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,048 kB
  • sloc: perl: 8,530; python: 242; makefile: 77; javascript: 16; sh: 1
file content (89 lines) | stat: -rw-r--r-- 2,251 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package Config::Model::Backend::Dpkg::DebHelperFile;

use strict;
use warnings;
use Mouse;

extends 'Config::Model::Backend::PlainFile';

use 5.20.1;

use feature qw/postderef signatures/;
no warnings qw/experimental::postderef experimental::signatures/;

use Carp;
use Config::Model::Exception;
use Log::Log4perl qw(get_logger);
use IO::File;
use Path::Tiny;

my $logger = get_logger("Backend.Dpkg.DebHelperFile");
my $user_logger = get_logger('User');

my $misc_install_regexp = qr/\.(docs)$/;

sub get_misc_install_regexp () {
    return $misc_install_regexp;
}

sub get_file_name {
    my ($self, %args) = @_;

    my $obj = $args{object}->fetch_element( name => $args{elt} );
    my $dh_file_type =  $args{file} ? $obj->compute_string($args{file}) : $args{elt};

    my $key = $obj->parent->index_value;
    return $key eq '.'  ? $dh_file_type
        :  $key =~ $misc_install_regexp ? $key
        :  $key =~ m!^\./! ? $key =~ s!\./!$dh_file_type.!r
        :  $key =~ m!/! ? $key =~ s!/!.$dh_file_type.!r
        :                 "$key.$dh_file_type";
}

1;

# ABSTRACT: Read and write DebHelper files

__END__

=head1 NAME

Config::Model::Backend::Dpkg::DebHelperFile - R/W backend for DebHelper files

=head1 SYNOPSIS

No synopsis. Internal class for cme dpkg

=head1 DESCRIPTION

This backend module is used directly by L<Config::Model> to read or
write the content of Debian DebHelper files like C<debian/install>,
C<debian/package.postinst> and any variation thereof.

The backend must be declared with:

 'backend' => 'Dpkg::DebHelperFile',
 'config_dir' => 'debian',
 'file' => 'install'

The C<file> parameter specifies the "main" name of the dh file, for
instance "install", "postinst" ... This parameter can also be used to
specify a file name that take into account the path in the tree using
C<&index()> and C<&element()> functions from
L<Config::Model::Role::ComputeFunction>.

The backend will then be able to load files like C<install>,
C<pkg.install>, C<pkg.postinst.amd64>...

This backend is derived from L<Config::Model::Backend::PlainFile>

=head1 AUTHOR

Dominique Dumont, (dod at debian.org)

=head1 SEE ALSO

L<Config::Model>, L<Config::Model::Backend::PlainFile>, L<Config::Model::Backend::Any>, L<debhelper(7)>

=cut