}
&::DEBUG("deb: gIndex: calling DebianDownload($dist, ...).");
- &DebianDownload($dist, %urlpackages);
+ &DebianDownload($dist, &fixDist($dist, %urlpackages) );
&::status("Debian: generating index for '$dist'.");
if (!open(OUT,">$idx")) {
if (&IsParam("useStrict")) { use strict; }
+#####
+# &openDB($dbname, $sqluser, $sqlpass, $nofail);
sub openDB {
- my ($db, $user, $pass) = @_;
- my $dsn = "DBI:mysql:$db:$param{'SQLHost'}";
+ my ($db, $user, $pass, $no_fail) = @_;
+ my $dsn = "DBI:mysql:$db";
+ my $hoststr = "";
+ if (exists $param{'SQLHost'} and $param{'SQLHost'}) {
+ $dsn .= ":$param{SQLHost}";
+ $hoststr = " to $param{'SQLHost'}";
+ }
$dbh = DBI->connect($dsn, $user, $pass);
if ($dbh) {
- &status("Opened MySQL connection to $param{'SQLHost'}");
+ &status("Opened MySQL connection$hoststr");
} else {
- &ERROR("cannot connect to $param{'SQLHost'}.");
+ &ERROR("cannot connect$hoststr.");
&ERROR("since mysql is not available, shutting down bot!");
&closePID();
&closeSHM($shm);
&closeLog();
+ return if ($no_fail);
+
exit 1;
}
}
sub closeDB {
return 0 unless ($dbh);
- &status("Closed MySQL connection to $param{'SQLHost'}.");
+ my $hoststr = "";
+ $hoststr = " to $param{'SQLHost'}" if (exists $param{'SQLHost'});
+
+ &status("Closed MySQL connection$hoststr.");
$dbh->disconnect();
return 1;
if (&IsParam("useStrict")) { use strict; }
+#####
+# openDB($dbname, $sqluser, $sqlpass, $nofail);
sub openDB {
- my $connectstr="dbi:Pg:dbname=$param{DBName};";
- $connectstr.=";host=$param{SQLHost}" if(defined $param{'SQLHost'});
- $dbh = DBI->connect($connectstr, $param{'SQLUser'}, $param{'SQLPass'});
+ my($dbname, $sqluser, $sqlpass, $nofail) = @_;
+ my $connectstr = "dbi:Pg:dbname=$dbname;";
+ my $hoststr = "";
+ if (exists $param{'SQLHost'} and $param{'SQLHost'}) {
+ $hoststr = " to $param{'SQLHost'}";
+ $connectstr .= ";host=$param{SQLHost}";
+ }
+ $dbh = DBI->connect($connectstr, $sqluser, $sqlpass);
- if (!$dbh->err) {
- &status("Opened pgSQL connection".
- (exists $param{'SQLHost'} ? " to ".$param{'SQLHost'} : ""));
+ if ($dbh and !$dbh->err) {
+ &status("Opened pgSQL connection$hoststr");
} else {
- &ERROR("cannot connect to $param{'SQLHost'}.");
- &ERROR("pgSQL: ".$dbh->errstr);
+ &ERROR("cannot connect$hoststr.");
+ &ERROR("pgSQL: ".$dbh->errstr) if ($dbh);
&closePID();
&closeSHM($shm);
&closeLog();
+ return 0 if ($nofail);
+
exit 1;
}
}