2 # Debian.pl: Frontend to debian contents and packages files
4 # Version: v0.8 (20000918)
12 # format: "alias=real".
14 my $defaultdist = "woody";
17 "testing" => "woody, # new since 20001219.
19 "incoming" => "incoming",
20 ### the following don't work. too much effort to get 3 types of distros
21 ### to work harmoniously :-)
22 "slink" => "archive-2.1",
23 "hamm" => "archive-2.0",
24 "rex" => "archive-1.?",
25 "bo" => "archive-1.?",
29 "debian/Contents-##DIST-i386.gz" =>
30 "ftp://ftp.us.debian.org".
31 "/debian/dists/##DIST/Contents-i386.gz",
32 ### APPEARS TO BE FIXED?
33 # => strip control chars just to be safe.
34 "debian/Contents-##DIST-i386-non-US.gz" =>
35 "ftp://ftp.ca.debian.org".
36 "/debian-non-US/dists/##DIST/non-US/Contents-i386.gz",
40 "debian/Packages-##DIST-main-i386.gz" =>
41 "ftp://ftp.us.debian.org".
42 "/debian/dists/##DIST/main/binary-i386/Packages.gz",
43 "debian/Packages-##DIST-contrib-i386.gz" =>
44 "ftp://ftp.us.debian.org".
45 "/debian/dists/##DIST/contrib/binary-i386/Packages.gz",
46 "debian/Packages-##DIST-non-free-i386.gz" =>
47 "ftp://ftp.us.debian.org".
48 "/debian/dists/##DIST/non-free/binary-i386/Packages.gz",
50 "debian/Packages-##DIST-non-US-main-i386.gz" =>
51 "ftp://ftp.ca.debian.org".
52 "/debian-non-US/dists/##DIST/non-US/main/binary-i386/Packages.gz",
53 "debian/Packages-##DIST-non-US-contrib-i386.gz" =>
54 "ftp://ftp.ca.debian.org".
55 "/debian-non-US/dists/##DIST/non-US/contrib/binary-i386/Packages.gz",
56 "debian/Packages-##DIST-non-US-non-free-i386.gz" =>
57 "ftp://ftp.ca.debian.org".
58 "/debian-non-US/dists/##DIST/non-US/non-free/binary-i386/Packages.gz",
62 ### COMMON FUNCTION....
63 #######################
66 # Usage: &DebianDownload(%hash);
68 my ($dist, %urls) = @_;
69 my $refresh = $main::param{'debianRefreshInterval'} * 60 * 60 * 24;
74 &main::status("Debian: creating debian dir.");
75 mkdir("debian/",0755);
82 foreach $file (keys %urls) {
83 my $url = $urls{$file};
84 $url =~ s/##DIST/$dist/g;
85 $file =~ s/##DIST/$dist/g;
89 my $last_refresh = (stat($file))[9];
90 $update++ if (time() - $last_refresh > $refresh);
95 next unless ($update);
97 &main::DEBUG("announce == $announce.");
98 if ($good + $bad == 0 and !$announce) {
99 &main::status("Debian: Downloading files for '$dist'.");
100 &main::msg($main::who, "Updating debian files... please wait.");
104 if (exists $main::debian{$url}) {
105 &main::DEBUG("2: ".(time - $main::debian{$url})." <= $refresh");
106 next if (time() - $main::debian{$url} <= $refresh);
107 &main::DEBUG("stale for url $url; updating!");
110 if ($url =~ /^ftp:\/\/(.*?)\/(\S+)\/(\S+)$/) {
111 my ($host,$path,$thisfile) = ($1,$2,$3);
113 # error internally to ftp.
114 # hope it doesn't do anything bad.
115 if ($file =~ /Contents-woody-i386-non-US/) {
116 &main::DEBUG("Skipping Contents-woody-i386-non-US.");
117 # $file =~ s/woody/potato/;
118 # $path =~ s/woody/potato/;
122 if (!&main::ftpGet($host,$path,$thisfile,$file)) {
123 &main::WARN("deb: down: $file == BAD.");
129 &main::DEBUG("deb: down: ftpGet: !file");
134 if ($file =~ /Contents-potato-i386-non-US/) {
135 &main::DEBUG("hack: using potato's non-US contents for woody.");
136 system("cp debian/Contents-potato-i386-non-US.gz debian/Contents-woody-i386-non-US.gz");
139 &main::DEBUG("deb: download: good.");
143 &main::ERROR("Debian: invalid format of url => ($url).");
150 &generateIndex($dist);
153 return -1 unless ($bad); # no download.
154 &main::DEBUG("DD: !good and bad($bad). :(");
159 ###########################
160 # DEBIAN CONTENTS SEARCH FUNCTIONS.
164 # Usage: &searchContents($query);
166 my ($dist, $query) = &getDistroFromStr($_[0]);
167 &main::status("Debian: Contents search for '$query' on $dist.");
170 $dccsend++ if ($query =~ s/^dcc\s+//i);
172 # $query = $query.'(\.so\.)?([.[[:digit:]]+\.]+)?$';
174 $query =~ s/\\([\^\$])/$1/g; # hrm?
175 $query =~ s/^\s+|\s+$//g;
177 if (!&main::validExec($query)) {
178 &main::msg($main::who, "search string looks fuzzy.");
182 if ($dist eq "incoming") { # nothing yet.
183 &main::DEBUG("sC: dist = 'incoming'. no contents yet.");
186 my %urls = &fixDist($dist, %urlcontents);
187 # download contents file.
188 &main::DEBUG("deb: download 1.");
189 if (!&DebianDownload($dist, %urls)) {
190 &main::WARN("Debian: could not download files.");
195 my $start_time = &main::gettimeofday();
201 ### TODO: search properly if /usr/bin/blah is done.
202 if ($query =~ s/\$$//) {
203 &main::DEBUG("search-regex found.");
204 $grepRE = "$query\[ \t]";
205 } elsif ($query =~ s/^\^//) {
206 &main::DEBUG("front marker regex found.");
210 $grepRE = "$query*\[ \t]";
213 ### fix up grepRE for "*".
214 $grepRE =~ s/\*/.*/g;
217 foreach (keys %urlcontents) {
220 next unless ( -f $_);
224 if (!scalar @files) {
225 &main::ERROR("sC: no files?");
226 &main::msg($main::who, "failed.");
230 my $files = join(' ', @files);
232 open(IN,"zegrep -h '$grepRE' $files |");
234 if (/^\.?\/?(.*?)[\t\s]+(\S+)\n$/) {
235 my ($file,$package) = ("/".$1,$2);
236 if ($query =~ /\//) {
237 next unless ($file =~ /\Q$query\E/);
239 my ($basename) = $file =~ /^.*\/(.*)$/;
240 next unless ($basename =~ /\Q$query\E/);
242 next if ($query !~ /\.\d\.gz/ and $file =~ /\/man\//);
243 next if ($front and $file !~ /^\/\Q$query\E/);
245 $contents{$package}{$file} = 1;
249 last if ($found > 100);
255 ### send results with dcc.
257 if (exists $main::dcc{'SEND'}{$main::who}) {
258 &main::msg($main::who, "DCC already active!");
262 if (!scalar %contents) {
263 &main::msg($main::who,"search returned no results.");
267 my $file = "$main::param{tempDir}/$main::who.txt";
268 if (!open(OUT,">$file")) {
269 &main::ERROR("Debian: cannot write file for dcc send.");
273 foreach $pkg (keys %contents) {
274 foreach (keys %{$contents{$pkg}}) {
275 # TODO: correct padding.
276 print OUT "$_\t\t\t$pkg\n";
281 &main::shmWrite($main::shm, "DCC SEND $main::who $file");
286 &main::status("Debian: $found contents results found.");
289 foreach $pkg (keys %contents) {
290 my @tmplist = &main::fixFileList(keys %{$contents{$pkg}});
291 my @sublist = sort { length $a <=> length $b } @tmplist;
293 pop @sublist while (scalar @sublist > 3);
295 $pkg =~ s/\,/\037\,\037/g; # underline ','.
296 push(@list, "(". join(', ',@sublist) .") in $pkg");
298 # sort the total list from shortest to longest...
299 @list = sort { length $a <=> length $b } @list;
301 # show how long it took.
302 my $delta_time = &main::gettimeofday() - $start_time;
303 &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
305 my $prefix = "Debian Search of '$query' ";
306 if (scalar @list) { # @list.
307 &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
309 &main::DEBUG("ok, !\@list, searching desc for '$query'.");
315 # Usage: &searchAuthor($query);
317 my ($dist, $query) = &getDistroFromStr($_[0]);
318 &main::DEBUG("searchAuthor: dist => '$dist', query => '$query'.");
319 $query =~ s/^\s+|\s+$//g;
322 my $start_time = &main::gettimeofday();
323 &main::status("Debian: starting author search.");
326 my ($bad,$good) = (0,0);
327 my %urls = %urlpackages;
329 foreach (keys %urlpackages) {
341 &main::DEBUG("good = $good, bad = $bad...");
343 if ($good == 0 and $bad != 0) {
344 my %urls = &fixDist($dist, %urlpackages);
345 &main::DEBUG("deb: download 2.");
346 if (!&DebianDownload($dist, %urls)) {
347 &main::ERROR("Debian(sA): could not download files.");
352 my (%maint, %pkg, $package);
353 open(IN,"zegrep -h '^Package|^Maintainer' $files |");
355 if (/^Package: (\S+)$/) {
357 } elsif (/^Maintainer: (.*) \<(\S+)\>$/) {
358 my($name,$email) = ($1,$2);
359 if ($package eq "") {
360 &main::DEBUG("sA: package == NULL.");
363 $maint{$name}{$email} = 1;
364 $pkg{$name}{$package} = 1;
367 &main::WARN("invalid line: '$_'.");
373 # TODO: can we use 'map' here?
374 foreach (grep /\Q$query\E/i, keys %maint) {
378 # TODO: should we only search email if '@' is used?
379 if (scalar keys %hash < 15) {
381 foreach $name (keys %maint) {
383 foreach $email (keys %{$maint{$name}}) {
384 next unless ($email =~ /\Q$query\E/i);
385 next if (exists $hash{$name});
391 my @list = keys %hash;
392 if (scalar @list != 1) {
393 my $prefix = "Debian Author Search of '$query' ";
394 &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
398 &main::DEBUG("showing all packages by '$list[0]'...");
400 my @pkg = sort keys %{$pkg{$list[0]}};
402 # show how long it took.
403 my $delta_time = &main::gettimeofday() - $start_time;
404 &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
406 my $email = join(', ', keys %{$maint{$list[0]}});
407 my $prefix = "Debian Packages by $list[0] \002<\002$email\002>\002 ";
408 &main::performStrictReply( &main::formListReply(0, $prefix, @pkg) );
412 # Usage: &searchDesc($query);
414 my ($dist, $query) = &getDistroFromStr($_[0]);
415 &main::DEBUG("searchDesc: dist => '$dist', query => '$query'.");
416 $query =~ s/^\s+|\s+$//g;
419 my $start_time = &main::gettimeofday();
420 &main::status("Debian: starting desc search.");
423 my ($bad,$good) = (0,0);
424 my %urls = %urlpackages;
426 foreach (keys %urlpackages) {
438 &main::DEBUG("good = $good, bad = $bad...");
440 if ($good == 0 and $bad != 0) {
441 my %urls = &fixDist($dist, %urlpackages);
442 &main::DEBUG("deb: download 2c.");
443 if (!&DebianDownload($dist, %urls)) {
444 &main::ERROR("Debian(sD): could not download files.");
449 my (%desc, $package);
450 open(IN,"zegrep -h '^Package|^Description' $files |");
452 if (/^Package: (\S+)$/) {
454 } elsif (/^Description: (.*)$/) {
456 next unless ($desc =~ /\Q$query\E/i);
457 if ($package eq "") {
458 &main::WARN("sD: package == NULL?");
461 $desc{$package} = $desc;
464 &main::WARN("invalid line: '$_'.");
469 my @list = keys %desc;
471 my $prefix = "Debian Desc Search of '$query' ";
472 &main::performStrictReply( &main::formListReply(0, $prefix, ) );
473 } elsif (scalar @list == 1) { # list = 1.
474 &main::DEBUG("list == 1; showing package info of '$list[0]'.");
475 &infoPackages("info", $list[0]);
477 my $prefix = "Debian Desc Search of '$query' ";
478 &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
481 # show how long it took.
482 my $delta_time = &main::gettimeofday() - $start_time;
483 &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
487 # Usage: &generateIncoming();
488 sub generateIncoming {
489 my $interval = $main::param{'debianRefreshInterval'};
490 my $pkgfile = "debian/Packages-incoming";
491 my $idxfile = $pkgfile.".idx";
493 $stale++ if (&main::isStale($pkgfile.".gz", $interval));
494 $stale++ if (&main::isStale($idxfile, $interval));
495 &main::DEBUG("gI: stale => '$stale'.");
496 return 0 unless ($stale);
499 my %ftp = &main::ftpList("llug.sep.bnl.gov", "/pub/debian/Incoming/");
501 if (!open(PKG,">$pkgfile")) {
502 &main::ERROR("cannot write to pkg $pkgfile.");
505 if (!open(IDX,">$idxfile")) {
506 &main::ERROR("cannot write to idx $idxfile.");
510 print IDX "*$pkgfile.gz\n";
512 foreach $file (sort keys %ftp) {
513 next unless ($file =~ /deb$/);
515 if ($file =~ /^(\S+)\_(\S+)\_(\S+)\.deb$/) {
517 print PKG "Package: $1\n";
518 print PKG "Version: $2\n";
519 print PKG "Architecture: ", (defined $4) ? $4 : "all", "\n";
521 print PKG "Filename: $file\n";
522 print PKG "Size: $ftp{$file}\n";
528 system("gzip -9fv $pkgfile"); # lame fix.
530 &main::status("Debian: generateIncoming() complete.");
534 ##############################
535 # DEBIAN PACKAGE INFO FUNCTIONS.
538 # Usage: &getPackageInfo($query,$file);
540 my ($package, $file) = @_;
543 &main::status("gPI: file $file does not exist?");
550 open(IN, "zcat $file 2>&1 |");
556 next if (/^ \S+/); # package long description.
559 if (/^Package: (.*)\n$/) {
561 if ($pkg =~ /^$package$/i) {
562 $found++; # we can use pkg{'package'} instead.
563 $pkg{'package'} = $pkg;
572 if (/^Version: (.*)$/) {
573 $pkg{'version'} = $1;
574 } elsif (/^Priority: (.*)$/) {
575 $pkg{'priority'} = $1;
576 } elsif (/^Section: (.*)$/) {
577 $pkg{'section'} = $1;
578 } elsif (/^Size: (.*)$/) {
580 } elsif (/^Installed-Size: (.*)$/i) {
581 $pkg{'installed'} = $1;
582 } elsif (/^Description: (.*)$/) {
584 } elsif (/^Filename: (.*)$/) {
586 } elsif (/^Pre-Depends: (.*)$/) {
587 $pkg{'depends'} = "pre-depends on $1";
588 } elsif (/^Depends: (.*)$/) {
589 if (exists $pkg{'depends'}) {
590 $pkg{'depends'} .= "; depends on $1";
592 $pkg{'depends'} = "depends on $1";
594 } elsif (/^Maintainer: (.*)$/) {
596 } elsif (/^Provides: (.*)$/) {
597 $pkg{'provides'} = $1;
598 } elsif (/^Suggests: (.*)$/) {
599 $pkg{'suggests'} = $1;
600 } elsif (/^Conflicts: (.*)$/) {
601 $pkg{'conflicts'} = $1;
604 ### &main::DEBUG("=> '$_'.");
614 next if (defined $pkg);
622 # Usage: &infoPackages($query,$package);
624 my ($query,$dist,$package) = ($_[0], &getDistroFromStr($_[1]));
625 my $interval = $main::param{'debianRefreshInterval'} || 7;
627 &main::status("Debian: Searching for package '$package' in '$dist'.");
629 # download packages file.
631 my %urls = &fixDist($dist, %urlpackages);
632 if ($dist ne "incoming") {
633 &main::DEBUG("deb: download 3.");
634 if (!&DebianDownload($dist, %urls)) { # no good download.
635 &main::WARN("Debian(iP): could not download ANY files.");
639 # check if the package is valid.
641 my @files = &validPackage($package, $dist);
642 if (!scalar @files) {
643 &main::status("Debian: no valid package found; checking incoming.");
644 @files = &validPackage($package, "incoming");
646 &main::status("Debian: cool, it exists in incoming.");
649 &main::msg($main::who, "Package '$package' does not exist.");
654 if (scalar @files > 1) {
655 &main::WARN("same package in more than one file; random.");
656 &main::DEBUG("THIS SHOULD BE FIXED SOMEHOW!!!");
657 $files[0] = &main::getRandom(@files);
660 if (! -f $files[0]) {
661 &main::WARN("files[0] ($files[0]) doesn't exist.");
662 &main::msg($main::who, "WARNING: $files[0] does not exist? FIXME");
666 ### TODO: if specific package is requested, note down that a version
667 ### exists in incoming.
670 my $file = $files[0];
673 ### TODO: use fe, dump to a hash. if only one version of the package
674 ### exists. do as normal otherwise list all versions.
676 &main::ERROR("D:iP: file '$file' DOES NOT EXIST!!! should never happen.");
679 my %pkg = &getPackageInfo($package, $file);
682 if ($query eq "info") {
683 if (scalar keys %pkg > 5) {
684 $pkg{'info'} = "\002(\002". $pkg{'desc'} ."\002)\002";
685 $pkg{'info'} .= ", section ".$pkg{'section'};
686 $pkg{'info'} .= ", is ".$pkg{'priority'};
687 $pkg{'info'} .= ". Version: \002$pkg{'version'}\002";
688 $pkg{'info'} .= ", Packaged size: \002". int($pkg{'size'}/1024) ."\002 kB";
689 $pkg{'info'} .= ", Installed size: \002$pkg{'installed'}\002 kB";
692 &main::status("iP: info requested and pkg is in incoming, too.");
693 my %incpkg = &getPackageInfo($query, "debian/Packages-incoming");
695 if (scalar keys %incpkg) {
696 $pkg{'info'} .= ". Is in incoming ($incpkg{'file'}).";
698 &main::ERROR("iP: pkg $query is in incoming but we couldn't get any info?");
702 &main::DEBUG("running debianCheck() due to problems (".scalar(keys %pkg).").");
704 &main::DEBUG("end of debianCheck()");
706 &main::msg($main::who,"Debian: Package appears to exist but I could not retrieve info about it...");
711 if ($dist eq "incoming") {
712 $pkg{'info'} .= "Version: \002$pkg{'version'}\002";
713 $pkg{'info'} .= ", Packaged size: \002". int($pkg{'size'}/1024) ."\002 kB";
714 $pkg{'info'} .= ", is in incoming!!!";
717 if (!exists $pkg{$query}) {
718 if ($query eq "suggests") {
719 $pkg{$query} = "has no suggestions";
720 } elsif ($query eq "conflicts") {
721 $pkg{$query} = "does not conflict with any other package";
722 } elsif ($query eq "depends") {
723 $pkg{$query} = "does not depend on anything";
724 } elsif ($query eq "maint") {
725 $pkg{$query} = "has no maintainer";
727 $pkg{$query} = "has nothing about $query";
731 &main::performStrictReply("$package: $pkg{$query}");
734 # Usage: &infoStats($dist);
737 $dist = &getDistro($dist);
738 return unless (defined $dist);
740 &main::DEBUG("infoS: dist => '$dist'.");
741 my $interval = $main::param{'debianRefreshInterval'} || 7;
743 # download packages file if needed.
744 my %urls = &fixDist($dist, %urlpackages);
745 &main::DEBUG("deb: download 4.");
746 if (!&DebianDownload($dist, %urls)) {
747 &main::WARN("Debian(iS): could not download ANY files.");
748 &main::msg($main::who, "Debian(iS): internal error.");
755 foreach $file (keys %urlpackages) {
756 $file =~ s/##DIST/$dist/g; # won't work for incoming.
757 &main::DEBUG("file => '$file'.");
758 if (exists $stats{$file}{'count'}) {
759 &main::DEBUG("hrm... duplicate open with $file???");
763 open(IN,"zcat $file 2>&1 |");
766 &main::DEBUG("iS: $file does not exist.");
773 next if (/^ \S+/); # package long description.
775 if (/^Package: (.*)\n$/) { # counter.
776 $stats{$file}{'count'}++;
778 } elsif (/^Maintainer: .* <(\S+)>$/) {
779 $stats{$file}{'maint'}{$1}++;
780 $total{'maint'}{$1}++;
781 } elsif (/^Size: (.*)$/) { # compressed size.
782 $stats{$file}{'csize'} += $1;
783 $total{'csize'} += $1;
784 } elsif (/^i.*size: (.*)$/i) { # installed size.
785 $stats{$file}{'isize'} += $1;
786 $total{'isize'} += $1;
789 ### &main::DEBUG("=> '$_'.");
794 ### TODO: don't count ppl with multiple email addresses.
796 &main::performStrictReply(
797 "Debian Distro Stats on $dist... ".
798 "\002$total{'count'}\002 packages, ".
799 "\002".scalar(keys %{$total{'maint'}})."\002 maintainers, ".
800 "\002". int($total{'isize'}/1024)."\002 MB installed size, ".
801 "\002". int($total{'csize'}/1024/1024)."\002 MB compressed size."
804 ### TODO: do individual stats? if so, we need _another_ arg.
805 # foreach $file (keys %stats) {
806 # foreach (keys %{$stats{$file}}) {
807 # &main::DEBUG(" '$file' '$_' '$stats{$file}{$_}'.");
817 # HELPER FUNCTIONS FOR INFOPACKAGES...
820 # Usage: &generateIndex();
823 &main::status("Debian: !!! generateIndex() called !!!");
824 if (!scalar @dists or $dists[0] eq '') {
825 &main::ERROR("gI: no dists to generate index.");
830 my $dist = &getDistro($_); # incase the alias is returned, possible?
831 my $idx = "debian/Packages-$dist.idx";
833 # TODO: check if any of the Packages file have been updated then
834 # regenerate it, even if it's not stale.
835 # TODO: also, regenerate the index if the packages file is newer
837 next unless (&main::isStale($idx, $main::param{'debianRefreshInterval'}));
839 &main::DEBUG("gIndex: calling generateIncoming()!");
845 &main::DEBUG("Copying old index of woody to -old");
846 system("cp $idx $idx-old");
849 &main::DEBUG("gIndeX: calling DebianDownload($dist, ...).");
850 &DebianDownload($dist, %urlpackages);
852 &main::status("Debian: generating index for '$dist'.");
853 if (!open(OUT,">$idx")) {
854 &main::ERROR("cannot write to $idx.");
859 foreach $packages (keys %urlpackages) {
860 $packages =~ s/##DIST/$dist/;
862 if (! -e $packages) {
863 &main::ERROR("gIndex: '$packages' does not exist?");
867 print OUT "*$packages\n";
868 open(IN,"zcat $packages |");
871 next unless (/^Package: (.*)\n$/);
882 # Usage: &validPackage($package, $dist);
884 my ($package,$dist) = @_;
888 &main::DEBUG("D: validPackage($package, $dist) called.");
891 while (!open(IN, "debian/Packages-$dist.idx")) {
893 &main::ERROR("Packages-$dist.idx does not exist (#1).");
897 &generateIndex($dist);
909 if (/^$package\n$/) {
916 &main::DEBUG("vP: scanned $count items in index.");
922 my ($dist, $query) = &getDistroFromStr($_[0]);
923 my $file = "debian/Packages-$dist.idx";
928 if ($query =~ tr/A-Z/a-z/) {
932 &main::status("Debian: Search package matching '$query' in '$dist'.");
933 unlink $file if ( -z $file);
935 while (!open(IN, $file)) {
936 if ($dist eq "incoming") {
937 &main::DEBUG("sP: dist == incoming; calling gI().");
942 &main::ERROR("could not generate index!!!");
947 &main::DEBUG("should we be doing this?");
948 &generateIndex(($dist));
957 if (&main::isStale($file, $main::param{'debianRefreshInterval'})) {
958 &main::DEBUG("STALE $file! regen.");
959 &generateIndex(($dist));
960 ### @files = searchPackage("$query $dist");
961 &main::DEBUG("EVIL HACK HACK HACK.");
974 if (scalar @files and $warn) {
975 &main::msg($main::who, "searching for package name should be fully lowercase!");
984 if (!defined $dist or $dist eq "") {
985 &main::DEBUG("gD: dist == NULL; dist = defaultdist.");
986 $dist = $defaultdist;
989 if ($dist =~ /^(slink|hamm|rex|bo)$/i) {
990 &main::DEBUG("Debian: deprecated version ($dist).");
991 &main::msg($main::who, "Debian: deprecated distribution version.");
995 if (exists $dists{$dist}) {
996 return $dists{$dist};
998 if (!grep /^\Q$dist\E$/i, %dists) {
999 &main::msg($main::who, "invalid dist '$dist'.");
1007 sub getDistroFromStr {
1009 my $dists = join '|', %dists;
1010 my $dist = $defaultdist;
1012 if ($str =~ s/\s+($dists)$//i) {
1013 $dist = &getDistro(lc $1);
1016 $str =~ s/\\([\$\^])/$1/g;
1022 my ($dist, %urls) = @_;
1026 while (($key,$val) = each %urls) {
1027 $key =~ s/##DIST/$dist/;
1028 $val =~ s/##DIST/$dist/;
1029 ### TODO: what should we do if the sar wasn't done.
1036 ### H-H-H-HACK HACK HACK :)
1038 my ($dist, $query) = &getDistroFromStr($str);
1039 my @results = sort &searchPackage($str);
1041 if (!scalar @results) {
1042 &main::Forker("debian", sub { &searchContents($str); } );
1043 } elsif (scalar @results == 1) {
1044 &main::status("searchPackage returned one result; getting info of package instead!");
1045 &main::Forker("debian", sub { &infoPackages("info", "$results[0] $dist"); } );
1047 my $prefix = "Debian Package Listing of '$str' ";
1048 &main::performStrictReply( &main::formListReply(0, $prefix, @results) );
1053 my $dir = "debian/";
1056 &main::status("debianCheck() called.");
1058 ### TODO: remove the following loop (check if dir exists before)
1060 last if (opendir(DEBIAN, $dir));
1062 &main::ERROR("dC: cannot opendir debian.");
1071 while (defined($file = readdir DEBIAN)) {
1072 next unless ($file =~ /(gz|bz2)$/);
1074 my $exit = system("gzip -t '$dir/$file'");
1075 next unless ($exit);
1076 &main::DEBUG("hmr... => ".(time() - (stat($file))[8])."'.");
1077 next unless (time() - (stat($file))[8] > 3600);
1079 &main::DEBUG("dC: exit => '$exit'.");
1080 &main::WARN("dC: '$dir/$file' corrupted? deleting!");
1081 unlink $dir."/".$file;