From 691ad119b247e41ee43b2910d9ef1d044364fcc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20Schr=C3=B6der?= Date: Thu, 27 Nov 2008 09:03:23 +0000 Subject: [PATCH] - move meta stuff out of build for now, it's currently not used --- Meta.pm | 37 -------------- Meta/Debmd.pm | 91 --------------------------------- Meta/Rpmmd.pm | 158 ---------------------------------------------------------- 3 files changed, 286 deletions(-) delete mode 100644 Meta.pm delete mode 100644 Meta/Debmd.pm delete mode 100644 Meta/Rpmmd.pm diff --git a/Meta.pm b/Meta.pm deleted file mode 100644 index b5fe583..0000000 --- a/Meta.pm +++ /dev/null @@ -1,37 +0,0 @@ -# -# -# Copyright (c) 2008 Marcus Huewe -# -# 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 -# -################################################################ -# -# The Download on Demand Metadata Parser for deb md files ("Packages" files) -# - -package Meta; - -use strict; -use warnings; -use Meta::Rpmmd; -use Meta::Debmd; - -sub parse { - my ($fn, $type, $opts) = @_; - return Meta::Debmd::parse($fn, $opts) if $type eq 'debmd'; - return Meta::Rpmmd::parse($fn, $opts) if $type eq 'rpmmd'; -} - -1; diff --git a/Meta/Debmd.pm b/Meta/Debmd.pm deleted file mode 100644 index b43fde8..0000000 --- a/Meta/Debmd.pm +++ /dev/null @@ -1,91 +0,0 @@ -# -# -# Copyright (c) 2008 Marcus Huewe -# -# 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 -# -################################################################ -# -# The Download on Demand Metadata Parser for deb md files ("Packages" files) -# - -package Meta::Debmd; -use strict; -use warnings; -use Data::Dumper; - -my %tagmap = ( - 'Package' => 'name', - 'Version' => 'version', - 'Provides' => 'provides', - 'Depends' => 'requires', - 'Pre-Depends' => 'requires', - 'Filename' => 'path', - 'Source' => 'source', - 'Architecture' => 'arch', -); - -sub parse { - my $fn = shift; - - my %packs = (); - my $cur = {}; - open(F, '<', $fn) or die("open: $!\n"); - while () { - chomp; - next unless /^(Package|Version|Provides|Depends|Pre-Depends|Filename|Source|Architecture|Size):\s(.*)/; - my ($tag, $what) = ($1, $2); - if ($tag =~ /^[\w-]*Depends|Provides/) { - my @m = $what =~ /([^\s,]+)(\s[^,]*)?[\s,]*/g; - my @l = (); - while (@m) { - my ($pack, $vers) = splice(@m, 0, 2); - $pack .= $vers if defined $vers; - push @l, $pack; - } - # stolen from the Build/Deb.pm - s/\(([^\)]*)\)/$1/g for @l; - s/<>/>/g for @l; - - push @{$cur->{$tagmap{$tag}}}, @l; - next; - } - # Size is the last entry in a package section - if ($tag eq 'Size') { - $cur->{'id'} = "-1/$what/-1"; - $cur->{'hdrmd5'} = 0; - my $rel = exists $cur->{'release'} ? "-$cur->{'release'}" : ''; - push @{$cur->{'provides'}}, "$cur->{'name'} = $cur->{'version'}$rel"; - $cur->{'requires'} = [] unless exists $cur->{'requires'}; - $cur->{'source'} = $cur->{'name'} unless exists $cur->{'source'}; - $packs{$cur->{'name'}} = $cur; - $cur = {}; - next; - } - $cur->{$tagmap{$tag}} = $what; - if ($tag eq 'Version') { - # stolen from Build/Deb.pm - if ($what =~ /^(.*)-(.*?)$/) { - $cur->{'version'} = $1; - $cur->{'release'} = $2; - } - } - } - close(F); - return \%packs; -} - -1; diff --git a/Meta/Rpmmd.pm b/Meta/Rpmmd.pm deleted file mode 100644 index 732c4ba..0000000 --- a/Meta/Rpmmd.pm +++ /dev/null @@ -1,158 +0,0 @@ -# -# -# Copyright (c) 2008 Marcus Huewe -# Copyright (c) 2008 Martin Mohring -# -# 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 -# -################################################################ -# -# The Download on Demand Metadata Parser for rpm md files ("primary.xml" files) -# - -package Meta::Rpmmd; -use strict; -use warnings; -use XML::Parser; - -sub parse { - my ($fn, $opts) = @_; - my $h = rpmmdhandler->new(@{$opts->{'arch'}}); - my $p = XML::Parser->new(Handlers => { - Start => sub { return $h->start_handler(@_); }, - End => sub { return $h->end_handler(@_); }, - Char => sub { return $h->char_handler(@_); }, - }, ErrorContext => 2); - eval { - $p->parsefile($fn); - }; - die("parse: $@") if $@; - return $h->getrepodata(); -} - -1; - -package rpmmdhandler; -use strict; -use warnings; -use Data::Dumper; - -sub new { - my ($class, @arch) = @_; - my $self = {}; - $self->{'repodata'} = {}; - $self->{'pack'} = {}; - $self->{'arch'} = [ @arch ]; # XXX: are there cases where we want to mix i586 and i686? - $self->{'reqprov'} = (); - $self->{'curchar'} = ''; - $self->{'attrs'} = [ qw(version location rpm:entry size) ]; - $self->{'chars'} = [ qw(name arch rpm:sourcerpm) ]; - return bless($self, $class); -} - -sub addversrel { - my ($self, $attrs) = @_; - $self->{'pack'}->{'version'} = $attrs->{'ver'}; - $self->{'pack'}->{'release'} = $attrs->{'rel'}; -} - -sub addreqprov { - my ($self, $attrs) = @_; - my %flags = ( 'EQ' => '=', 'LE' => '<=', 'GE' => '>=', 'LT' => '<', 'GT' => '>' ); - my $name = $attrs->{'name'}; - unless ($name =~ /^(rpmlib\(|\/)/) { - $name .= exists $attrs->{'flags'} ? " $flags{$attrs->{'flags'}} " : ""; - $name .= exists $attrs->{'epoch'} ? "$attrs->{'epoch'}:" : ""; - $name .= exists $attrs->{'ver'} ? $attrs->{'ver'} : ""; - $name .= exists $attrs->{'rel'} ? "-$attrs->{'rel'}" : ""; - push @{$self->{'reqprov'}}, $name; - } -} - -sub addlocation { - my ($self, $attrs) = @_; - $self->{'pack'}->{'path'} = $attrs->{'href'}; -} - -sub addsize { - my ($self, $attrs) = @_; - $self->{'pack'}->{'id'} = "-1/$attrs->{'package'}/-1"; # XXX: the