1 package Packages::DoNewPkg;
6 use Benchmark ':hireswallclock';
12 our @ISA = qw( Exporter );
13 our @EXPORT = qw( do_newpkg );
15 use Packages::I18N::Locale;
16 use Packages::Search qw( :all );
19 use Packages::Config qw( $TOPDIR @SECTIONS $ROOT );
22 my ($params, $opts, $page_content) = @_;
24 if ($params->{errors}{suite}) {
25 fatal_error( _g( "suite not valid or not specified" ) );
27 if (@{$opts->{suite}} > 1) {
28 fatal_error( sprintf( _g( "more than one suite specified for show (%s)" ), "@{$opts->{suite}}" ) );
31 my $sort_func = sub { $_[0][0] cmp $_[1][0] };
32 $sort_func = sub { $_[0][1] <=> $_[1][1] or $_[0][0] cmp $_[1][0] }
33 if $opts->{mode} eq 'byage';
35 my $suite = $opts->{suite}[0];
36 my $one_archive = @{$opts->{archive}} == 1 ?
37 $opts->{archive}[0] : undef;
38 my $one_section = @{$opts->{section}} == 1 ?
39 $opts->{section}[0] : undef;
42 #FIXME: move to Packages::DB?
43 open NEWPKG, '<', "$TOPDIR/files/packages/newpkg_info"
44 or die "can't read newpkg_info file: $!";
47 my @data = split /\s/, $_, 10;
49 next unless $data[3] eq $suite;
50 next if $one_archive and $data[2] ne $one_archive;
51 next if $one_section and $data[5] ne $one_section;
53 debug( "new pkg: @data", 1 ) if DEBUG;
54 push @new_pkgs, \@data;
59 #FIXME: compute in the template
60 $page_content->{rss_timestamp} = strftime ("%Y-%m-%dT%H:%M+00:00", @date);
63 $page_content->{new_packages} = [ sort { &$sort_func($a,$b) } @new_pkgs ];
66 $page_content->{suite} = $suite;
67 $page_content->{section} = $one_section if $one_section;
68 $page_content->{archive} = $one_archive if $one_archive;
69 $page_content->{sections} = \@SECTIONS;