Skip to content

Commit

Permalink
[backend] adapt to new DoD scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Aug 12, 2015
1 parent 6b97b32 commit 390874c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
26 changes: 19 additions & 7 deletions src/backend/BSDoD.pm
Expand Up @@ -25,6 +25,7 @@ package BSDoD;
use Build::Repo;
use Build::Deb;
use Build::Rpm;
use BSUtil;

use strict;

Expand Down Expand Up @@ -79,27 +80,38 @@ sub addpkg {

sub gencookie {
my ($doddata, $dir) = @_;
my @s = stat("$dir/$doddata->{'metafile'}");
my $metafile = $doddata->{'metafile'} || 'doddata';
my @s = stat("$dir/$metafile");
return undef unless @s;
return "1/$s[9]/$s[7]/$s[1]";
}

sub parse {
my ($doddata, $dir, $arch) = @_;
my $mtype = $doddata->{'mtype'} || 'mtype not set';
my ($doddata, $dir) = @_;
my $mtype = $doddata->{'repotype'} || $doddata->{'mtype'} || 'mtype not set';
my $baseurl = $doddata->{'url'} || $doddata->{'baseurl'};
$mtype = 'deb' if $mtype eq 'debmd';
$mtype = 'susetags' if $mtype eq 'susetagsmd';
$mtype = 'parsed' if $doddata->{'repotype'}; # new format is always parsed
my $metafile = $doddata->{'metafile'} || 'doddata';
my $archfilter;
if ($mtype eq 'rpmmd' || $mtype eq 'susetags') {
# do arch filtering for rpmmd/susetags hybrid repos
$arch ||= 'noarch';
my $arch = $doddata->{'arch'} || 'noarch';
$archfilter = { map { $_ => 1} @{$compatarch{$arch} || [ $arch, 'noarch' ] } };
}
my $cache = {};
my $cookie = gencookie($doddata, $dir);
return "$doddata->{'metafile'}: $!" unless $cookie;
return "$metafile: $!" unless $cookie;

eval {
Build::Repo::parse($mtype, "$dir/$doddata->{'metafile'}", sub { addpkg($cache, $_[0], $archfilter) }, 'addselfprovides' => 1, 'normalizedeps' => 1, 'withchecksum' => 1);
if ($mtype eq 'parsed') {
$cache = BSUtil::retrieve("$dir/$metafile");
$baseurl = delete $cache->{'/url'};
die("baseurl missing in data\n") unless $baseurl;
} else {
Build::Repo::parse($mtype, "$dir/$metafile", sub { addpkg($cache, $_[0], $archfilter) }, 'addselfprovides' => 1, 'normalizedeps' => 1, 'withchecksum' => 1);
}
};
if ($@) {
my $error = $@;
Expand All @@ -110,7 +122,7 @@ sub parse {
$_->{'id'} = 'dod';
$_->{'hdrmd5'} = 'd0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0';
}
$cache->{'/url'} = $doddata->{'baseurl'};
$cache->{'/url'} = $baseurl;
$cache->{'/dodcookie'} = $cookie;
return $cache;
}
Expand Down
7 changes: 4 additions & 3 deletions src/backend/bs_sched
Expand Up @@ -383,9 +383,10 @@ sub addrepo_scan {
# update the doddata
my $doddata;
if ($BSConfig::enable_download_on_demand) {
my ($projid) = split('/', $prp, 2);
my @doddata = grep {$_->{'arch'} && $_->{'arch'} eq $myarch} @{$projpacks->{$projid}->{'download'} || []};
$doddata = $doddata[0];
my ($projid, $repoid) = split('/', $prp, 2);
my $proj = $projpacks->{$projid} || {};
my $repo = (grep {$_->{'name'} eq $repoid} @{$proj->{'repository'} || []})[0] || {};
$doddata = (grep {($_->{'arch'} || '') eq $myarch} @{$repo->{'download'} || $proj->{'download'} || []})[0];
($dirty, $cache) = put_doddata_in_cache($pool, $prp, $cache, $doddata, $dir);
}

Expand Down

0 comments on commit 390874c

Please sign in to comment.