| 1 | # | ||||||||||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # vim: set ts=2 sw=2 tw=0: | ||||||||||||||||||||||||||||
| 5 | # vim: set expandtab: | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | package Rex::Repositorio::Repository::Apt; | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use File::Basename qw'basename dirname'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Digest::SHA; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use IO::All; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | our $VERSION = '1.2.1'; # VERSION | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | extends "Rex::Repositorio::Repository::Base"; | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub mirror { | ||||||||||||||||||||||||||
|
Subroutine
mirror: not called CC=23 SCAR=63.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 0 | my ( $self, %option ) = @_; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | $self->repo->{url} =~ s/\/$//; | |||||||||||||||||||||||||||
| 27 | 0 | $self->repo->{local} =~ s/\/$//; | |||||||||||||||||||||||||||
| 28 | 0 | my $name = $self->repo->{name}; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | my $dist = $self->repo->{dist}; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | my @archs = split /, ?/, $self->repo->{arch}; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | ############################################################################## | ||||||||||||||||||||||||||||
| 35 | # get meta data | ||||||||||||||||||||||||||||
| 36 | ############################################################################## | ||||||||||||||||||||||||||||
| 37 | 0 | my $url = $self->repo->{url} . "/dists/${dist}"; | |||||||||||||||||||||||||||
| 38 | 0 | my $contents = $self->download("$url/Release"); | |||||||||||||||||||||||||||
| 39 | 0 | my $ref = $self->_parse_debian_release_file($contents); | |||||||||||||||||||||||||||
| 40 | 0 | my $arch = $self->repo->{arch}; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | $self->app->logger->notice('Downloading metadata...'); | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | my $destbase = $self->app->get_repo_dir(repo => $self->repo->{name}); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # try download Release and Release.gpg | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 48 | $self->download_metadata( | ||||||||||||||||||||||||||||
| 49 | url => $url . '/Release', | ||||||||||||||||||||||||||||
| 50 | dest => File::Spec->catfile('dists',$dist,'Release'), | ||||||||||||||||||||||||||||
| 51 | force => $option{update_metadata}, | ||||||||||||||||||||||||||||
| 52 | 0 | ); | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | $self->app->logger->info("1/2 ${url}"); | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | $self->download_metadata( | ||||||||||||||||||||||||||||
| 57 | url => $url . '/Release.gpg', | ||||||||||||||||||||||||||||
| 58 | dest => File::Spec->catfile('dists', $dist, 'Release.gpg'), | ||||||||||||||||||||||||||||
| 59 | force => $option{update_metadata}, | ||||||||||||||||||||||||||||
| 60 | 0 | ); | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | $self->app->logger->info("2/2 ${url}"); | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 66 | 0 | $self->app->logger->info("2/2 ${url}"); | |||||||||||||||||||||||||||
| 67 | 0 | $self->app->logger->error($_); | |||||||||||||||||||||||||||
| 68 | 0 | }; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | $self->app->logger->notice('Downloading file listing...'); | |||||||||||||||||||||||||||
| 72 | 0 | my $f_count = 0; | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $f_total = scalar( @{ $ref->{SHA1} || $ref->{SHA1Sum} } ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$ref->{'SHA1'} || $ref->{'SHA1Sum'}
MC/DC0%0/2
$ref->{'SHA1'} || $ref->{'SHA1Sum'}
$ref->{'SHA1'}
$ref->{'SHA1Sum'}
Truth table0%0/3
A || B
A= $ref->{'SHA1'}B= $ref->{'SHA1Sum'}
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | ▶ | for my $file_data ( @{ $ref->{SHA1} || $ref->{SHA1Sum} } ) { | ||||||||||||||||||||||||||
|
Condition0%0/3
$ref->{'SHA1'} || $ref->{'SHA1Sum'}
MC/DC0%0/2
$ref->{'SHA1'} || $ref->{'SHA1Sum'}
$ref->{'SHA1'}
$ref->{'SHA1Sum'}
Truth table0%0/3
A || B
A= $ref->{'SHA1'}B= $ref->{'SHA1Sum'}
| |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | my $file_url = $url . "/" . $file_data->{file}; | |||||||||||||||||||||||||||
| 78 | 0 | my $file = $file_data->{file}; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | $f_count++; | |||||||||||||||||||||||||||
| 81 | 0 | $self->app->logger->info("${f_count}/${f_total} ${file_url}"); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | my $arch_str = join( "|", @archs ); | |||||||||||||||||||||||||||
| 84 | 0 | my $regexp = qr{i18n|((Contents|binary|installer)\-(udeb-)?($arch_str))}; | |||||||||||||||||||||||||||
| 85 | next | ||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ( $file_data->{file} !~ $regexp ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 89 | $self->download_metadata( | ||||||||||||||||||||||||||||
| 90 | url => $file_url, | ||||||||||||||||||||||||||||
| 91 | dest => File::Spec->catfile('dists',$dist,$file), | ||||||||||||||||||||||||||||
| 92 | force => $option{update_metadata}, | ||||||||||||||||||||||||||||
| 93 | 0 | ); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 96 | 0 | $self->app->logger->info( | |||||||||||||||||||||||||||
| 97 | "Can't find the url: $file_url. " . "This should be no problem." ); | ||||||||||||||||||||||||||||
| 98 | 0 | $self->app->logger->info($_); | |||||||||||||||||||||||||||
| 99 | 0 | }; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | ############################################################################## | ||||||||||||||||||||||||||||
| 103 | # download packages | ||||||||||||||||||||||||||||
| 104 | ############################################################################## | ||||||||||||||||||||||||||||
| 105 | 0 | ▶ | if ( $option{update_files} || $option{force} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$option{"update_files"} or $option{"force"}
MC/DC0%0/2
$option{"update_files"} or $option{"force"}
$option{"update_files"}
$option{"force"}
Truth table0%0/3
A or B
A= $option{"update_files"}B= $option{"force"}
| |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | my @components; | |||||||||||||||||||||||||||
| 108 | 0 | ▶ | if ( exists $self->repo->{components} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 0 | @components = split /, ?/, $self->repo->{components}; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | else { | ||||||||||||||||||||||||||||
| 112 | 0 | @components = ( $self->repo->{component} ); | |||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||
| 114 | 0 | for my $component (@components) { | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | my $local_components_path = File::Spec->catdir( | ||||||||||||||||||||||||||||
| 117 | 0 | $self->app->get_repo_dir( repo => $self->repo->{name} ), | |||||||||||||||||||||||||||
| 118 | 'dists',$dist,$component); | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | for my $arch (@archs) { | |||||||||||||||||||||||||||
| 121 | 0 | $self->app->logger->debug( | |||||||||||||||||||||||||||
| 122 | "Processing ($name, $component) $dist / $arch"); | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | my $local_packages_path = File::Spec->catfile( | |||||||||||||||||||||||||||
| 125 | $local_components_path, "binary-$arch", 'Packages.gz'); | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | $self->app->logger->debug("Reading: $local_packages_path"); | |||||||||||||||||||||||||||
| 128 | 0 | my $content = $self->gunzip( io($local_packages_path)->binary->all ); | |||||||||||||||||||||||||||
| 129 | 0 | my $package_ref = $self->_parse_debian_package_file($content); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | $self->app->logger->notice("Downloading packages for ${component} (${arch})..."); | |||||||||||||||||||||||||||
| 132 | 0 | my $p_count = 0; | |||||||||||||||||||||||||||
| 133 | 0 | my $p_total = scalar( @{$package_ref} ); | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | for my $package ( @{$package_ref} ) { | |||||||||||||||||||||||||||
| 136 | 0 | my $package_url = $self->repo->{url} . "/" . $package->{Filename}; | |||||||||||||||||||||||||||
| 137 | 0 | my $package_name = $package->{Package}; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 0 | $p_count++; | |||||||||||||||||||||||||||
| 140 | 0 | $self->app->logger->info("${p_count}/$p_total ${package_url}"); | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | my $local_file = File::Spec->catfile($package->{Filename}); | |||||||||||||||||||||||||||
| 143 | $self->download_package( | ||||||||||||||||||||||||||||
| 144 | url => $package_url, | ||||||||||||||||||||||||||||
| 145 | name => $package_name, | ||||||||||||||||||||||||||||
| 146 | dest => $local_file, | ||||||||||||||||||||||||||||
| 147 | 0 | ▶ | cb => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 148 | $self->_checksum( @_, "sha1", | ||||||||||||||||||||||||||||
| 149 | 0 | ▶ | ( $package->{SHA1} || $package->{SHA1Sum} ) ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$package->{'SHA1'} || $package->{'SHA1Sum'}
MC/DC0%0/2
$package->{'SHA1'} || $package->{'SHA1Sum'}
$package->{'SHA1'}
$package->{'SHA1Sum'}
Truth table0%0/3
A || B
A= $package->{'SHA1'}B= $package->{'SHA1Sum'}
| |||||||||||||||||||||||||||||
| 150 | }, | ||||||||||||||||||||||||||||
| 151 | force => $option{force}, | ||||||||||||||||||||||||||||
| 152 | update_file => $option{update_files}, | ||||||||||||||||||||||||||||
| 153 | 0 | ); | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ( exists $self->repo->{images} && $self->repo->{images} eq "true" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->repo->{"images"} and $self->repo->{"images"} eq "true"
MC/DC0%0/2
exists $self->repo->{"images"} and $self->repo->{"images"} eq "true"
exists $self->repo->{"images"}
$self->repo->{"images"} eq "true"
Truth table0%0/3
A and B
A= exists $self->repo->{"images"}B= $self->repo->{"images"} eq "true"
| |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | # installer components | ||||||||||||||||||||||||||||
| 160 | 0 | for my $arch (@archs) { | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | next if ( "\L$arch" eq "all" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | next if ( "\L$component" ne "main" ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | $self->app->logger->debug( | |||||||||||||||||||||||||||
| 166 | "Processing installer ($name, $component) $dist / $arch"); | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | my $local_packages_path; | |||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ( | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 170 | -d File::Spec->catdir( $local_components_path, "debian-installer" ) | ||||||||||||||||||||||||||||
| 171 | ) | ||||||||||||||||||||||||||||
| 172 | { | ||||||||||||||||||||||||||||
| 173 | 0 | $local_packages_path = File::Spec->catfile( | |||||||||||||||||||||||||||
| 174 | $local_components_path, "debian-installer", | ||||||||||||||||||||||||||||
| 175 | "binary-$arch", "Packages.gz" | ||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | elsif ( | ||||||||||||||||||||||||||||
| 179 | -d File::Spec->catdir( $local_components_path, "ubuntu-installer" ) | ||||||||||||||||||||||||||||
| 180 | ) | ||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||
| 182 | 0 | $local_packages_path = File::Spec->catfile( | |||||||||||||||||||||||||||
| 183 | $local_components_path, "ubuntu-installer", | ||||||||||||||||||||||||||||
| 184 | "binary-$arch", "Packages.gz" | ||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | else { | ||||||||||||||||||||||||||||
| 188 | 0 | $self->app->logger->error( | |||||||||||||||||||||||||||
| 189 | "Can't find Package.gz file for installer."); | ||||||||||||||||||||||||||||
| 190 | 0 | confess "Can't find Package.gz file for installer."; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | $self->app->logger->debug("Reading: $local_packages_path"); | |||||||||||||||||||||||||||
| 194 | 0 | my $content = $self->gunzip( io($local_packages_path)->binary->all ); | |||||||||||||||||||||||||||
| 195 | 0 | my $package_ref = $self->_parse_debian_package_file($content); | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | $self->app->logger->notice("Downloading installer packages for ${component} (${arch})..."); | |||||||||||||||||||||||||||
| 198 | 0 | my $p_count = 0; | |||||||||||||||||||||||||||
| 199 | 0 | my $p_total = scalar( @{$package_ref} ); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | for my $package ( @{$package_ref} ) { | |||||||||||||||||||||||||||
| 202 | 0 | my $package_url = $self->repo->{url} . "/" . $package->{Filename}; | |||||||||||||||||||||||||||
| 203 | 0 | my $package_name = $package->{Package}; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | $p_count++; | |||||||||||||||||||||||||||
| 206 | 0 | $self->app->logger->info("${p_count}/${p_total} ${package_url}"); | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | my $local_file = File::Spec->catfile($package->{Filename}); | |||||||||||||||||||||||||||
| 209 | $self->download_package( | ||||||||||||||||||||||||||||
| 210 | url => $package_url, | ||||||||||||||||||||||||||||
| 211 | name => $package_name, | ||||||||||||||||||||||||||||
| 212 | dest => $local_file, | ||||||||||||||||||||||||||||
| 213 | 0 | ▶ | cb => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 214 | $self->_checksum( @_, "sha1", | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | ( $package->{SHA1} || $package->{SHA1Sum} ) ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$package->{'SHA1'} || $package->{'SHA1Sum'}
MC/DC0%0/2
$package->{'SHA1'} || $package->{'SHA1Sum'}
$package->{'SHA1'}
$package->{'SHA1Sum'}
Truth table0%0/3
A || B
A= $package->{'SHA1'}B= $package->{'SHA1Sum'}
| |||||||||||||||||||||||||||||
| 216 | }, | ||||||||||||||||||||||||||||
| 217 | force => $option{update_files} | ||||||||||||||||||||||||||||
| 218 | 0 | ); | |||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | my $local_file_path = | |||||||||||||||||||||||||||
| 222 | File::Spec->catfile( $local_components_path, "installer-$arch", | ||||||||||||||||||||||||||||
| 223 | "current", "images" ); | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | $self->app->logger->debug( "Looking for SHA256SUMS file: " | |||||||||||||||||||||||||||
| 226 | . File::Spec->catfile( $local_file_path, "SHA256SUMS" ) ); | ||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ( !-f File::Spec->catfile( $local_file_path, "SHA256SUMS" ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 228 | 0 | $self->app->logger->error( | |||||||||||||||||||||||||||
| 229 | "need to download SHA256SUMS file, because it was not listed in Release file" | ||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||
| 231 | 0 | my $remote_sha256sums = $local_file_path . "/SHA256SUMS"; | |||||||||||||||||||||||||||
| 232 | my $repo_root = | ||||||||||||||||||||||||||||
| 233 | 0 | $self->app->get_repo_dir( repo => $self->repo->{name} ); | |||||||||||||||||||||||||||
| 234 | 0 | $self->app->logger->debug("Found repo root: $repo_root"); | |||||||||||||||||||||||||||
| 235 | 0 | $remote_sha256sums =~ s/^\Q$repo_root\E//; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | my $local_sha256sums_rel = File::Spec->catfile( | |||||||||||||||||||||||||||
| 238 | $remote_sha256sums); | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | $remote_sha256sums = $self->repo->{url} . $remote_sha256sums; | |||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 0 | $self->app->logger->debug( | |||||||||||||||||||||||||||
| 243 | "sha256sums download location: $remote_sha256sums -> $local_sha256sums_rel" | ||||||||||||||||||||||||||||
| 244 | ); | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | $self->download_metadata( | |||||||||||||||||||||||||||
| 247 | url => $remote_sha256sums, | ||||||||||||||||||||||||||||
| 248 | dest => $local_sha256sums_rel, | ||||||||||||||||||||||||||||
| 249 | ); | ||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | my $file_ref = | |||||||||||||||||||||||||||
| 253 | $self->_parse_sha256sum_file( File::Spec->catfile($local_file_path, 'SHA256SUMS' )); | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 0 | $self->app->logger->notice("Downloading installer image files for ${component} (${arch})..."); | |||||||||||||||||||||||||||
| 256 | 0 | my $f_count = 0; | |||||||||||||||||||||||||||
| 257 | 0 | my $f_total = scalar( @{$package_ref} ); | |||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | for my $file ( @{$file_ref} ) { | |||||||||||||||||||||||||||
| 260 | my $file_url = | ||||||||||||||||||||||||||||
| 261 | $self->repo->{url} | ||||||||||||||||||||||||||||
| 262 | . "/dists/$dist/$component/installer-$arch/current/images/" | ||||||||||||||||||||||||||||
| 263 | 0 | . $file->{file}; | |||||||||||||||||||||||||||
| 264 | 0 | my $file_name = $file->{file}; | |||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 0 | $f_count++; | |||||||||||||||||||||||||||
| 267 | 0 | $self->app->logger->info("${f_count}/$f_total ${file_url}"); | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | my $local_file = File::Spec->catfile( $self->repo->{local}, | ||||||||||||||||||||||||||||
| 270 | "dists", $dist, $component, "installer-$arch", "current", | ||||||||||||||||||||||||||||
| 271 | 0 | "images", $file->{file} ); | |||||||||||||||||||||||||||
| 272 | $self->download_package( | ||||||||||||||||||||||||||||
| 273 | url => $file_url, | ||||||||||||||||||||||||||||
| 274 | name => $file_name, | ||||||||||||||||||||||||||||
| 275 | dest => $local_file, | ||||||||||||||||||||||||||||
| 276 | 0 | ▶ | cb => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 277 | 0 | $self->_checksum( @_, "sha256", $file->{sha256} ); | |||||||||||||||||||||||||||
| 278 | }, | ||||||||||||||||||||||||||||
| 279 | force => $option{update_files} | ||||||||||||||||||||||||||||
| 280 | 0 | ); | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | ############################################################################## | ||||||||||||||||||||||||||||
| 287 | # download rest of metadata | ||||||||||||||||||||||||||||
| 288 | ############################################################################## | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | 0 | $self->app->logger->notice("Downloading rest of metadata..."); | |||||||||||||||||||||||||||
| 291 | 0 | my $m_count = 0; | |||||||||||||||||||||||||||
| 292 | 0 | my $m_total = ( 2 * scalar(@archs) ); | |||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | for my $arch (@archs) { | |||||||||||||||||||||||||||
| 295 | 0 | for my $suffix (qw/bz2 gz/) { | |||||||||||||||||||||||||||
| 296 | 0 | my $file_url = $url . "/Contents-$arch.$suffix"; | |||||||||||||||||||||||||||
| 297 | 0 | my $file = "Contents-$arch.$suffix"; | |||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 0 | $m_count++; | |||||||||||||||||||||||||||
| 300 | 0 | $self->app->logger->info("${m_count}/$m_total ${file_url}"); | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 303 | $self->download_metadata( | ||||||||||||||||||||||||||||
| 304 | url => $file_url, | ||||||||||||||||||||||||||||
| 305 | dest => File::Spec->catfile('dists',$dist,$file), | ||||||||||||||||||||||||||||
| 306 | force => $option{update_metadata}, | ||||||||||||||||||||||||||||
| 307 | 0 | ); | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 310 | 0 | $self->app->logger->error($_); | |||||||||||||||||||||||||||
| 311 | 0 | }; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub _parse_debian_release_file { | ||||||||||||||||||||||||||
|
Subroutine
_parse_debian_release_file: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 318 | 0 | my ( $self, $content ) = @_; | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | my $ret = {}; | |||||||||||||||||||||||||||
| 321 | 0 | my $section = "main"; | |||||||||||||||||||||||||||
| 322 | 0 | for my $line ( split /\n/, $content ) { | |||||||||||||||||||||||||||
| 323 | 0 | chomp $line; | |||||||||||||||||||||||||||
| 324 | 0 | ▶ | next if ( $line =~ m/^\s*?$/ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if ( $line !~ m/^\s/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | 0 | my ( $key, $value ) = split /:/, $line; | |||||||||||||||||||||||||||
| 328 | 0 | $value =~ s/^\s*|\s*$//; | |||||||||||||||||||||||||||
| 329 | 0 | $section = $key; | |||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ($value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | 0 | $ret->{$key} = $value; | |||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | else { | ||||||||||||||||||||||||||||
| 334 | 0 | $ret->{$key} = []; | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if ( $line =~ m/^\s/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | $line =~ s/^\s//; | |||||||||||||||||||||||||||
| 340 | 0 | my @values = split /\s+/, $line; | |||||||||||||||||||||||||||
| 341 | 0 | ▶ | if ( $ret->{$section} && !ref $ret->{$section} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ret->{$section} and not ref $ret->{$section}
MC/DC0%0/2
$ret->{$section} and not ref $ret->{$section}
$ret->{$section}
not ref $ret->{$section}
Truth table0%0/3
A and not(B)
A= $ret->{$section}B= not ref $ret->{$section}
| |||||||||||||||||||||||||||||
| 342 | 0 | $ret->{$section} = [ $ret->{$section} ]; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | 0 | push @{ $ret->{$section} }, | |||||||||||||||||||||||||||
| 345 | { | ||||||||||||||||||||||||||||
| 346 | checksum => $values[0], | ||||||||||||||||||||||||||||
| 347 | size => $values[1], | ||||||||||||||||||||||||||||
| 348 | file => $values[2], | ||||||||||||||||||||||||||||
| 349 | }; | ||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 0 | return $ret; | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub _parse_debian_package_file { | ||||||||||||||||||||||||||
|
Subroutine
_parse_debian_package_file: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 357 | 0 | my ( $self, $content ) = @_; | |||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | 0 | my @ret; | |||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | my $section; | ||||||||||||||||||||||||||||
| 362 | 0 | my $current_section; | |||||||||||||||||||||||||||
| 363 | 0 | for my $line ( split /\n/, $content ) { | |||||||||||||||||||||||||||
| 364 | 0 | chomp $line; | |||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ( $line =~ m/^$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 0 | push @ret, $current_section; | |||||||||||||||||||||||||||
| 368 | 0 | $current_section = {}; | |||||||||||||||||||||||||||
| 369 | 0 | next; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | my ( $key, $value ) = ( $line =~ m/^([A-Z0-9a-z\-]+):(.*)$/ ); | |||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 0 | ▶ | if ($key) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | 0 | $value =~ s/^\s//; | |||||||||||||||||||||||||||
| 376 | 0 | $section = $key; | |||||||||||||||||||||||||||
| 377 | 0 | $current_section->{$key} = $value; | |||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | else { | ||||||||||||||||||||||||||||
| 380 | 0 | $value = $line; | |||||||||||||||||||||||||||
| 381 | 0 | $value =~ s/^\s//; | |||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if ( $current_section->{$section} && !ref $current_section->{$section} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$current_section->{$section} and not ref $current_section->{$section}
MC/DC0%0/2
$current_section->{$section} and not ref $current_section->{$section}
$current_section->{$section}
not ref $current_section->{$section}
Truth table0%0/3
A and not(B)
A= $current_section->{$section}B= not ref $current_section->{$section}
| |||||||||||||||||||||||||||||
| 384 | 0 | $current_section->{$section} = [ $current_section->{$section} ]; | |||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 0 | push @{ $current_section->{$section} }, $value; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | # push last package | ||||||||||||||||||||||||||||
| 392 | 0 | push @ret, $current_section; | |||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | 0 | return \@ret; | |||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 0 | ▶ | sub _parse_sha256sum_file { | ||||||||||||||||||||||||||
|
Subroutine
_parse_sha256sum_file: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 398 | 0 | my ( $self, $file ) = @_; | |||||||||||||||||||||||||||
| 399 | 0 | my @files; | |||||||||||||||||||||||||||
| 400 | 0 | ▶ | open my $fh, "<", $file or die $!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 401 | 0 | ▶ | while ( my $line = <$fh> ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 402 | 0 | my ( $sum, $file_name ) = split( /\s+/, $line ); | |||||||||||||||||||||||||||
| 403 | 0 | $file_name =~ s/^\.\///; | |||||||||||||||||||||||||||
| 404 | 0 | push @files, { sha256 => $sum, file => $file_name }; | |||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | 0 | close $fh; | |||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | 0 | return \@files; | |||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 0 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 412 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | 0 | my $dist = $self->repo->{dist}; | |||||||||||||||||||||||||||
| 415 | 0 | my $arch = $self->repo->{arch}; | |||||||||||||||||||||||||||
| 416 | 0 | my $component = $self->repo->{component}; | |||||||||||||||||||||||||||
| 417 | 0 | ▶ | my $desc = $self->repo->{description} || "$component repository"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->repo->{'description'} || "$component repository"
MC/DC0%0/1
$self->repo->{'description'} || "$component repository"
$self->repo->{'description'}
Truth table0%0/2
A
A= $self->repo->{'description'}
| |||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | my $repo_dir = $self->app->get_repo_dir( repo => $self->repo->{name} ); | |||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 0 | File::Path->make_path(File::Spec->catdir($repo_dir,'dists',$dist,$component,"binary-$arch")); | |||||||||||||||||||||||||||
| 422 | 0 | File::Path->make_path(File::Spec->catdir($repo_dir,'pool',$dist,$component)); | |||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 0 | my $aptftp = io("$repo_dir/aptftp.conf"); | |||||||||||||||||||||||||||
| 425 | 0 | my $aptgenerate = io("$repo_dir/aptgenerate.conf"); | |||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | 0 | $aptftp->print(<<" EOF"); | |||||||||||||||||||||||||||
| 428 | APT::FTPArchive::Release { | ||||||||||||||||||||||||||||
| 429 | Origin "$component"; | ||||||||||||||||||||||||||||
| 430 | Label "$component"; | ||||||||||||||||||||||||||||
| 431 | Suite "$dist"; | ||||||||||||||||||||||||||||
| 432 | Codename "$dist"; | ||||||||||||||||||||||||||||
| 433 | Architectures "$arch"; | ||||||||||||||||||||||||||||
| 434 | Components "$component"; | ||||||||||||||||||||||||||||
| 435 | Description "$desc"; | ||||||||||||||||||||||||||||
| 436 | }; | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | EOF | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | 0 | $aptgenerate->print(<<" EOF"); | |||||||||||||||||||||||||||
| 441 | Dir::ArchiveDir "."; | ||||||||||||||||||||||||||||
| 442 | Dir::CacheDir "."; | ||||||||||||||||||||||||||||
| 443 | TreeDefault::Directory "pool/$dist/"; | ||||||||||||||||||||||||||||
| 444 | TreeDefault::SrcDirectory "pool/$dist/"; | ||||||||||||||||||||||||||||
| 445 | Default::Packages::Extensions ".deb"; | ||||||||||||||||||||||||||||
| 446 | Default::Packages::Compress ". gzip bzip2"; | ||||||||||||||||||||||||||||
| 447 | Default::Sources::Compress "gzip bzip2"; | ||||||||||||||||||||||||||||
| 448 | Default::Contents::Compress "gzip bzip2"; | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | BinDirectory "dists/$dist/$component/binary-$arch" { | ||||||||||||||||||||||||||||
| 451 | Packages "dists/$dist/$component/binary-$arch/Packages"; | ||||||||||||||||||||||||||||
| 452 | Contents "dists/$dist/Contents-$arch"; | ||||||||||||||||||||||||||||
| 453 | }; | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | Tree "dists/$dist" { | ||||||||||||||||||||||||||||
| 456 | Sections "$component"; | ||||||||||||||||||||||||||||
| 457 | Architectures "$arch"; | ||||||||||||||||||||||||||||
| 458 | }; | ||||||||||||||||||||||||||||
| 459 | EOF | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | 0 | $self->_run_ftp_archive(); | |||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | 0 | ▶ | sub add_file { | ||||||||||||||||||||||||||
|
Subroutine
add_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 465 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 466 | 0 | my %option = validate( | |||||||||||||||||||||||||||
| 467 | @_, | ||||||||||||||||||||||||||||
| 468 | { | ||||||||||||||||||||||||||||
| 469 | file => { | ||||||||||||||||||||||||||||
| 470 | type => SCALAR | ||||||||||||||||||||||||||||
| 471 | }, | ||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | ); | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 0 | my $dist = $self->repo->{dist}; | |||||||||||||||||||||||||||
| 476 | 0 | my $component = $self->repo->{component}; | |||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | my $dest = File::Spec->catdir( | ||||||||||||||||||||||||||||
| 479 | $self->app->get_repo_dir( repo => $self->repo->{name} ), | ||||||||||||||||||||||||||||
| 480 | 0 | 'pool',$dist,$component,basename( $option{file} )); | |||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | 0 | $self->add_file_to_repo( source => $option{file}, dest => $dest ); | |||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 0 | $self->_run_ftp_archive(); | |||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | 0 | ▶ | sub remove_file { | ||||||||||||||||||||||||||
|
Subroutine
remove_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 488 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | 0 | my %option = validate( | |||||||||||||||||||||||||||
| 491 | @_, | ||||||||||||||||||||||||||||
| 492 | { | ||||||||||||||||||||||||||||
| 493 | file => { | ||||||||||||||||||||||||||||
| 494 | type => SCALAR | ||||||||||||||||||||||||||||
| 495 | }, | ||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||
| 497 | ); | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 0 | my $dist = $self->repo->{dist}; | |||||||||||||||||||||||||||
| 500 | 0 | my $component = $self->repo->{component}; | |||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | my $file = File::Spec->catdir( | ||||||||||||||||||||||||||||
| 503 | $self->app->get_repo_dir( repo => $self->repo->{name} ), | ||||||||||||||||||||||||||||
| 504 | 0 | 'pool',$dist,$component,basename( $option{file} )); | |||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | 0 | $self->remove_file_from_repo( file => $file ); | |||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||
| 508 | 0 | $self->_run_ftp_archive(); | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 0 | ▶ | sub _run_ftp_archive { | ||||||||||||||||||||||||||
|
Subroutine
_run_ftp_archive: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 512 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | 0 | my $dist = $self->repo->{dist}; | |||||||||||||||||||||||||||
| 515 | 0 | my $repo_dir = $self->app->get_repo_dir( repo => $self->repo->{name} ); | |||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | # TODO: should probably check that apt-ftparchive exists and is executable | ||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | 0 | system | |||||||||||||||||||||||||||
| 520 | "cd $repo_dir ; apt-ftparchive generate -c=aptftp.conf aptgenerate.conf"; | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | 0 | ▶ | if ( $? != 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 523 | 0 | confess "Error running apt-ftparchive generate"; | |||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | system | ||||||||||||||||||||||||||||
| 527 | 0 | "cd $repo_dir ; apt-ftparchive release -c=aptftp.conf dists/$dist >dists/$dist/Release"; | |||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 0 | ▶ | if ( $? != 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 530 | 0 | confess "Error running apt-ftparchive release"; | |||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if ( exists $self->repo->{gpg} && $self->repo->{gpg}->{key} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->repo->{"gpg"} and $self->repo->{"gpg"}{"key"}
MC/DC0%0/2
exists $self->repo->{"gpg"} and $self->repo->{"gpg"}{"key"}
exists $self->repo->{"gpg"}
$self->repo->{"gpg"}{"key"}
Truth table0%0/3
A and B
A= exists $self->repo->{"gpg"}B= $self->repo->{"gpg"}{"key"}
| |||||||||||||||||||||||||||||
| 534 | 0 | my $key = $self->repo->{gpg}->{key}; | |||||||||||||||||||||||||||
| 535 | 0 | my $pass = $self->repo->{gpg}->{password}; | |||||||||||||||||||||||||||
| 536 | 0 | ▶ | if ( !$pass ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 537 | 0 | $pass = $self->read_password("GPG key passphrase: "); | |||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 0 | unlink "$repo_dir/dists/$dist/Release.gpg"; | |||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | 0 | my $cmd = | |||||||||||||||||||||||||||
| 543 | "cd $repo_dir ; gpg -u $key " | ||||||||||||||||||||||||||||
| 544 | . "--batch --passphrase '" | ||||||||||||||||||||||||||||
| 545 | . $pass | ||||||||||||||||||||||||||||
| 546 | . "' -bao dists/$dist/Release.gpg dists/$dist/Release"; | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | 0 | system $cmd; | |||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||
| 550 | 0 | ▶ | if ( $? != 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 551 | 0 | $cmd =~ s/\Q$pass\E/\*\*\*\*\*\*\*/; | |||||||||||||||||||||||||||
| 552 | 0 | confess "Error running gpg sign: $cmd"; | |||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||
| 555 | # export pub key as asc file | ||||||||||||||||||||||||||||
| 556 | 0 | my $pub_file = $self->repo->{name} . ".asc"; | |||||||||||||||||||||||||||
| 557 | 0 | $cmd = "cd $repo_dir ; gpg -a --output $pub_file --export $key"; | |||||||||||||||||||||||||||
| 558 | 0 | system $cmd; | |||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | 0 | ▶ | if ( $? != 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 561 | 0 | confess "Error running gpg export: $cmd"; | |||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||
| 566 | # test if all necessary parameters are available | ||||||||||||||||||||||||||||
| 567 | 0 | ▶ | override verify_options => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 568 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 569 | 0 | super(); | |||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | 0 | ▶ | if ( !exists $self->repo->{local} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 572 | 0 | confess "No local path (local) given for: " . $self->repo->{name}; | |||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 0 | ▶ | if ( !exists $self->repo->{arch} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 576 | 0 | confess "No architecture (arch) given for: " . $self->repo->{name}; | |||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | 0 | ▶ | if ( !exists $self->repo->{dist} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 580 | 0 | confess "No distribution (dist) given for: " . $self->repo->{name}; | |||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | 0 | ▶ | if ( !exists $self->repo->{component} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 584 | 0 | confess "No component (component) given for: " . $self->repo->{name}; | |||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||
| 586 | 1 | }; | |||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | 1 | 1; | |||||||||||||||||||||||||||