X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=blobdiff_plain;f=bin%2Fcreate_index_pages;h=aa40f3c0702f49f9719c8c6b7f9f4b783a63a664;hp=11849bce7a745fff257db4d0520a00fa1fabda27;hb=01393b020237bbfa4571d41cc98899b4d25acd8b;hpb=3210a2b7d904e95b48ebbd84afa2bf1875544e8e diff --git a/bin/create_index_pages b/bin/create_index_pages index 11849bc..aa40f3c 100755 --- a/bin/create_index_pages +++ b/bin/create_index_pages @@ -8,15 +8,25 @@ use File::Path; use DB_File; use Storable; use HTML::Entities; +use Locale::gettext; +use Compress::Zlib; use lib './lib'; -use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES ); +use Packages::Config qw( $TOPDIR $DBDIR @ARCHIVES @SUITES @LANGUAGES $LOCALES); use Packages::HTML; +use Packages::I18N::Locale; use Packages::Page; +use Packages::Sections; &Packages::Config::init( './' ); -sub gettext { return $_[0]; } -sub dgettext { return $_[1]; } + +delete $ENV{'LANGUAGE'}; +delete $ENV{'LANG'}; +delete $ENV{'LC_ALL'}; +delete $ENV{'LC_MESSAGES'}; +bindtextdomain ( 'pdo', $LOCALES ); +bindtextdomain ( 'sections', $LOCALES ); +textdomain( 'pdo' ); my $wwwdir = "$TOPDIR/www"; @@ -32,173 +42,126 @@ my $priorities = retrieve "$DBDIR/priorities.info"; #use Data::Dumper; #print STDERR Dumper($sections, $subsections, $priorities); -my %sections_descs = ( - 'admin' => [ "Administration Utilities", - "Utilities to administer system resources, manage user accounts, etc." ], - 'base' => [ "Base Utilities", - "Basic needed utilities of every Debian system." ], - 'comm' => [ "Communication Programs", - "Software to use your modem in the old fashioned style." ], - 'devel' => [ "Development", - "Development utilities, compilers, development environments, libraries, etc." ], - 'doc' => [ "Documentation", - "FAQs, HOWTOs and other documents trying to explain everything related to Debian, and software needed to browse documentation (man, info, etc)." ], - 'editors' => [ "Editors", - "Software to edit files. Programming environments." ], - 'electronics' => [ "Electronics", - "Electronics utilities." ], - 'embedded' => [ "Embedded software", - "Software suitable for use in embedded applications." ], - 'games' => [ "Games", - "Programs to spend a nice time with after all this setting up." ], - 'gnome' => [ "GNOME", - "The GNOME desktop environment, a powerful, easy to use set of integrated applications." ], - 'graphics' => [ "Graphics", - "Editors, viewers, converters... Everything to become an artist." ], - 'hamradio' => [ "Ham Radio", - "Software for ham radio." ], - 'interpreters' => [ "Interpreters", - "All kind of interpreters for interpreted languages. Macro processors." ], - 'kde' => [ "KDE", - "The K Desktop Environment, a powerful, easy to use set of integrated applications." ], - 'libs' => [ "Libraries", - "Libraries to make other programs work. They provide special features to developers." ], - 'libdevel' => [ "Library development", - "Libraries necessary for developers to write programs that use them." ], - 'mail' => [ "Mail", - "Programs to route, read, and compose E-mail messages." ], - 'math' => [ "Mathematics", - "Math software." ], - 'misc' => [ "Miscellaneous", - "Miscellaneous utilities that didn\'t fit well anywhere else." ], - 'net' => [ "Network", - "Daemons and clients to connect your Debian GNU/Linux system to the world." ], - 'news' => [ "Newsgroups", - "Software to access Usenet, to set up news servers, etc." ], - 'non-US' => [ "Software restricted in the U.S.", - "These packages probably may not be used in or distributed from the U.S. due to software patents. You should check the regulations in your country before using this software." ], - 'oldlibs' => [ "Old Libraries", - "Old versions of libraries, kept for backward compatibility with old applications." ], - 'otherosfs' => [ "Other OS\'s and file systems", - "Software to run programs compiled for other operating system, and to use their filesystems." ], - 'perl' => [ "Perl", - "Everything about Perl, an interpreted scripting language." ], - 'python' => [ "Python", - "Everything about Python, an interpreted, interactive object oriented language." ], - 'science' => [ "Science", - "Basic tools for scientific work" ], - 'shells' => [ "Shells", - "Command shells. Friendly user interfaces for beginners." ], - 'sound' => [ "Sound", - "Utilities to deal with sound: mixers, players, recorders, CD players, etc." ], - 'tex' => [ "TeX", - "The famous typesetting software and related programs." ], - 'text' => [ "Text Processing", - "Utilities to format and print text documents." ], - 'utils' => [ "Utilities", - "Utilities for file/disk manipulation, backup and archive tools, system monitoring, input systems, etc." ], - 'virtual' => [ "Virtual packages", - "Virtual packages." ], - 'web' => [ "Web Software", - "Web servers, browsers, proxies, download tools etc." ], - 'x11' => [ "X Window System software", - "X servers, libraries, fonts, window managers, terminal emulators and many related applications." ], - 'debian-installer' => [ "debian-installer udeb packages", - "Special packages for building customized debian-installer variants. Do not install them on a normal system!" ], - ); - my (%pages); -print "opening files ...\n"; +print "write suite index files ...\n"; foreach my $s (@SUITES) { - foreach my $a (@ARCHIVES) { - next if $a eq 'security'; - next if $a eq 'non-US'; - my $key = ($a eq 'us') ? $s : "$s/$a"; - mkpath ( "$wwwdir/$key" ); - open $pages{$key}{index}{fh}, '>', "$wwwdir/$key/index.en.html.new" + my $key = $s; + mkpath ( "$wwwdir/$key" ); + foreach my $lang (@LANGUAGES) { + my $locale = get_locale( $lang ); + setlocale ( LC_ALL, $locale ) or do { + warn "couldn't set locale ($lang/$locale)\n"; + next; + }; + open $pages{$key}{$lang}{index}{fh}, '>', "$wwwdir/$key/index.$lang.html.new" or die "can't open index file for output: $!"; - open $pages{$key}{fh}, '>', "$wwwdir/$key/allpackages.en.html.new" - or die "can't open index file for output: $!"; - - my $title = sprintf( gettext ( "Software Packages in \"%s\"" ), - $s ); - my $index_title = sprintf( gettext ( "List of sections in \"%s\"" ), - $s ); - print {$pages{$key}{fh}} header( title => $title, - title_keywords => "debian, $s", - desc => encode_entities( $title, '"' ), - lang => 'en' ), - title( $title ), '
'; - print {$pages{$key}{index}{fh}} header( title => $index_title, - title_keywords => "debian, $s", - desc => encode_entities( $index_title, '"' ), - lang => 'en' ), + my $index_title = sprintf( _g( "List of sections in \"%s\"" ), + $key ); + print {$pages{$key}{$lang}{index}{fh}} header( title => $index_title, + title_keywords => "debian, $s", + desc => encode_entities( $index_title, '"' ), + lang => $lang ), title( $index_title ), '
'; - - foreach my $sec (keys %{$sections->{$s}{$a}}) { - mkpath ( "$wwwdir/$key/$sec" ); - open $pages{$key}{$sec}{fh}, '>', "$wwwdir/$key/$sec/index.en.html.new" - or die "can't open index file for output: $!"; - $title = sprintf( gettext ( "Software Packages in \"%s\", section %s" ), - $s, $sec ); - print {$pages{$key}{$sec}{fh}} header( title => $title, - title_keywords => "debian, $s, $sec", - desc => encode_entities( $title, '"' ), - lang => 'en' ), - title( $title ), '
'; - } - my $i = 0; my $num_sections = keys %{$subsections->{$s}{$a}}; - foreach my $ssec ((keys %{$subsections->{$s}{$a}}, 'virtual')) { + my $i = 0; my $num_sections = keys %{$subsections->{$s}}; + foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { next if $ssec eq '-'; - mkpath ( "$wwwdir/$key/$ssec" ); - open $pages{$key}{$ssec}{fh}, '>', "$wwwdir/$key/$ssec/index.en.html.new" - or die "can't open index file for output: $!"; - $title = sprintf( gettext ( "Software Packages in \"%s\", subsection %s" ), - $s, $ssec ); - print {$pages{$key}{$ssec}{fh}} header( title => $title, - title_keywords => "debian, $s, $ssec", - desc => encode_entities( $title, '"' ), - lang => 'en' ), - title( $title ), '
'; - if ($sections_descs{$ssec}) { - print {$pages{$key}{index}{fh}} "
".dgettext( 'sections', $sections_descs{$ssec}[0] )."
".dgettext( 'sections', $sections_descs{$ssec}[1] )."
\n"; + print {$pages{$key}{$lang}{index}{fh}} "
".dgettext( 'sections', $sections_descs{$ssec}[0] )."
".dgettext( 'sections', $sections_descs{$ssec}[1] )."
\n"; $i++; if ($i eq ceil($num_sections/2)) { - print {$pages{$key}{index}{fh}} "
\n
\n
\n
\n"; + print {$pages{$key}{$lang}{index}{fh}} "
\n
\n
\n
\n"; } } } - foreach my $prio (keys %{$priorities->{$s}{$a}}) { - next if $prio eq '-'; - mkpath ( "$wwwdir/$key/$prio" ); - open $pages{$key}{$prio}{fh}, '>', "$wwwdir/$key/$prio/index.en.html.new" - or die "can't open index file for output: $!"; - $title = sprintf( gettext ( "Software Packages in \"%s\", priority %s" ), - $s, $prio ); - print {$pages{$key}{$prio}{fh}} header( title => $title, - title_keywords => "debian, $s, $prio", - desc => encode_entities( $title, '"' ), - lang => 'en' ), - title( $title ), '
'; - } + + print {$pages{$key}{$lang}{index}{fh}} '
', + "

