Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[backend] DoD: use build's repo parser instead of local copies
- Loading branch information
Showing
6 changed files
with
103 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.