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};
71 #FIXME: should be mergable with the Packages::Page version
72 sub normalize_dependencies {
73 my ($self, $dep_field, $data) = @_;
75 my ($deps_norm, $deps) = parse_deps( $data->{$dep_field}||'' );
76 $self->{dep_fields}{$dep_field} =
77 [ $deps_norm, $deps ];
81 my ($self, $field) = @_;
83 return $self->{$field} if exists $self->{$field};
84 return $self->{data}{$field};
87 sub get_architectures {
92 my ($self, $field) = @_;
94 return $self->{data}{$field};
100 return [ $self->{version} ];
103 sub get_version_string {
106 my $versions = $self->get_versions;
108 return ($self->{version}, $versions);
112 my ($self, $dep_field) = @_;
115 foreach my $dep (@{$self->{dep_fields}{$dep_field}[1]}) {
117 foreach my $or_dep ( @$dep ) {
118 my $p_name = $or_dep->[0];
119 my $p_version = $or_dep->[1] ? "$or_dep->[1] $or_dep->[2]" : undef;
122 if ($or_dep->[3] && @{$or_dep->[3]}) {
123 # as either all or no archs have to be prepended with
124 # exlamation marks, use the first and delete the others
125 if ($or_dep->[3][0] =~ /^!/) {
127 foreach (@{$or_dep->[3]}) {
131 $arch_str = join(" ",sort(@{$or_dep->[3]}));
134 push @or_deps, [ $p_name, $p_version, $arch_neg, $arch_str ];
136 push @deps, [ 0, @or_deps ];