". + _g( "All packages" ) ."
(". + _g( "compact compressed textlist" ).")

\n"; + print {$pages{$key}{$lang}{index}{fh}} trailer( "../", 'index', $lang, @LANGUAGES ); + close $pages{$key}{$lang}{index}{fh} or + warn "can't close index file $wwwdir/$key/index.$lang.html.new: $!"; + rename( "$wwwdir/$key/index.$lang.html.new", + "$wwwdir/$key/index.$lang.html" ); + + } +} +setlocale( LC_ALL, 'C' ) or die "couldn't reset locale"; + +print "opening files ...\n"; +foreach my $s (@SUITES) { + my $key = $s; + mkpath ( "$wwwdir/$key" ); + open $pages{$key}{fh}, '>', "$wwwdir/$key/allpackages.en.html.new" + or die "can't open index file for output: $!"; + $pages{$key}{textgz} = gzopen("$wwwdir/$key/allpackages.en.txt.gz.new", + 'wb9') + or die "can't open text index file for output: $!"; + + my $title = sprintf( _g( "Software Packages in \"%s\"" ), + $key ); + print {$pages{$key}{fh}} header( title => $title, + title_keywords => "debian, $s", + desc => encode_entities( $title, '"' ), + lang => 'en' ), + title( $title ), '
'; + my $title_txt = sprintf( _g( "All Debian Packages in \"%s\"" ), + $key )."\n\n"; + $title_txt .= _g( "Last Modified: " ).gmtime()."\n". + sprintf(_g( "Copyright (C) 1997-%d SPI;\nSee for the license terms."), (gmtime)[5]+1900 )."\n\n"; + $pages{$key}{textgz}->gzwrite($title_txt); + + foreach my $sec (keys %{$sections->{$s}}) { + mkpath ( "$wwwdir/$key/$sec" ); + open $pages{$key}{$sec}{fh}, '>', "$wwwdir/$key/$sec/index.en.html.new" + or die "can't open index file for output: $!"; + $title = sprintf( _g( "Software Packages in \"%s\", section %s" ), + $key, $sec ); + print {$pages{$key}{$sec}{fh}} header( title => $title, + title_keywords => "debian, $s, $sec", + desc => encode_entities( $title, '"' ), + lang => 'en' ), + title( $title ), '
'; + } + foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { + next if $ssec eq '-'; + mkpath ( "$wwwdir/$key/$ssec" ); + open $pages{$key}{$ssec}{fh}, '>', "$wwwdir/$key/$ssec/index.en.html.new" + or die "can't open index file for output: $!"; + $title = sprintf( _g( "Software Packages in \"%s\", subsection %s" ), + $key, $ssec ); + print {$pages{$key}{$ssec}{fh}} header( title => $title, + title_keywords => "debian, $s, $ssec", + desc => encode_entities( $title, '"' ), + lang => 'en' ), + title( $title ), '
'; + } + foreach my $prio (keys %{$priorities->{$s}}) { + next if $prio eq '-'; + mkpath ( "$wwwdir/$key/$prio" ); + open $pages{$key}{$prio}{fh}, '>', "$wwwdir/$key/$prio/index.en.html.new" + or die "can't open index file for output: $!"; + $title = sprintf( _g( "Software Packages in \"%s\", priority %s" ), + $key, $prio ); + print {$pages{$key}{$prio}{fh}} header( title => $title, + title_keywords => "debian, $s, $prio", + desc => encode_entities( $title, '"' ), + lang => 'en' ), + title( $title ), '
'; } } print "writing package info ...\n"; while (my ($pkg, $data) = each %packages) { - my %pkg; - foreach (split /\000/o, $data) { + my (%pkg,%virt); + my ($virt, $p_data) = split /\000/o, $data, 2; + %virt = split /\01/o, $virt; + foreach (split /\000/o, $p_data||'') { my @data = split ( /\s/o, $_, 8 ); - my $key = $data[1]; - if ($data[0] !~ /^(?:us|security|non-US)$/o) { - $key = "$data[1]/$data[0]"; - } - $pkg{$key} ||= new Packages::Page( $pkg ); - if ($data[2] ne 'virtual') { - $pkg{$key}->merge_package( { package => $pkg, + $pkg{$data[1]} ||= new Packages::Page( $pkg ); + $pkg{$data[1]}->merge_package( { package => $pkg, archive => $data[0], suite => $data[1], architecture => $data[2], @@ -207,10 +170,13 @@ while (my ($pkg, $data) = each %packages) { priority => $data[5], version => $data[6], description => $data[7] } ); - } else { - $pkg{$key}->add_provided_by([split /\s+/, $data[7]]); - } } + foreach (keys %virt) { + next if $_ eq '-'; + $pkg{$_} ||= new Packages::Page( $pkg ); + $pkg{$_}->add_provided_by([split /\s+/, $virt{$_}]); + } + while (my ($key, $entry) = each %pkg) { if (my $provided_by = $entry->{provided_by}) { my $str = "
$pkg ". @@ -228,7 +194,7 @@ while (my ($pkg, $data) = each %packages) { my $short_desc_txt = $entry->get_newest( 'description' ); my $short_desc = encode_entities( $short_desc_txt, "<>&\"" ); my $priority = $entry->get_newest( 'priority' ); - + my $str = "
$pkg ($v_str) "; my $txt_str = "$pkg ($v_str)"; if ($section ne 'main') { @@ -240,9 +206,11 @@ while (my ($pkg, $data) = each %packages) { $txt_str .= " [$archive]"; } $str .= "
\n
$short_desc
\n"; - $txt_str .= " $short_desc_txt\n"; + $txt_str .= " $short_desc_txt\n"; print {$pages{$key}{fh}} $str or die "couldn't write to output file: $!"; + $pages{$key}{textgz}->gzwrite($txt_str) + or die "couldn't write to output file: ".$pages{$key}{textgz}->gzerror; print {$pages{$key}{$section}{fh}} $str or die "couldn't write to output file: $!"; if ($subsection ne '-') { @@ -258,47 +226,37 @@ while (my ($pkg, $data) = each %packages) { print "closing files ...\n"; foreach my $s (@SUITES) { - foreach my $a (@ARCHIVES) { - next if $a eq 'security'; - next if $a eq 'non-US'; - my $key = ($a eq 'us') ? $s : "$s/$a"; - my $root = ($a eq 'us') ? '' : '../'; - print {$pages{$key}{index}{fh}} '
', - "

