1 package Packages::DoNewPkg;
9 our @ISA = qw( Exporter );
10 our @EXPORT = qw( do_newpkg );
12 use Packages::Search qw( :all );
15 use Packages::Config qw( $TOPDIR @SECTIONS $ROOT );
18 my ($params, $opts, $page_content) = @_;
19 my $cat = $opts->{cat};
21 if ($params->{errors}{suite}) {
22 fatal_error( $cat->g( "suite not valid or not specified" ) );
24 if (@{$opts->{suite}} > 1) {
25 fatal_error( $cat->g( "more than one suite specified for newpkg (%s)",
26 "@{$opts->{suite}}" ) );
29 my $sort_func = sub { $_[0][0] cmp $_[1][0] };
30 $sort_func = sub { $_[0][1] <=> $_[1][1] or $_[0][0] cmp $_[1][0] }
31 if $opts->{mode} eq 'byage';
33 my $suite = $opts->{suite}[0];
34 my $one_archive = @{$opts->{archive}} == 1 ?
35 $opts->{archive}[0] : undef;
36 my $one_section = @{$opts->{section}} == 1 ?
37 $opts->{section}[0] : undef;
40 open NEWPKG, '<', "$TOPDIR/files/packages/newpkg_info_$suite"
42 warn "can't read newpkg_info_$suite: $!";
43 fatal_error( $cat->g("no newpkg information found for suite %s",
49 my @data = split /\s/, $_, 11;
51 next unless $data[2]; #removed packages
52 next unless $data[3] eq $suite;
53 next if $one_archive and $data[2] ne $one_archive;
54 next if $one_section and $data[5] ne $one_section;
56 debug( "new pkg: @data", 1 ) if DEBUG;
57 push @new_pkgs, \@data;
62 #FIXME: compute in the template
63 $page_content->{rss_timestamp} = strftime ("%Y-%m-%dT%H:%M+00:00", @date);
66 $page_content->{new_packages} = [ sort { &$sort_func($a,$b) } @new_pkgs ];
69 $page_content->{suite} = $suite;
70 $page_content->{section} = $one_section if $one_section;
71 $page_content->{archive} = $one_archive if $one_archive;
72 $page_content->{sections} = \@SECTIONS;