| 1 | # $Id: Repository.pm 2434 2017-10-28 12:25:04Z guillomovitch $ | ||||||||||||||||||||||||||||
| 2 | package Youri::Repository; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | =head1 NAME | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | Youri::Repository - Abstract repository | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | This abstract class defines Youri::Repository interface. | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =cut | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Youri::Package; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use List::MoreUtils qw(uniq); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use version; our $VERSION = qv('0.1.3'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 CLASS METHODS | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =head2 new(%args) | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | Creates and returns a new Youri::Repository object. | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | No generic parameters (subclasses may define additional ones). | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | Warning: do not call directly, call subclass constructor instead. | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub new { | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 0 | ▶ | croak "Abstract class" if $class eq __PACKAGE__; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my %options = ( | |||||||||||||||||||||||||||
| 39 | install_root => '', # path to top-level directory | ||||||||||||||||||||||||||||
| 40 | archive_root => '', # path to top-level directory | ||||||||||||||||||||||||||||
| 41 | version_root => '', # path to top-level directory | ||||||||||||||||||||||||||||
| 42 | test => 0, # test mode | ||||||||||||||||||||||||||||
| 43 | verbose => 0, # verbose mode | ||||||||||||||||||||||||||||
| 44 | @_ | ||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | croak "no install root" unless $options{install_root}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | croak "invalid install root" unless -d $options{install_root}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | my $self = bless { | ||||||||||||||||||||||||||||
| 52 | _install_root => $options{install_root}, | ||||||||||||||||||||||||||||
| 53 | _archive_root => $options{archive_root}, | ||||||||||||||||||||||||||||
| 54 | _version_root => $options{version_root}, | ||||||||||||||||||||||||||||
| 55 | _test => $options{test}, | ||||||||||||||||||||||||||||
| 56 | _verbose => $options{verbose}, | ||||||||||||||||||||||||||||
| 57 | 0 | }, $class; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | $self->_init(%options); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 0 | return $self; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | ▶ | sub _init { | |||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 65 | # do nothing | ||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head1 INSTANCE METHODS | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head2 get_package_class() | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | Return package class for this repository. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | sub get_package_class { | ||||||||||||||||||||||||||||
| 77 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_package_class: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 0 | return $self->{_package_class}; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head2 get_package_charset() | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Return package charset for this repository. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | sub get_package_charset { | ||||||||||||||||||||||||||||
| 89 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_package_charset: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | 0 | return $self->{_package_charset}; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head2 get_extra_arches() | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Return the list of additional archictectures to handle when dealing with noarch | ||||||||||||||||||||||||||||
| 97 | packages. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =cut | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | sub get_extra_arches { | ||||||||||||||||||||||||||||
| 102 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_extra_arches: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 103 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 0 | return @{$self->{_extra_arches}}; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head2 get_target_arches() | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | Return the list of additional archictectures to handle when dealing | ||||||||||||||||||||||||||||
| 111 | with noarch packages for a given target. | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =cut | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | sub get_target_arches { | ||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my ($self, $target) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_target_arches: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | return $target && $self->{_arch}{$target} ? | ||||||||||||||||||||||||||||
| 119 | 0 | ▶ | @{$self->{_arch}{$target}} : @{$self->{_extra_arches}}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$target and $self->{"_arch"}{$target}
MC/DC0%0/2
$target and $self->{"_arch"}{$target}
$target
$self->{"_arch"}{$target}
Truth table0%0/3
A and B
A= $targetB= $self->{"_arch"}{$target}
| |||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =head2 get_older_revisions($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | Get all older revisions from a package found in its installation directory, as a | ||||||||||||||||||||||||||||
| 126 | list of L<Youri::Package> objects. | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =cut | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | sub get_older_revisions { | ||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_older_revisions: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 132 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | print "Looking for package $package older revisions for $target\n" | ||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if $self->{_verbose} > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | return $self->get_revisions( | ||||||||||||||||||||||||||||
| 137 | $package, | ||||||||||||||||||||||||||||
| 138 | $target, | ||||||||||||||||||||||||||||
| 139 | $user_context, | ||||||||||||||||||||||||||||
| 140 | $app_context, | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub { return $package->compare($_[0]) > 0 } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 142 | 0 | ); | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =head2 get_last_older_revision($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | Get last older revision from a package found in its installation directory, as a | ||||||||||||||||||||||||||||
| 148 | single L<Youri::Package> object. | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | sub get_last_older_revision { | ||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_last_older_revision: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | print "Looking for package $package last older revision for $target\n" | ||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if $self->{_verbose} > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | return ( | ||||||||||||||||||||||||||||
| 159 | 0 | $self->get_older_revisions( | |||||||||||||||||||||||||||
| 160 | $package, | ||||||||||||||||||||||||||||
| 161 | $target, | ||||||||||||||||||||||||||||
| 162 | $user_context, | ||||||||||||||||||||||||||||
| 163 | $app_context | ||||||||||||||||||||||||||||
| 164 | ) | ||||||||||||||||||||||||||||
| 165 | )[0]; | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | =head2 get_newer_revisions($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | Get all newer revisions from a package found in its installation directory, as | ||||||||||||||||||||||||||||
| 171 | a list of L<Youri::Package> objects. | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | sub get_newer_revisions { | ||||||||||||||||||||||||||||
| 176 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_newer_revisions: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 177 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | print "Looking for package $package newer revisions for $target\n" | ||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if $self->{_verbose} > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | return $self->get_revisions( | ||||||||||||||||||||||||||||
| 182 | $package, | ||||||||||||||||||||||||||||
| 183 | $target, | ||||||||||||||||||||||||||||
| 184 | $user_context, | ||||||||||||||||||||||||||||
| 185 | $app_context, | ||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub { return $_[0]->compare($package) > 0 } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 187 | 0 | ); | |||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | =head2 get_revisions($package, $target, $user_context, $app_context, $filter) | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | Get all revisions from a package found in its installation directory, using an | ||||||||||||||||||||||||||||
| 194 | optional filter, as a list of L<Youri::Package> objects. | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | =cut | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | sub get_revisions { | ||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context, $filter) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_revisions: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 200 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | print "Looking for package $package revisions for $target\n" | ||||||||||||||||||||||||||||
| 202 | 0 | ▶ | if $self->{_verbose} > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | my @arches = $package->get_arch() eq 'noarch' ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | ( $self->get_target_arches($target), 'noarch' ) : | ||||||||||||||||||||||||||||
| 206 | ( $package->get_arch(), 'noarch' ); | ||||||||||||||||||||||||||||
| 207 | my @packages = | ||||||||||||||||||||||||||||
| 208 | 0 | map { $self->get_package_class()->new(file => $_) } | |||||||||||||||||||||||||||
| 209 | map { | ||||||||||||||||||||||||||||
| 210 | 0 | $self->get_files( | |||||||||||||||||||||||||||
| 211 | $self->{_install_root}, | ||||||||||||||||||||||||||||
| 212 | 0 | $self->get_install_path( | |||||||||||||||||||||||||||
| 213 | $package, | ||||||||||||||||||||||||||||
| 214 | $target, | ||||||||||||||||||||||||||||
| 215 | $user_context, | ||||||||||||||||||||||||||||
| 216 | $app_context | ||||||||||||||||||||||||||||
| 217 | ), | ||||||||||||||||||||||||||||
| 218 | $self->get_package_class()->get_pattern( | ||||||||||||||||||||||||||||
| 219 | $package->get_name(), | ||||||||||||||||||||||||||||
| 220 | undef, | ||||||||||||||||||||||||||||
| 221 | undef, | ||||||||||||||||||||||||||||
| 222 | $_ | ||||||||||||||||||||||||||||
| 223 | ) | ||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||
| 225 | } @arches; | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | ▶ | @packages = grep { $filter->($_) } @packages if $filter; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | # | ||||||||||||||||||||||||||||
| 229 | # sort by revision order | ||||||||||||||||||||||||||||
| 230 | 0 | @packages = sort { $b->compare($a) } @packages; | |||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 0 | return @packages; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | =head2 get_obsoleted_packages($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | Get all packages obsoleted by given one, as a list of L<Youri::Package> | ||||||||||||||||||||||||||||
| 238 | objects. | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | =cut | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | sub get_obsoleted_packages { | ||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_obsoleted_packages: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | print "Looking for packages obsoleted by $package for $target\n" | ||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if $self->{_verbose} > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | my @packages; | |||||||||||||||||||||||||||
| 249 | 0 | foreach my $obsolete ($package->get_obsoletes()) { | |||||||||||||||||||||||||||
| 250 | 0 | my $pattern = $self->get_package_class()->get_pattern( | |||||||||||||||||||||||||||
| 251 | $obsolete->get_name() | ||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||
| 253 | 0 | my $range = $obsolete->get_range(); | |||||||||||||||||||||||||||
| 254 | push(@packages, | ||||||||||||||||||||||||||||
| 255 | 0 | ▶ | grep { $range ? $_->satisfy_range($range) : 1 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 0 | map { $self->get_package_class()->new(file => $_) } | |||||||||||||||||||||||||||
| 257 | $self->get_files( | ||||||||||||||||||||||||||||
| 258 | $self->{_install_root}, | ||||||||||||||||||||||||||||
| 259 | 0 | $self->get_install_path( | |||||||||||||||||||||||||||
| 260 | $package, $target, | ||||||||||||||||||||||||||||
| 261 | $user_context, | ||||||||||||||||||||||||||||
| 262 | $app_context | ||||||||||||||||||||||||||||
| 263 | ), | ||||||||||||||||||||||||||||
| 264 | $pattern | ||||||||||||||||||||||||||||
| 265 | ) | ||||||||||||||||||||||||||||
| 266 | ); | ||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | return @packages; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head2 get_replaced_packages($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | Get all packages replaced by given one, as a list of L<Youri::Package> | ||||||||||||||||||||||||||||
| 275 | objects. | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | =cut | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | sub get_replaced_packages { | ||||||||||||||||||||||||||||
| 280 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_replaced_packages: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 281 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | print "Looking for packages replaced by $package for $target\n" | ||||||||||||||||||||||||||||
| 283 | 0 | ▶ | if $self->{_verbose} > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 0 | my @list; | |||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | # noarch packages are potentially linked from other directories | ||||||||||||||||||||||||||||
| 288 | 0 | ▶ | my @arches = $package->get_arch() eq 'noarch' ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | ( $self->get_target_arches($target), 'noarch' ) : | ||||||||||||||||||||||||||||
| 290 | ( $package->get_arch(), 'noarch' ); | ||||||||||||||||||||||||||||
| 291 | 0 | foreach my $arch (@arches) { | |||||||||||||||||||||||||||
| 292 | 0 | push(@list, $self->get_older_revisions( | |||||||||||||||||||||||||||
| 293 | $package, | ||||||||||||||||||||||||||||
| 294 | $target, | ||||||||||||||||||||||||||||
| 295 | $user_context, | ||||||||||||||||||||||||||||
| 296 | { arch => $arch } | ||||||||||||||||||||||||||||
| 297 | )); | ||||||||||||||||||||||||||||
| 298 | 0 | push(@list, $self->get_obsoleted_packages( | |||||||||||||||||||||||||||
| 299 | $package, | ||||||||||||||||||||||||||||
| 300 | $target, | ||||||||||||||||||||||||||||
| 301 | $user_context, | ||||||||||||||||||||||||||||
| 302 | { arch => $arch } | ||||||||||||||||||||||||||||
| 303 | )); | ||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 0 | return uniq(@list); | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =head2 get_files($path, $pattern) | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | Get all files found in a directory, using an optional filtering pattern | ||||||||||||||||||||||||||||
| 312 | (applied to the whole file name), as a list of files. | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =cut | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | sub get_files { | ||||||||||||||||||||||||||||
| 317 | 0 | ▶ | my ($self, $root, $path, $pattern) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_files: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 318 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | my @files; | |||||||||||||||||||||||||||
| 321 | 0 | my $dir = "$root/$path"; | |||||||||||||||||||||||||||
| 322 | 0 | ▶ | $pattern = '.*' unless defined $pattern; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 323 | 0 | my $comp_pattern = qr/^$pattern$/; | |||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | print "Looking for files matching $pattern in $root/$path\n" | ||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if $self->{_verbose} > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | ▶ | opendir(my $dh, $dir) or die "Can't open $dir: $!"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | 0 | ▶ | while (my $file = readdir($dh)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 330 | 0 | ▶ | next unless $file =~ $comp_pattern; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 0 | $file = "$dir/$file"; | |||||||||||||||||||||||||||
| 332 | 0 | ▶ | next unless -f $file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | 0 | push(@files, $file); | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | 0 | closedir($dh); | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | return @files; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | =head2 get_install_root() | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | Returns installation root | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | =cut | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | sub get_install_root { | ||||||||||||||||||||||||||||
| 347 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_install_root: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 348 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 0 | return $self->{_install_root}; | |||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | =head2 get_install_dir($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | Returns install destination directory for given L<Youri::Package> object | ||||||||||||||||||||||||||||
| 356 | and given target. | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | =cut | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | sub get_install_dir { | ||||||||||||||||||||||||||||
| 361 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_install_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 362 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | return $self->_get_dir( | ||||||||||||||||||||||||||||
| 365 | $self->{_install_root}, | ||||||||||||||||||||||||||||
| 366 | 0 | $self->get_install_path($package, $target, $user_context, $app_context) | |||||||||||||||||||||||||||
| 367 | ); | ||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | =head2 get_archive_root() | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | Returns archiving root | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | =cut | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | sub get_archive_root { | ||||||||||||||||||||||||||||
| 377 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_archive_root: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 378 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 0 | return $self->{_archive_root}; | |||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | =head2 get_archive_dir($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | Returns archiving destination directory for given L<Youri::Package> object | ||||||||||||||||||||||||||||
| 386 | and given target. | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | =cut | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | sub get_archive_dir { | ||||||||||||||||||||||||||||
| 391 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_archive_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 392 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | return $self->_get_dir( | ||||||||||||||||||||||||||||
| 395 | $self->{_archive_root}, | ||||||||||||||||||||||||||||
| 396 | 0 | $self->get_archive_path($package, $target, $user_context, $app_context) | |||||||||||||||||||||||||||
| 397 | ); | ||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | =head2 get_version_root() | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | Returns versionning root | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | sub get_version_root { | ||||||||||||||||||||||||||||
| 408 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_version_root: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 409 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 0 | return $self->{_version_root}; | |||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | =head2 get_version_dir($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | Returns versioning destination directory for given L<Youri::Package> | ||||||||||||||||||||||||||||
| 417 | object and given target. | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | =cut | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | sub get_version_dir { | ||||||||||||||||||||||||||||
| 422 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_version_dir: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 423 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | return $self->_get_dir( | ||||||||||||||||||||||||||||
| 426 | $self->{_version_root}, | ||||||||||||||||||||||||||||
| 427 | 0 | $self->get_version_path($package, $target, $user_context, $app_context) | |||||||||||||||||||||||||||
| 428 | ); | ||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | sub _get_dir { | ||||||||||||||||||||||||||||
| 432 | 0 | ▶ | my ($self, $root, $path) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_get_dir: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 0 | ▶ | return substr($path, 0, 1) eq '/' ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 435 | $path : | ||||||||||||||||||||||||||||
| 436 | $root . '/' . $path; | ||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | =head2 get_install_file($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | Returns install destination file for given L<Youri::Package> object and | ||||||||||||||||||||||||||||
| 442 | given target. | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | =cut | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | sub get_install_file { | ||||||||||||||||||||||||||||
| 447 | 0 | ▶ | my ($self, $package, $target, $user_context, $app_context) = @_; | ||||||||||||||||||||||||||
|
Subroutine
get_install_file: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 448 | 0 | ▶ | croak "Not a class method" unless ref $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | return | ||||||||||||||||||||||||||||
| 451 | 0 | $self->get_install_dir($package, $target, $user_context, $app_context) . | |||||||||||||||||||||||||||
| 452 | '/' . | ||||||||||||||||||||||||||||
| 453 | $package->get_file_name(); | ||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | =head2 get_install_path($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | Returns installation destination path (relative to repository root) for given | ||||||||||||||||||||||||||||
| 459 | L<Youri::Package> object and given target. | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | =head2 get_archive_path($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | Returns archiving destination path (relative to repository root) for given | ||||||||||||||||||||||||||||
| 464 | L<Youri::Package> object and given target. | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | =head2 get_version_path($package, $target, $user_context, $app_context) | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||
| 468 | Returns versioning destination path (relative to repository root) for given | ||||||||||||||||||||||||||||
| 469 | L<Youri::Package> object and given target. | ||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | =head1 SUBCLASSING | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | The following methods have to be implemented: | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | =over | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | =item get_install_path | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | =item get_archive_path | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | =item get_version_path | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | =back | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | Copyright (C) 2002-2006, YOURI project | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | =cut | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 1 | 1; | |||||||||||||||||||||||||||