@@ -29,6 +29,7 @@ use Digest::MD5 ();
29
29
use Build;
30
30
use Build::Rpmmd;
31
31
use Build::Archrepo;
32
+ use Build::Apkrepo;
32
33
use Build::Debrepo;
33
34
use Build::Deb;
34
35
use Build::Susetags;
@@ -41,7 +42,7 @@ use PBuild::Verify;
41
42
use PBuild::OBS;
42
43
use PBuild::Cando;
43
44
44
- my @binsufs = qw{ rpm deb pkg.tar.gz pkg.tar.xz pkg.tar.zst} ;
45
+ my @binsufs = qw{ rpm deb pkg.tar.gz pkg.tar.xz pkg.tar.zst apk } ;
45
46
my $binsufsre = join (' |' , map {" \Q $_ \E " } @binsufs );
46
47
47
48
sub open_uncompressed {
@@ -100,6 +101,15 @@ sub fetchrepo_arch {
100
101
return \@bins ;
101
102
}
102
103
104
+ sub fetchrepo_apk {
105
+ my ($url , $tmpdir , %opts ) = @_ ;
106
+ $url .= ' /' unless $url =~ / \/ $ / ;
107
+ download(" ${url} APKINDEX.tar.gz" , " $tmpdir /APKINDEX.tar.gz" );
108
+ my @bins ;
109
+ Build::Apkrepo::parse(" $tmpdir /APKINDEX.tar.gz" , sub { addpkg(\@bins , $_ [0], $url ) }, ' addselfprovides' => 1, ' normalizedeps' => 1);
110
+ return \@bins ;
111
+ }
112
+
103
113
sub fetchrepo_debian {
104
114
my ($url , $tmpdir , %opts ) = @_ ;
105
115
my ($baseurl , $disturl , $components ) = Build::Debrepo::parserepourl($url );
@@ -236,7 +246,8 @@ sub calc_binname {
236
246
my $binname = $bin -> {' version' };
237
247
$binname = " $bin ->{'epoch'}:$binname " if $bin -> {' epoch' };
238
248
$binname .= " -$bin ->{'release'}" if defined $bin -> {' release' };
239
- $binname .= " .$bin ->{'arch'}" if $bin -> {' arch' };
249
+ # for apk the arch entry in the repo metadata does not match the binary
250
+ $binname .= " .$bin ->{'arch'}" if $bin -> {' arch' } && $suf ne ' apk' ;
240
251
$binname = " $bin ->{'name'}-$binname .$suf " ;
241
252
$binname = " $bin ->{'hdrmd5'}-$binname " if $binname =~ s / ^container:// && $bin -> {' hdrmd5' };
242
253
return $binname ;
@@ -328,10 +339,11 @@ sub guess_repotype {
328
339
my ($bconf , $buildtype ) = @_ ;
329
340
return undef unless $bconf ;
330
341
for (@{$bconf -> {' repotype' } || []}) {
331
- return $_ if $_ eq ' arch' || $_ eq ' debian' || $_ eq ' hdlist2' || $_ eq ' rpm-md' ;
342
+ return $_ if $_ eq ' arch' || $_ eq ' debian' || $_ eq ' hdlist2' || $_ eq ' rpm-md' || $_ eq ' apk ' ;
332
343
}
333
344
return ' arch' if ($bconf -> {' binarytype' } || ' ' ) eq ' arch' ;
334
345
return ' debian' if ($bconf -> {' binarytype' } || ' ' ) eq ' deb' ;
346
+ return ' apk' if ($bconf -> {' binarytype' } || ' ' ) eq ' apk' ;
335
347
$buildtype ||= $bconf -> {' type' };
336
348
return ' rpm-md' if ($buildtype || ' ' ) eq ' spec' ;
337
349
return ' debian' if ($buildtype || ' ' ) eq ' dsc' ;
@@ -348,7 +360,7 @@ sub fetchrepo {
348
360
$repotype = ' zypp' if $url =~ / ^zypp:/ ;
349
361
$repotype = ' obs' if $url =~ / ^obs:/ ;
350
362
my $archfilter ;
351
- if ($url =~ / ^(arch|debian|hdlist2|rpmmd|rpm-md|suse)(?:\+ archfilter=([^\@\/ ]+))?\@ (.*)$ / ) {
363
+ if ($url =~ / ^(arch|debian|hdlist2|rpmmd|rpm-md|suse|apk )(?:\+ archfilter=([^\@\/ ]+))?\@ (.*)$ / ) {
352
364
$repotype = $1 ;
353
365
$archfilter = [ split (' ,' , $2 ) ] if $2 ;
354
366
$url = $3 ;
@@ -388,6 +400,8 @@ sub fetchrepo {
388
400
$repo = fetchrepo_debian($url , $tmpdir , %opts );
389
401
} elsif ($repotype eq ' arch' ) {
390
402
$repo = fetchrepo_arch($url , $tmpdir , %opts );
403
+ } elsif ($repotype eq ' apk' ) {
404
+ $repo = fetchrepo_apk($url , $tmpdir , %opts );
391
405
} elsif ($repotype eq ' suse' ) {
392
406
$repo = fetchrepo_susetags($url , $tmpdir , %opts );
393
407
} elsif ($repotype eq ' zypp' ) {
@@ -468,6 +482,7 @@ sub fetchbinaries_replace {
468
482
my ($repodir , $tmpname , $binname , $bin ) = @_ ;
469
483
Build::Download::checkfiledigest(" $repodir /$tmpname " , $bin -> {' checksum' }) if $bin -> {' checksum' };
470
484
my $q = querybinary($repodir , $tmpname );
485
+ $bin -> {' arch' } = $q -> {' arch' } if $binname =~ / \. apk$ / ; # see comment in calc_binname
471
486
die (" downloaded binary $binname does not match repository metadata\n " ) unless is_matching_binary($bin , $q );
472
487
rename (" $repodir /$tmpname " , " $repodir /$binname " ) || die (" rename $repodir /$tmpname $repodir /$binname \n " );
473
488
$q -> {' filename' } = $binname ;
0 commit comments