This file is indexed.

/usr/share/perl5/Carton/Snapshot/Parser.pm is in carton 1.0.12-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package Carton::Snapshot::Parser;
use Moo;
use warnings NONFATAL => 'all';
use Carton::Dist;
use Carton::Error;

my $machine = {
    init => [
        {
            re => qr/^\# carton snapshot format: version (1\.0)/,
            code => sub {
                my($stash, $snapshot, $ver) = @_;
                $snapshot->version($ver);
            },
            goto => 'section',
        },
        # TODO support pasing error and version mismatch etc.
    ],
    section => [
        {
            re => qr/^DISTRIBUTIONS$/,
            goto => 'dists',
        },
        {
            re => qr/^__EOF__$/,
            done => 1,
        },
    ],
    dists => [
        {
            re => qr/^  (\S+)$/,
            code => sub { $_[0]->{dist} = Carton::Dist->new(name => $1) },
            goto => 'distmeta',
        },
        {
            re => qr/^\S/,
            goto => 'section',
            redo => 1,
        },
    ],
    distmeta => [
        {
            re => qr/^    pathname: (.*)$/,
            code => sub { $_[0]->{dist}->pathname($1) },
        },
        {
            re => qr/^\s{4}provides:$/,
            code => sub { $_[0]->{property} = 'provides' },
            goto => 'properties',
        },
        {
            re => qr/^\s{4}requirements:$/,
            code => sub {
                $_[0]->{property} = 'requirements';
            },
            goto => 'properties',
        },
        {
            re => qr/^\s{0,2}\S/,
            code => sub {
                my($stash, $snapshot) = @_;
                $snapshot->add_distribution($stash->{dist});
                %$stash = (); # clear
            },
            goto => 'dists',
            redo => 1,
        },
    ],
    properties => [
        {
            re => qr/^\s{6}([0-9A-Za-z_:]+) ([v0-9\._,=\!<>\s]+|undef)/,
            code => sub {
                my($stash, $snapshot, $module, $version) = @_;

                if ($stash->{property} eq 'provides') {
                    $stash->{dist}->provides->{$module} = { version => $version };
                } else {
                    $stash->{dist}->add_string_requirement($module, $version);
                }
            },
        },
        {
            re => qr/^\s{0,4}\S/,
            goto => 'distmeta',
            redo => 1,
        },
    ],
};

sub parse {
    my($self, $data, $snapshot) = @_;

    my @lines = split /\r?\n/, $data;

    my $state = $machine->{init};
    my $stash = {};

    LINE:
    for my $line (@lines, '__EOF__') {
        last LINE unless @$state;

    STATE: {
            for my $trans (@{$state}) {
                if (my @match = $line =~ $trans->{re}) {
                    if (my $code = $trans->{code}) {
                        $code->($stash, $snapshot, @match);
                    }
                    if (my $goto = $trans->{goto}) {
                        $state = $machine->{$goto};
                        if ($trans->{redo}) {
                            redo STATE;
                        } else {
                            next LINE;
                        }
                    }

                    last STATE;
                }
            }

            Carton::Error::SnapshotParseError->throw(error => "Could not parse snapshot file.");
        }
    }
}

1;