1 package Packages::SrcPage;
10 use Packages::Page qw( :all );
12 our @ISA = qw( Packages::Page );
14 #FIXME: change parameters so that we can use the version from Packages::Page
16 my ($self, $pkg, $suite, $archive, $data) = @_;
18 my %data = split /\00/o, $data;
19 $data{package} = $pkg;
20 $data{suite} = $suite;
21 $data{archive} = $archive;
23 return $self->merge_package( \%data );
26 our @DEP_FIELDS = qw( build-depends build-depends-indep
27 build-conflicts build-conflicts-indep);
29 my ($self, $data) = @_;
31 ($data->{package} && $data->{suite} && $data->{archive}) || return;
32 $self->{package} ||= $data->{package};
33 ($self->{package} eq $data->{package}) || return;
34 debug( "merge package $data->{package}/$data->{version} into $self (".($self->{version}||'').")", 2 ) if DEBUG;
37 || (version_cmp( $data->{version}, $self->{version} ) > 0)) {
38 debug( "added package is newer, replacing old information" ) if DEBUG;
40 $self->{data} = $data;
43 if ($data->{maintainer} ||= '') {
44 push @uploaders, [ split_name_mail( $data->{maintainer} ) ];
46 if ($data->{uploaders}) {
47 my @up_tmp = split( /\s*,\s*/,
49 foreach my $up (@up_tmp) {
50 if ($up ne $data->{maintainer}) { # weed out duplicates
51 push @uploaders, [ split_name_mail( $up ) ];
55 $self->{uploaders} = \@uploaders;
58 my @files = split /\01/so, $data->{files};
59 $self->{files} = \@files;
62 foreach (@DEP_FIELDS) {
63 $self->normalize_dependencies( $_, $data );
66 $self->{version} = $data->{version};
70 #FIXME: should be mergable with the Packages::Page version
71 sub normalize_dependencies {
72 my ($self, $dep_field, $data) = @_;
74 my ($deps_norm, $deps) = parse_deps( $data->{$dep_field}||'' );
75 $self->{dep_fields}{$dep_field} =
76 [ $deps_norm, $deps ];
80 my ($self, $field) = @_;
82 return $self->{$field} if exists $self->{$field};
83 return $self->{data}{$field};
86 sub get_architectures {
91 my ($self, $field) = @_;
93 return $self->{data}{$field};
99 return [ $self->{version} ];
102 sub get_version_string {
105 my $versions = $self->get_versions;
107 return ($self->{version}, $versions);
111 my ($self, $dep_field) = @_;
114 foreach my $dep (@{$self->{dep_fields}{$dep_field}[1]}) {
116 foreach my $or_dep ( @$dep ) {
117 my $p_name = $or_dep->[0];
118 my $p_version = $or_dep->[1] ? "$or_dep->[1] $or_dep->[2]" : undef;
121 if ($or_dep->[3] && @{$or_dep->[3]}) {
122 # as either all or no archs have to be prepended with
123 # exlamation marks, use the first and delete the others
124 if ($or_dep->[3][0] =~ /^!/) {
126 foreach (@{$or_dep->[3]}) {
130 $arch_str = join(" ",sort(@{$or_dep->[3]}));
133 push @or_deps, [ $p_name, $p_version, $arch_neg, $arch_str ];
135 push @deps, [ 0, @or_deps ];