2 # Debian.pl: Frontend to debian contents and packages files
4 # Version: v0.8 (20000918)
12 # format: "alias=real".
14 my $defaultdist = "woody";
16 "unstable" => "woody",
18 "incoming" => "incoming",
19 "slink" => "archive-2.1",
20 "hamm" => "archive-2.0",
21 "rex" => "archive-1.?",
22 "bo" => "archive-1.?",
26 "debian/Contents-##DIST-i386.gz" =>
27 "ftp://ftp.us.debian.org".
28 "/debian/dists/##DIST/Contents-i386.gz",
30 # "debian/Contents-##DIST-i386-non-US.gz" =>
31 # "ftp://ftp.ca.debian.org".
32 # "/debian-non-US/dists/##DIST/non-US/Contents-i386.gz",
37 "debian/Packages-##DIST-main-i386.gz" =>
38 "ftp://ftp.us.debian.org".
39 "/debian/dists/##DIST/main/binary-i386/Packages.gz",
40 "debian/Packages-##DIST-contrib-i386.gz" =>
41 "ftp://ftp.us.debian.org".
42 "/debian/dists/##DIST/contrib/binary-i386/Packages.gz",
43 "debian/Packages-##DIST-non-free-i386.gz" =>
44 "ftp://ftp.us.debian.org".
45 "/debian/dists/##DIST/non-free/binary-i386/Packages.gz",
47 "debian/Packages-##DIST-non-US-main-i386.gz" =>
48 "ftp://ftp.ca.debian.org".
49 "/debian-non-US/dists/##DIST/non-US/main/binary-i386/Packages.gz",
50 "debian/Packages-##DIST-non-US-contrib-i386.gz" =>
51 "ftp://ftp.ca.debian.org".
52 "/debian-non-US/dists/##DIST/non-US/contrib/binary-i386/Packages.gz",
53 "debian/Packages-##DIST-non-US-non-free-i386.gz" =>
54 "ftp://ftp.ca.debian.org".
55 "/debian-non-US/dists/##DIST/non-US/non-free/binary-i386/Packages.gz",
59 ### COMMON FUNCTION....
60 #######################
63 # Usage: &DebianDownload(%hash);
65 my ($dist, %urls) = @_;
66 my $refresh = $main::param{'debianRefreshInterval'} * 60 * 60 * 24;
71 &main::status("Debian: creating debian dir.");
72 mkdir("debian/",0755);
79 foreach $file (keys %urls) {
80 my $url = $urls{$file};
81 $url =~ s/##DIST/$dist/g;
82 $file =~ s/##DIST/$dist/g;
86 my $last_refresh = (stat($file))[9];
87 $update++ if (time() - $last_refresh > $refresh);
92 next unless ($update);
94 &main::DEBUG("announce == $announce.");
95 if ($good + $bad == 0 and !$announce) {
96 &main::status("Debian: Downloading files for '$dist'.");
97 &main::msg($main::who, "Updating debian files... please wait.");
101 if (exists $main::debian{$url}) {
102 &main::DEBUG("2: ".(time - $main::debian{$url})." <= $refresh");
103 next if (time() - $main::debian{$url} <= $refresh);
104 &main::DEBUG("stale for url $url; updating!");
107 if ($url =~ /^ftp:\/\/(.*?)\/(\S+)\/(\S+)$/) {
108 my ($host,$path,$thisfile) = ($1,$2,$3);
110 # error internally to ftp.
111 # hope it doesn't do anything bad.
112 if ($file =~ /Contents-woody-i386-non-US/) {
113 &main::DEBUG("Skipping Contents-woody-i386-non-US.");
114 # $file =~ s/woody/potato/;
115 # $path =~ s/woody/potato/;
119 if (!&main::ftpGet($host,$path,$thisfile,$file)) {
120 &main::DEBUG("deb: down: ftpGet($host,$path,$thisfile,$file) == BAD.");
126 &main::DEBUG("deb: down: ftpGet: !file");
131 if ($file =~ /Contents-potato-i386-non-US/) {
132 &main::DEBUG("hack: using potato's non-US contents for woody.");
133 system("cp debian/Contents-potato-i386-non-US.gz debian/Contents-woody-i386-non-US.gz");
136 &main::DEBUG("deb: download: good.");
140 &main::ERROR("Debian: invalid format of url => ($url).");
147 &generateIndex($dist);
150 return -1 unless ($bad); # no download.
151 &main::DEBUG("DD: !good and bad($bad). :(");
156 ###########################
157 # DEBIAN CONTENTS SEARCH FUNCTIONS.
161 # Usage: &searchContents($query);
163 my ($dist, $query) = &getDistroFromStr($_[0]);
164 &main::status("Debian: Contents search for '$query' on $dist.");
167 $dccsend++ if ($query =~ s/^dcc\s+//i);
169 # $query = $query.'(\.so\.)?([.[[:digit:]]+\.]+)?$';
171 $query =~ s/\\([\^\$])/$1/g; # hrm?
172 $query =~ s/^\s+|\s+$//g;
174 if (!&main::validExec($query)) {
175 &main::msg($main::who, "search string looks fuzzy.");
179 if ($dist eq "incoming") { # nothing yet.
180 &main::DEBUG("sC: dist = 'incoming'. no contents yet.");
183 my %urls = &fixDist($dist, %urlcontents);
184 # download contents file.
185 &main::DEBUG("deb: download 1.");
186 if (!&DebianDownload($dist, %urls)) {
187 &main::WARN("Debian: could not download files.");
192 my $start_time = &main::gettimeofday();
198 ### TODO: search properly if /usr/bin/blah is done.
199 if ($query =~ s/\$$//) {
200 &main::DEBUG("search-regex found.");
201 $grepRE = "$query\[ \t]";
202 } elsif ($query =~ s/^\^//) {
203 &main::DEBUG("front marker regex found.");
207 $grepRE = "$query.*\[ \t]";
210 ### fix up grepRE for "*".
211 $grepRE =~ s/\*/\.\*/g;
214 foreach (keys %urlcontents) {
217 next unless ( -f $_);
221 if (!scalar @files) {
222 &main::ERROR("sC: no files?");
223 &main::msg($main::who, "failed.");
227 my $files = join(' ', @files);
229 &main::status("search regex => '$grepRE'.");
230 open(IN,"zegrep -h '$grepRE' $files |");
232 if (/^\.?\/?(.*?)[\t\s]+(\S+)\n$/) {
233 my ($file,$package) = ("/".$1,$2);
234 if ($query =~ /\//) {
235 next unless ($file =~ /\Q$query\E/);
237 my ($basename) = $file =~ /^.*\/(.*)$/;
238 next unless ($basename =~ /\Q$query\E/);
240 next if ($query !~ /\.\d\.gz/ and $file =~ /\/man\//);
241 next if ($front and $file !~ /^\/\Q$query\E/);
243 $contents{$package}{$file} = 1;
251 ### send results with dcc.
253 if (exists $main::dcc{'SEND'}{$main::who}) {
254 &main::msg($main::who, "DCC already active!");
258 if (!scalar %contents) {
259 &main::msg($main::who,"search returned no results.");
263 my $file = "$main::param{tempDir}/$main::who.txt";
264 if (!open(OUT,">$file")) {
265 &main::ERROR("Debian: cannot write file for dcc send.");
269 foreach $pkg (keys %contents) {
270 foreach (keys %{$contents{$pkg}}) {
271 # TODO: correct padding.
272 print OUT "$_\t\t\t$pkg\n";
277 &main::shmWrite($main::shm, "DCC SEND $main::who $file");
282 &main::status("Debian: $found contents results found.");
285 foreach $pkg (keys %contents) {
286 my @tmplist = &main::fixFileList(keys %{$contents{$pkg}});
287 my @sublist = sort { length $a <=> length $b } @tmplist;
289 pop @sublist while (scalar @sublist > 3);
291 $pkg =~ s/\,/\037\,\037/g; # underline ','.
292 push(@list, "(". join(', ',@sublist) .") in $pkg");
294 # sort the total list from shortest to longest...
295 @list = sort { length $a <=> length $b } @list;
297 # show how long it took.
298 my $delta_time = &main::gettimeofday() - $start_time;
299 &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
301 my $prefix = "Debian Search of '$query' ";
302 if (scalar @list) { # @list.
303 &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
305 &main::DEBUG("ok, !\@list, searching desc for '$query'.");
311 # Usage: &searchAuthor($query);
313 my ($dist, $query) = &getDistroFromStr($_[0]);
314 &main::DEBUG("searchAuthor: dist => '$dist', query => '$query'.");
315 $query =~ s/^\s+|\s+$//g;
318 my $start_time = &main::gettimeofday();
319 &main::status("Debian: starting author search.");
322 my ($bad,$good) = (0,0);
323 my %urls = %urlpackages;
325 foreach (keys %urlpackages) {
337 &main::DEBUG("good = $good, bad = $bad...");
339 if ($good == 0 and $bad != 0) {
340 my %urls = &fixDist($dist, %urlpackages);
341 &main::DEBUG("deb: download 2.");
342 if (!&DebianDownload($dist, %urls)) {
343 &main::ERROR("Debian(sA): could not download files.");
348 my (%maint, %pkg, $package);
349 open(IN,"zegrep -h '^Package|^Maintainer' $files |");
351 if (/^Package: (\S+)$/) {
353 } elsif (/^Maintainer: (.*) \<(\S+)\>$/) {
354 my($name,$email) = ($1,$2);
355 if ($package eq "") {
356 &main::DEBUG("sA: package == NULL.");
359 $maint{$name}{$email} = 1;
360 $pkg{$name}{$package} = 1;
363 &main::WARN("invalid line: '$_'.");
369 # TODO: can we use 'map' here?
370 foreach (grep /\Q$query\E/i, keys %maint) {
374 # TODO: should we only search email if '@' is used?
375 if (scalar keys %hash < 15) {
377 foreach $name (keys %maint) {
379 foreach $email (keys %{$maint{$name}}) {
380 next unless ($email =~ /\Q$query\E/i);
381 next if (exists $hash{$name});
387 my @list = keys %hash;
388 if (scalar @list != 1) {
389 my $prefix = "Debian Author Search of '$query' ";
390 &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
394 &main::DEBUG("showing all packages by '$list[0]'...");
396 my @pkg = sort keys %{$pkg{$list[0]}};
398 # show how long it took.
399 my $delta_time = &main::gettimeofday() - $start_time;
400 &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
402 my $email = join(', ', keys %{$maint{$list[0]}});
403 my $prefix = "Debian Packages by $list[0] \002<\002$email\002>\002 ";
404 &main::performStrictReply( &main::formListReply(0, $prefix, @pkg) );
408 # Usage: &searchDesc($query);
410 my ($dist, $query) = &getDistroFromStr($_[0]);
411 &main::DEBUG("searchDesc: dist => '$dist', query => '$query'.");
412 $query =~ s/^\s+|\s+$//g;
415 my $start_time = &main::gettimeofday();
416 &main::status("Debian: starting desc search.");
419 my ($bad,$good) = (0,0);
420 my %urls = %urlpackages;
422 foreach (keys %urlpackages) {
434 &main::DEBUG("good = $good, bad = $bad...");
436 if ($good == 0 and $bad != 0) {
437 my %urls = &fixDist($dist, %urlpackages);
438 &main::DEBUG("deb: download 2c.");
439 if (!&DebianDownload($dist, %urls)) {
440 &main::ERROR("Debian(sD): could not download files.");
445 my (%desc, $package);
446 open(IN,"zegrep -h '^Package|^Description' $files |");
448 if (/^Package: (\S+)$/) {
450 } elsif (/^Description: (.*)$/) {
452 next unless ($desc =~ /\Q$query\E/i);
453 if ($package eq "") {
454 &main::WARN("sD: package == NULL?");
457 $desc{$package} = $desc;
460 &main::WARN("invalid line: '$_'.");
465 my @list = keys %desc;
467 my $prefix = "Debian Desc Search of '$query' ";
468 &main::performStrictReply( &main::formListReply(0, $prefix, ) );
469 } elsif (scalar @list == 1) { # list = 1.
470 &main::DEBUG("list == 1; showing package info of '$list[0]'.");
471 &infoPackages("info", $list[0]);
473 my $prefix = "Debian Desc Search of '$query' ";
474 &main::performStrictReply( &main::formListReply(0, $prefix, @list) );
477 # show how long it took.
478 my $delta_time = &main::gettimeofday() - $start_time;
479 &main::status(sprintf("Debian: %.02f sec to complete query.", $delta_time)) if ($delta_time > 0);
483 # Usage: &generateIncoming();
484 sub generateIncoming {
485 my $interval = $main::param{'debianRefreshInterval'};
486 my $pkgfile = "debian/Packages-incoming";
487 my $idxfile = $pkgfile.".idx";
489 $stale++ if (&main::isStale($pkgfile.".gz", $interval));
490 $stale++ if (&main::isStale($idxfile, $interval));
491 &main::DEBUG("gI: stale => '$stale'.");
492 return 0 unless ($stale);
495 my %ftp = &main::ftpList("llug.sep.bnl.gov", "/pub/debian/Incoming/");
497 if (!open(PKG,">$pkgfile")) {
498 &main::ERROR("cannot write to pkg $pkgfile.");
501 if (!open(IDX,">$idxfile")) {
502 &main::ERROR("cannot write to idx $idxfile.");
506 print IDX "*$pkgfile.gz\n";
508 foreach $file (sort keys %ftp) {
509 next unless ($file =~ /deb$/);
511 if ($file =~ /^(\S+)\_(\S+)\_(\S+)\.deb$/) {
513 print PKG "Package: $1\n";
514 print PKG "Version: $2\n";
515 print PKG "Architecture: ", (defined $4) ? $4 : "all", "\n";
517 print PKG "Filename: $file\n";
518 print PKG "Size: $ftp{$file}\n";
524 system("gzip -9fv $pkgfile"); # lame fix.
526 &main::status("Debian: generateIncoming() complete.");
530 ##############################
531 # DEBIAN PACKAGE INFO FUNCTIONS.
534 # Usage: &getPackageInfo($query,$file);
536 my ($package, $file) = @_;
539 &main::status("gPI: file $file does not exist?");
546 open(IN, "zcat $file 2>&1 |");
552 next if (/^ \S+/); # package long description.
555 if (/^Package: (.*)\n$/) {
557 if ($pkg =~ /^$package$/i) {
558 $found++; # we can use pkg{'package'} instead.
559 $pkg{'package'} = $pkg;
568 if (/^Version: (.*)$/) {
569 $pkg{'version'} = $1;
570 } elsif (/^Priority: (.*)$/) {
571 $pkg{'priority'} = $1;
572 } elsif (/^Section: (.*)$/) {
573 $pkg{'section'} = $1;
574 } elsif (/^Size: (.*)$/) {
576 } elsif (/^Installed-Size: (.*)$/i) {
577 $pkg{'installed'} = $1;
578 } elsif (/^Description: (.*)$/) {
580 } elsif (/^Filename: (.*)$/) {
582 } elsif (/^Pre-Depends: (.*)$/) {
583 $pkg{'depends'} = "pre-depends on $1";
584 } elsif (/^Depends: (.*)$/) {
585 if (exists $pkg{'depends'}) {
586 $pkg{'depends'} .= "; depends on $1";
588 $pkg{'depends'} = "depends on $1";
590 } elsif (/^Maintainer: (.*)$/) {
592 } elsif (/^Provides: (.*)$/) {
593 $pkg{'provides'} = $1;
594 } elsif (/^Suggests: (.*)$/) {
595 $pkg{'suggests'} = $1;
596 } elsif (/^Conflicts: (.*)$/) {
597 $pkg{'conflicts'} = $1;
600 ### &main::DEBUG("=> '$_'.");
610 next if (defined $pkg);
618 # Usage: &infoPackages($query,$package);
620 my ($query,$dist,$package) = ($_[0], &getDistroFromStr($_[1]));
621 my $interval = $main::param{'debianRefreshInterval'} || 7;
623 &main::status("Debian: Searching for package '$package' in '$dist'.");
625 # download packages file.
627 my %urls = &fixDist($dist, %urlpackages);
628 if ($dist ne "incoming") {
629 &main::DEBUG("deb: download 3.");
630 if (!&DebianDownload($dist, %urls)) { # no good download.
631 &main::WARN("Debian(iP): could not download ANY files.");
635 # check if the package is valid.
637 my @files = &validPackage($package, $dist);
638 if (!scalar @files) {
639 &main::status("Debian: no valid package found; checking incoming.");
640 @files = &validPackage($package, "incoming");
642 &main::status("Debian: cool, it exists in incoming.");
645 &main::msg($main::who, "Package '$package' does not exist.");
650 if (scalar @files > 1) {
651 &main::WARN("same package in more than one file; random.");
652 &main::DEBUG("THIS SHOULD BE FIXED SOMEHOW!!!");
653 $files[0] = &main::getRandom(@files);
656 if (! -f $files[0]) {
657 &main::WARN("files[0] ($files[0]) doesn't exist.");
658 &main::msg($main::who, "WARNING: $files[0] does not exist? FIXME");
662 ### TODO: if specific package is requested, note down that a version
663 ### exists in incoming.
666 my $file = $files[0];
669 ### TODO: use fe, dump to a hash. if only one version of the package
670 ### exists. do as normal otherwise list all versions.
672 &main::ERROR("D:iP: file '$file' DOES NOT EXIST!!! should never happen.");
675 my %pkg = &getPackageInfo($package, $file);
678 if ($query eq "info") {
679 if (scalar keys %pkg > 5) {
680 $pkg{'info'} = "\002(\002". $pkg{'desc'} ."\002)\002";
681 $pkg{'info'} .= ", section ".$pkg{'section'};
682 $pkg{'info'} .= ", is ".$pkg{'priority'};
683 $pkg{'info'} .= ". Version: \002$pkg{'version'}\002";
684 $pkg{'info'} .= ", Packaged size: \002". int($pkg{'size'}/1024) ."\002 kB";
685 $pkg{'info'} .= ", Installed size: \002$pkg{'installed'}\002 kB";
688 &main::status("iP: info requested and pkg is in incoming, too.");
689 my %incpkg = &getPackageInfo($query, "debian/Packages-incoming");
691 if (scalar keys %incpkg) {
692 $pkg{'info'} .= ". Is in incoming ($incpkg{'file'}).";
694 &main::ERROR("iP: pkg $query is in incoming but we couldn't get any info?");
698 &main::DEBUG("running debianCheck() due to problems (".scalar(keys %pkg).").");
700 &main::DEBUG("end of debianCheck()");
702 &main::msg($main::who,"Debian: Package appears to exist but I could not retrieve info about it...");
707 if ($dist eq "incoming") {
708 $pkg{'info'} .= "Version: \002$pkg{'version'}\002";
709 $pkg{'info'} .= ", Packaged size: \002". int($pkg{'size'}/1024) ."\002 kB";
710 $pkg{'info'} .= ", is in incoming!!!";
713 if (!exists $pkg{$query}) {
714 if ($query eq "suggests") {
715 $pkg{$query} = "has no suggestions";
716 } elsif ($query eq "conflicts") {
717 $pkg{$query} = "does not conflict with any other package";
718 } elsif ($query eq "depends") {
719 $pkg{$query} = "does not depend on anything";
720 } elsif ($query eq "maint") {
721 $pkg{$query} = "has no maintainer";
723 $pkg{$query} = "has nothing about $query";
727 &main::performStrictReply("$package: $pkg{$query}");
730 # Usage: &infoStats($dist);
733 $dist = &getDistro($dist);
734 return unless (defined $dist);
736 &main::DEBUG("infoS: dist => '$dist'.");
737 my $interval = $main::param{'debianRefreshInterval'} || 7;
739 # download packages file if needed.
740 my %urls = &fixDist($dist, %urlpackages);
741 &main::DEBUG("deb: download 4.");
742 if (!&DebianDownload($dist, %urls)) {
743 &main::WARN("Debian(iS): could not download ANY files.");
744 &main::msg($main::who, "Debian(iS): internal error.");
751 foreach $file (keys %urlpackages) {
752 $file =~ s/##DIST/$dist/g; # won't work for incoming.
753 &main::DEBUG("file => '$file'.");
754 if (exists $stats{$file}{'count'}) {
755 &main::DEBUG("hrm... duplicate open with $file???");
759 open(IN,"zcat $file 2>&1 |");
762 &main::DEBUG("iS: $file does not exist.");
769 next if (/^ \S+/); # package long description.
771 if (/^Package: (.*)\n$/) { # counter.
772 $stats{$file}{'count'}++;
774 } elsif (/^Maintainer: .* <(\S+)>$/) {
775 $stats{$file}{'maint'}{$1}++;
776 $total{'maint'}{$1}++;
777 } elsif (/^Size: (.*)$/) { # compressed size.
778 $stats{$file}{'csize'} += $1;
779 $total{'csize'} += $1;
780 } elsif (/^i.*size: (.*)$/i) { # installed size.
781 $stats{$file}{'isize'} += $1;
782 $total{'isize'} += $1;
785 ### &main::DEBUG("=> '$_'.");
790 &main::performStrictReply(
791 "Debian Distro Stats on $dist... ".
792 "\002$total{'count'}\002 packages, ".
793 "\002".scalar(keys %{$total{'maint'}})."\002 maintainers, ".
794 "\002". int($total{'isize'}/1024)."\002 MB installed size, ".
795 "\002". int($total{'csize'}/1024/1024)."\002 MB compressed size."
798 ### TODO: do individual stats? if so, we need _another_ arg.
799 # foreach $file (keys %stats) {
800 # foreach (keys %{$stats{$file}}) {
801 # &main::DEBUG(" '$file' '$_' '$stats{$file}{$_}'.");
811 # HELPER FUNCTIONS FOR INFOPACKAGES...
814 # Usage: &generateIndex();
817 &main::status("Debian: !!! generateIndex() called !!!");
818 if (!scalar @dists or $dists[0] eq '') {
819 &main::ERROR("gI: no dists to generate index.");
824 my $dist = &getDistro($_); # incase the alias is returned, possible?
825 my $idx = "debian/Packages-$dist.idx";
827 # TODO: check if any of the Packages file have been updated then
828 # regenerate it, even if it's not stale.
829 # TODO: also, regenerate the index if the packages file is newer
831 next unless (&main::isStale($idx, $main::param{'debianRefreshInterval'}));
833 &main::DEBUG("gIndex: calling generateIncoming()!");
839 &main::DEBUG("Copying old index of woody to -old");
840 system("cp $idx $idx-old");
843 &main::DEBUG("gIndeX: calling DebianDownload($dist, ...).");
844 &DebianDownload($dist, %urlpackages);
846 &main::status("Debian: generating index for '$dist'.");
847 if (!open(OUT,">$idx")) {
848 &main::ERROR("cannot write to $idx.");
853 foreach $packages (keys %urlpackages) {
854 $packages =~ s/##DIST/$dist/;
856 if (! -e $packages) {
857 &main::ERROR("gIndex: '$packages' does not exist?");
861 print OUT "*$packages\n";
862 open(IN,"zcat $packages |");
865 next unless (/^Package: (.*)\n$/);
876 # Usage: &validPackage($package, $dist);
878 my ($package,$dist) = @_;
882 &main::DEBUG("D: validPackage($package, $dist) called.");
885 while (!open(IN, "debian/Packages-$dist.idx")) {
887 &main::ERROR("Packages-$dist.idx does not exist (#1).");
891 &generateIndex($dist);
903 if (/^$package\n$/) {
910 &main::DEBUG("vP: scanned $count items in index.");
916 my ($dist, $query) = &getDistroFromStr($_[0]);
917 my $file = "debian/Packages-$dist.idx";
921 &main::status("Debian: Search package matching '$query' in '$dist'.");
922 unlink $file if ( -z $file);
924 while (!open(IN, $file)) {
925 if ($dist eq "incoming") {
926 &main::DEBUG("sP: dist == incoming; calling gI().");
931 &main::ERROR("could not generate index!!!");
936 &main::DEBUG("should we be doing this?");
937 &generateIndex(($dist));
946 if (&main::isStale($file, $main::param{'debianRefreshInterval'})) {
947 &main::DEBUG("STALE $file! regen.");
948 &generateIndex(($dist));
949 ### @files = searchPackage("$query $dist");
950 &main::DEBUG("EVIL HACK HACK HACK.");
969 if (!defined $dist or $dist eq "") {
970 &main::DEBUG("gD: dist == NULL; dist = defaultdist.");
971 $dist = $defaultdist;
974 if ($dist =~ /^(slink|hamm|rex|bo)$/i) {
975 &main::DEBUG("Debian: deprecated version ($dist).");
976 &main::msg($main::who, "Debian: deprecated distribution version.");
980 if (exists $dists{$dist}) {
981 return $dists{$dist};
983 if (!grep /^\Q$dist\E$/i, %dists) {
984 &main::msg($main::who, "invalid dist '$dist'.");
992 sub getDistroFromStr {
994 my $dists = join '|', %dists;
995 my $dist = $defaultdist;
997 if ($str =~ s/\s+($dists)$//i) {
998 $dist = &getDistro(lc $1);
1001 $str =~ s/\\([\$\^])/$1/g;
1007 my ($dist, %urls) = @_;
1011 while (($key,$val) = each %urls) {
1012 $key =~ s/##DIST/$dist/;
1013 $val =~ s/##DIST/$dist/;
1014 ### TODO: what should we do if the sar wasn't done.
1021 ### H-H-H-HACK HACK HACK :)
1023 my ($dist, $query) = &getDistroFromStr($str);
1024 my @results = sort &searchPackage($str);
1026 if (!scalar @results) {
1027 &main::Forker("debian", sub { &searchContents($str); } );
1028 } elsif (scalar @results == 1) {
1029 &main::status("searchPackage returned one result; getting info of package instead!");
1030 &main::Forker("debian", sub { &infoPackages("info", "$results[0] $dist"); } );
1032 my $prefix = "Debian Package Listing of '$str' ";
1033 &main::performStrictReply( &main::formListReply(0, $prefix, @results) );
1038 my $dir = "debian/";
1041 &main::status("debianCheck() called.");
1043 ### TODO: remove the following loop (check if dir exists before)
1045 last if (opendir(DEBIAN, $dir));
1047 &main::ERROR("dC: cannot opendir debian.");
1056 while (defined($file = readdir DEBIAN)) {
1057 next unless ($file =~ /(gz|bz2)$/);
1059 my $exit = system("gzip -t '$dir/$file'");
1060 next unless ($exit);
1061 &main::DEBUG("hmr... => ".(time() - (stat($file))[8])."'.");
1062 next unless (time() - (stat($file))[8] > 3600);
1064 &main::DEBUG("dC: exit => '$exit'.");
1065 &main::WARN("dC: '$dir/$file' corrupted? deleting!");
1066 unlink $dir."/".$file;