". - gettext( "All packages" ) ."
(". - gettext( "compact compressed textlist" ).")

\n"; - print {$pages{$key}{index}{fh}} trailer( "$root../" ); - close $pages{$key}{index}{fh} or - warn "can't open index file for output $wwwdir/$key/index.en.html.new: $!"; - rename( "$wwwdir/$key/index.en.html.new", - "$wwwdir/$key/index.en.html" ); - print {$pages{$key}{fh}} '
', trailer( "$root../" ); - close $pages{$key}{fh} or - warn "can't close index file $wwwdir/$key/allpackages.en.html.new: $!"; - rename( "$wwwdir/$key/allpackages.en.html.new", - "$wwwdir/$key/allpackages.en.html" ); - foreach my $sec (keys %{$sections->{$s}{$a}}) { - print {$pages{$key}{$sec}{fh}} '
', trailer( "$root../../" ); - close $pages{$key}{$sec}{fh} or - warn "can't close index file $wwwdir/$key/$sec/index.en.html.new: $!"; - rename( "$wwwdir/$key/$sec/index.en.html.new", - "$wwwdir/$key/$sec/index.en.html" ); - } - foreach my $ssec ((keys %{$subsections->{$s}{$a}}, 'virtual')) { - next if $ssec eq '-'; - print {$pages{$key}{$ssec}{fh}} '
', trailer( "$root../../" ); - close $pages{$key}{$ssec}{fh} or - warn "can't close index file $wwwdir/$key/$ssec/index.en.html.new: $!"; - rename( "$wwwdir/$key/$ssec/index.en.html.new", - "$wwwdir/$key/$ssec/index.en.html" ); - } - foreach my $prio (keys %{$priorities->{$s}{$a}}) { - next if $prio eq '-'; - print {$pages{$key}{$prio}{fh}} '
', trailer( "$root../../" ); - close $pages{$key}{$prio}{fh} or - warn "can't close index file $wwwdir/$key/$prio/index.en.html.new: $!"; - rename( "$wwwdir/$key/$prio/index.en.html.new", - "$wwwdir/$key/$prio/index.en.html" ); - } + my $key = $s; + print {$pages{$key}{fh}} '', trailer( "../" ); + $pages{$key}{textgz}->gzclose or + warn "can't close text index file $wwwdir/$key/allpackages.en.txt.gz.new: ".$pages{$key}{textgz}->gzerror; + close $pages{$key}{fh} or + warn "can't close index file $wwwdir/$key/allpackages.en.html.new: $!"; + rename( "$wwwdir/$key/allpackages.en.html.new", + "$wwwdir/$key/allpackages.en.html" ); + rename( "$wwwdir/$key/allpackages.en.txt.gz.new", + "$wwwdir/$key/allpackages.en.txt.gz" ); + foreach my $sec (keys %{$sections->{$s}{'us'}}) { + print {$pages{$key}{$sec}{fh}} '', trailer( "../../" ); + close $pages{$key}{$sec}{fh} or + warn "can't close index file $wwwdir/$key/$sec/index.en.html.new: $!"; + rename( "$wwwdir/$key/$sec/index.en.html.new", + "$wwwdir/$key/$sec/index.en.html" ); + } + foreach my $ssec ((keys %{$subsections->{$s}}, 'virtual')) { + next if $ssec eq '-'; + print {$pages{$key}{$ssec}{fh}} '', trailer( "../../" ); + close $pages{$key}{$ssec}{fh} or + warn "can't close index file $wwwdir/$key/$ssec/index.en.html.new: $!"; + rename( "$wwwdir/$key/$ssec/index.en.html.new", + "$wwwdir/$key/$ssec/index.en.html" ); + } + foreach my $prio (keys %{$priorities->{$s}}) { + next if $prio eq '-'; + print {$pages{$key}{$prio}{fh}} '', trailer( "../../" ); + close $pages{$key}{$prio}{fh} or + warn "can't close index file $wwwdir/$key/$prio/index.en.html.new: $!"; + rename( "$wwwdir/$key/$prio/index.en.html.new", + "$wwwdir/$key/$prio/index.en.html" ); } }