1 package Packages::SrcPage;
9 use Packages::Page qw( :all );
11 our @ISA = qw( Packages::Page );
13 #FIXME: change parameters so that we can use the version from Packages::Page
15 my ($self, $pkg, $suite, $archive, $data) = @_;
17 my %data = split /\00/o, $data;
18 $data{package} = $pkg;
19 $data{suite} = $suite;
20 $data{archive} = $archive;
22 return $self->merge_package( \%data );
25 our @DEP_FIELDS = qw( build-depends build-depends-indep
26 build-conflicts build-conflicts-indep);
28 my ($self, $data) = @_;
30 ($data->{package} && $data->{suite} && $data->{archive}) || return;
31 $self->{package} ||= $data->{package};
32 ($self->{package} eq $data->{package}) || return;
33 debug( "merge package $data->{package}/$data->{version} into $self (".($self->{version}||'').")", 2 ) if DEBUG;
36 || (version_cmp( $data->{version}, $self->{version} ) > 0)) {
37 debug( "added package is newer, replacing old information" ) if DEBUG;
39 $self->{data} = $data;
42 if ($data->{maintainer} ||= '') {
43 push @uploaders, [ split_name_mail( $data->{maintainer} ) ];
45 if ($data->{uploaders}) {
46 my @up_tmp = split( /\s*,\s*/,
48 foreach my $up (@up_tmp) {
49 if ($up ne $data->{maintainer}) { # weed out duplicates
50 push @uploaders, [ split_name_mail( $up ) ];
54 $self->{uploaders} = \@uploaders;
57 my @files = split /\01/so, $data->{files};
58 $self->{files} = \@files;
61 foreach (@DEP_FIELDS) {
62 $self->normalize_dependencies( $_, $data );
65 $self->{version} = $data->{version};
69 #FIXME: should be mergable with the Packages::Page version
70 sub normalize_dependencies {
71 my ($self, $dep_field, $data) = @_;
73 my ($deps_norm, $deps) = parse_deps( $data->{$dep_field}||'' );
74 $self->{dep_fields}{$dep_field} =
75 [ $deps_norm, $deps ];
79 my ($self, $field) = @_;
81 return $self->{$field} if exists $self->{$field};
82 return $self->{data}{$field};
85 sub get_architectures {
90 my ($self, $field) = @_;
92 return $self->{data}{$field};
98 return [ $self->{version} ];
101 sub get_version_string {
104 my $versions = $self->get_versions;
106 return ($self->{version}, $versions);
110 my ($self, $dep_field) = @_;
113 foreach my $dep (@{$self->{dep_fields}{$dep_field}[1]}) {
115 foreach my $or_dep ( @$dep ) {
116 my $p_name = $or_dep->[0];
117 my $p_version = $or_dep->[1] ? "$or_dep->[1] $or_dep->[2]" : undef;
120 if ($or_dep->[3] && @{$or_dep->[3]}) {
121 # as either all or no archs have to be prepended with
122 # exlamation marks, use the first and delete the others
123 if ($or_dep->[3][0] =~ /^!/) {
125 foreach (@{$or_dep->[3]}) {
129 $arch_str = join(" ",sort(@{$or_dep->[3]}));
132 push @or_deps, [ $p_name, $p_version, $arch_neg, $arch_str ];
134 push @deps, [ 0, @or_deps ];