Skip to content

Commit

Permalink
[backend] DoD: use build's repo parser instead of local copies
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Jul 27, 2015
1 parent dad2cf3 commit 9d6db24
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 358 deletions.
96 changes: 96 additions & 0 deletions src/backend/BSDoD.pm
@@ -0,0 +1,96 @@
#
# Copyright (c) 2015 Michael Schroeder, SUSE Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see the file COPYING); if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#
################################################################
#
# Download on Demand parser
#

package BSDoD;

use Build::Repo;

use strict;

my %compatarch = (
'armv4l' => ['arm', 'armel', 'noarch'],
'armv5l' => ['arm', 'armel', 'armv5el', 'armv5tel', 'armv5tevl' , 'noarch'],
'armv6l' => ['arm', 'armel', 'armv6l', 'armv6el', 'noarch'],
'armv7l' => ['arm', 'armel', 'armv7l', 'armv7el', 'noarch'],
'armv5el' => ['arm', 'armel', 'armv5el', 'armv5tel', 'armv5tevl' , 'noarch'],
'armv6el' => ['arm', 'armel', 'armv6l', 'armv6el', 'noarch'],
'armv7el' => ['arm', 'armel', 'armv7l', 'armv7el', 'noarch'],
'armv7hl' => ['armhf', 'armv7hl', 'armv7nhl', 'noarch'],
'ppc' => ['ppc', 'noarch'],
'ppc64' => ['ppc', 'ppc64', 'noarch'],
'sh4' => ['sh4', 'noarch'],
'ia64' => ['ia64', 'noarch'],
's390' => ['s390', 'noarch'],
's390x' => ['s390', 's390x', 'noarch'],
'sparc' => ['sparc', 'noarch'],
'sparc64' => ['sparc', 'sparc64', 'noarch'],
'mips' => ['mips', 'noarch'],
'mips64' => ['mips', 'mips64', 'noarch'],
'i586' => [ 'i386', 'i486', 'i586', 'i686', 'noarch'],
'i686' => [ 'i386', 'i486', 'i586', 'i686', 'noarch'],
'x86_64' => ['x86_64', 'noarch'],
);

sub parse {
my ($doddata, $dir, $arch) = @_;
my $cache;
my $mtype = $doddata->{'mtype'} || 'mtype not set';
$mtype = 'deb' if $mtype eq 'debmd';
$mtype = 'susetags' if $mtype eq 'susetagsmd';
$cache = {};
my $handler;
if ($mtype eq 'rpmmd' || $mtype eq 'susetags') {
# do arch filtering for rpmmd/susetags hybrid repos
$arch ||= 'noarch';
my %compat = map { $_ => 1} @{$compatarch{$arch} || [ $arch, 'noarch' ] };
$handler = sub {
my ($p) = @_;
return unless $p->{'location'} && $p->{'name'} && $p->{'arch'};
$p->{'path'} = delete $p->{'location'};
return unless $compat{$p->{'arch'}};
$cache->{"$p->{'name'}.$p->{'arch'}"} = $p;
};
} else {
$handler = sub {
my ($p) = @_;
return unless $p->{'location'} && $p->{'name'} && $p->{'arch'};
$p->{'path'} = delete $p->{'location'};
$cache->{"$p->{'name'}.$p->{'arch'}"} = $p;
};
}
eval {
Build::Repo::parse($mtype, "$dir/$doddata->{'metafile'}", $handler, 'addselfprovides' => 1, 'normalizedeps' => 1);
};
if ($@) {
my $error = $@;
chomp $error;
return $error;
}
for (values %$cache) {
$_->{'id'} = 'dod';
$_->{'hdrmd5'} = 'd0d0d0d0d0d0d0d0d0d0d0d0d0d0d0d0';
}
$cache->{'/url'} = $doddata->{'baseurl'};
return $cache;
}

1;
39 changes: 0 additions & 39 deletions src/backend/Meta.pm

This file was deleted.

94 changes: 0 additions & 94 deletions src/backend/Meta/Debmd.pm

This file was deleted.

165 changes: 0 additions & 165 deletions src/backend/Meta/Rpmmd.pm

This file was deleted.

0 comments on commit 9d6db24

Please sign in to comment.