package Greenstone::Package::_pacman;

use strict;
use warnings;
use utf8;
use parent 'Greenstone::Package';
use Digest::MD5;

sub replacement_array {
    my $self = shift;
    my $array = shift;
    return join "\n", @{$array};
}

sub add_md5 {
    my $self = shift;
    my $md5 = Digest::MD5->new;
    for my $source (@_) {
        open my $MD5FH, '<', "$self->{output}/$source";
        binmode $MD5FH;
        $md5->addfile ($MD5FH);
        push @{$self->{config}->{SOURCE_SUMS}}, $md5->hexdigest;
        close $MD5FH
    }
}

sub add_sources {
    my $self = shift;
    $self->SUPER::add_sources;
    $self->{config}->{SOURCE_SUMS} = [];
    $self->add_md5 (@{$self->{config}->{SOURCES}});
}

sub add_makefile {
    my $self = shift;
    $self->SUPER::add_makefile;
    $self->add_md5 ('Makefile');
}

1;
