Arepa
view release on metacpan or search on metacpan
lib/Arepa/Repository.pm view on Meta::CPAN
print STDERR "Can't open $distributions_config_file for writing\n";
return 0;
};
print F <<EOD;
$serialised_distro
EOD
close F;
# Now, update the repository with the new distro
$self->_execute_reprepro('export', $properties{codename});
}
sub sign_distribution {
my ($self, $distro_name) = @_;
my $repo_path = $self->get_config_key('repository:path');
my $release_file_path = File::Spec->catfile($repo_path,
"dists",
$distro_name,
"Release");
unlink "$release_file_path.gpg";
my $extra_options = "";
if ($self->config_key_exists('repository:signature:id')) {
my $key_id = $self->get_config_key('repository:signature:id');
$extra_options = " -u $key_id";
}
my $gpg_cmd = "gpg --batch -abs $extra_options -o $release_file_path.gpg $release_file_path >/dev/null";
return (system($gpg_cmd) == 0);
}
sub sync_remote {
my ($self) = @_;
my $repo_path = $self->get_config_key('repository:path');
if ($self->config_key_exists('repository:remote_path')) {
my $remote_repo_path = $self->get_config_key('repository:remote_path');
my $rsync_cmd = "rsync -avz --delete $repo_path $remote_repo_path";
if (system($rsync_cmd) == 0) {
return 1;
}
else {
print STDERR "Command was '$rsync_cmd'\n";
return 0;
}
}
return 0;
}
sub is_synced {
my ($self) = @_;
my $repo_path = $self->get_config_key('repository:path');
if ($self->config_key_exists('repository:remote_path')) {
my $remote_repo_path = $self->get_config_key('repository:remote_path');
my $rsync_cmd = "rsync -avz --delete --dry-run --out-format='AREPA_CHANGE %i' $repo_path $remote_repo_path";
my $changes = 0;
open RSYNCOUTPUT, "$rsync_cmd |";
while (<RSYNCOUTPUT>) {
next unless /^AREPA_CHANGE/;
if (/^AREPA_CHANGE [^.]/) {
$changes = 1;
}
}
close RSYNCOUTPUT;
return (! $changes);
}
return 0;
}
1;
__END__
=head1 NAME
Arepa::Repository - Arepa repository access class
=head1 SYNOPSIS
my $repo = Arepa::Repository->new('path/to/config.yml');
my $value = $repo->get_config_key('repository:path');
my @distros = $repo->get_distributions;
my @archs = $repo->get_architectures;
my $bool = $repo->insert_source_package($dsc_file, $distro);
my $bool = $repo->insert_source_package($dsc_file, $distro,
priority => 'optional',
section => 'perl');
my $bool = $repo->insert_source_package($dsc_file, $distro,
priority => 'optional',
section => 'perl',
comments => 'Why this was approved',
canonical_distro => 'lenny');
my $bool = $repo->insert_binary_package($deb_file, $distro);
my $text = $repo->last_cmd_output;
=head1 DESCRIPTION
This class represents a reprepro-managed APT repository. It allows you get
information about the repository and to insert new source and binary packages
in it.
It uses the Arepa configuration to get the repository path, and the own
repository reprepro configuration to figure out the distributions and
architectures inside it.
=head1 METHODS
=over 4
=item new($path)
Creates a new repository access object, using the configuration file in
C<$path>.
=item get_config_key($key)
Gets the configuration key C<$key> from the Arepa configuration.
=item get_distributions
Returns an array of hashrefs. Each hashref represents a distribution declared
in the repository C<conf/distributions> configuration file, and contains a
(always lowercase) key for every distribution attribute.
( run in 0.802 second using v1.01-cache-2.11-cpan-39bf76dae61 )