[Dehs-devel] r64 - trunk
atomo64-guest at alioth.debian.org
atomo64-guest at alioth.debian.org
Sat Dec 8 23:42:12 UTC 2007
Author: atomo64-guest
Date: 2007-12-08 23:42:12 +0000 (Sat, 08 Dec 2007)
New Revision: 64
Modified:
trunk/dehs.config.inc
trunk/dehs_pg.php
Log:
All db connections are persistent now
Added update_new command which is a 'minimal' run
Maintainer field is now also converted to utf-8
Modified: trunk/dehs.config.inc
===================================================================
--- trunk/dehs.config.inc 2007-12-07 00:50:00 UTC (rev 63)
+++ trunk/dehs.config.inc 2007-12-08 23:42:12 UTC (rev 64)
@@ -12,11 +12,15 @@
"unstable"=>"merkel.debian.org",
"experimental"=>"merkel.debian.org",
);
-$email="bluefuture at email.it,filippo at esaurito.net,atomo64 at gmail.com";
+//list of addresses wishing to receive ALL the emails (even minor/less important reports)
+$email_all='atomo64 at gmail.com';
+//list of addresses wishing to be notified when update_all runs
+$email="bluefuture at email.it,filippo at esaurito.net,$email_all";
$uscan=$base.'/uscan.pl';
$sfIgnore = array('dl','download','prdownload','downloads','lists','cvs','svn','www');
$watchFileExts = array('tar.*', 'tgz', 'zip', 'gz', 'bz2');
/*1: watch url, 2: $space, 3: name, 4: file ext, 5: extra options*/
$watchFormat = 'version=3' . "\n" . '%5$s' . "\n" . '%1$s%2$s%3$s-?_?([\d+\.]+|\d+)\.%4$s debian uupdate';
$fetchUpstreamChanges = false;
+$_SERVER['SERVER_NAME']=shell_exec("hostname -f 2>&1");
?>
\ No newline at end of file
Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php 2007-12-07 00:50:00 UTC (rev 63)
+++ trunk/dehs_pg.php 2007-12-08 23:42:12 UTC (rev 64)
@@ -4,6 +4,7 @@
Originally written by Stefano Fabri <bluefuture at nospam@email.it>
Copyright 2004, Stefano Fabri
+Copyright 2007 by Raphael Geissert <atomo64 at gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -57,14 +58,15 @@
}
}
-if (in_array("-db_add",$argv)) db_add($argv[2]);
+if (in_array("-db_add",$argv)) db_add($argv[2], false);
elseif (in_array("-db_query",$argv)) db_query($argv[2],$argv[3] );
elseif (in_array("-dl_diffs",$argv) || in_array("-keep_diff",$argv)) dl_diffs($argv[2]);
- elseif (in_array("-keep_sources",$argv)) keep_sources();
+ elseif (in_array("-keep_sources",$argv) || in_array("-download_sources",$argv)) download_sources();
elseif (in_array("-db_popcon",$argv)) db_popcon($argv[2]);
elseif (in_array("-dl_popcon",$argv) || in_array("-keep_popcon",$argv)) dl_popcon($argv[2]);
elseif (in_array("-db_upstream",$argv)) db_upstream($argv[2]);
elseif (in_array("-update_all",$argv)) update_all();
+ elseif (in_array("-update_new",$argv)) update_new();
elseif (in_array("-check_db",$argv)) check_db();
elseif (in_array("-dehsqa_db",$argv)) dehsqa_db();
elseif (in_array("-clear_db",$argv)) clear_db();
@@ -165,12 +167,12 @@
print "Download Diff.gz of package $pkg => Fallito\n";
return false;
}
-function db_add($initial='') {
+function db_add($initial='', $clear_db = true) {
global $dirs,$dists,$dbconn;
check_db();
- keep_source();
+ download_sources();
- $db = pg_connect($dbconn) or die_status(pg_errormessage($db));
+ $db = pg_pconnect($dbconn) or die_status(pg_errormessage($db));
pg_exec($db, "CREATE TEMP TABLE pkgs_atsrc (name text,dist text)") or die_status('Error creating temp table pkgs_atsrc');
pg_exec($db, "CREATE UNIQUE INDEX idxdis on pkgs_atsrc (name,dist)") or die_status('Error creating index on temp table');
pg_exec($db, "CREATE TEMP TABLE bin_atsrc (name text,bin_name text, dist text)") or die_status('Error creating temp table pkgs_atsrc');
@@ -195,9 +197,13 @@
$buff1 .= $line;
}
if (preg_match($regexp,$buff1,$matches)) {
+ if ($matches[5]) {
+ $matches[5]=iconv("ISO-8859-1","UTF-8",$matches[5]);
+ $matches[5]=pg_escape_string($matches[5]);
+ }
if ($matches[10]) {
$matches[10]=iconv("ISO-8859-1","UTF-8",$matches[10]);
- $matches[10]=addslashes($matches[10]);
+ $matches[10]=pg_escape_string($matches[10]);
}
@pg_exec($db,"INSERT INTO pkgs_atsrc (name,dist) VALUES ('$matches[1]','$dist')") OR die_status("Temp table pkgs_atsrc query error");
$rst=@pg_exec($db, "INSERT INTO pkgs (name,version,maint,dir,md5_atsource,bytes,dist,section,uploaders) VALUES ('$matches[1]','$matches[4]','$matches[5]','$matches[6]','$matches[7]','$matches[8]','$dist','$section','$matches[10]')") ;
@@ -223,6 +229,7 @@
gzclose($zp) ;
}
}
+ if (!$clear_db)
clear_db($db);
pg_close($db);
}
@@ -266,7 +273,7 @@
$res_array=pg_fetch_array($rsql);
return $res_array[totbytes] ;
}
-function keep_source () {
+function download_sources () {
global $dirs,$dists,$mirrors;
foreach ($dists as $dist=>$sections) {
$server=$mirrors[$dist];
@@ -321,7 +328,7 @@
}
function check_db() {
global $dirs,$dbconn;
- $db = pg_connect($dbconn) or die_status(1/*pg_last_notice($db)*/);
+ $db = pg_pconnect($dbconn) or die_status(1/*pg_last_notice($db)*/);
if (!pg_table_exists($db,"pkgs")){
pg_exec($db, "CREATE TABLE pkgs (id serial PRIMARY KEY,name text,version text,maint text, uploaders text, dir text,watch text,md5_diff text,md5_atsource text,bytes numeric,dist text,section text,up_version text,up_changes text, up_url text,watch_warn text,updated bool, keep_changes bool, wwiz text,wwiz_version text, wwiz_type text)") or die_status('Error creating table pkgs\n');
pg_exec($db, "CREATE UNIQUE INDEX idxname on pkgs (name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
@@ -371,7 +378,7 @@
function clear_db(&$db) {
#global $dbconn;
#if (check_db()) die_status("Il Database era vuoto\n");
- #keep_source();
+ #download_sources();
#$db = pg_pconnect($dbconn) or die_status(pg_result_error($db));
$sql1= "Delete from binpkgs where id NOT IN
(select id FROM binpkgs INNER JOIN bin_atsrc USING (name,bin_name,dist))" ;
@@ -444,7 +451,7 @@
function db_upstream($initial='%') {
global $dirs,$dbconn;
check_db();
- $db = pg_connect($dbconn) ;
+ $db = pg_pconnect($dbconn) ;
$rsql=pg_exec($db, "SELECT id, pkgs.name,pkgs.dist,up_version,version,watch FROM pkgs WHERE watch is not null AND name LIKE '$initial%' ORDER BY name DESC");
$tot=pg_numrows($rsql);
while ($res_array=pg_fetch_array($rsql)) {
@@ -601,7 +608,7 @@
function db_up_error() {
global $dbconn;
check_db();
- $db = pg_connect($dbconn) ;
+ $db = pg_pconnect($dbconn) ;
$bugurl="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=tag&data=upstream&archive=no&show_list_header=no&pend-exc=done";
print "\nDownloading bugs list =>";
$ferrors=file_get_contents($bugurl) or die_status ("I can't keep error page from bugs.debian.org");
@@ -838,6 +845,37 @@
"Reply-To: dehs-noreply@{$_SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" . phpversion());
}
+function update_new() {
+ global $email_all;
+ $intime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2);
+ db_add('',false);
+ dl_popcon();
+ db_popcon();
+
+ global $dbconn;
+ check_db();
+ $db = pg_pconnect($dbconn);
+ $sql="SELECT name FROM pkgs WHERE (md5_diff!=md5_atsource or md5_diff is null)";
+ $rsql=pg_exec($db, $sql);
+ $res_array=pg_fetch_all($rsql);
+ pg_close($db);
+
+ dl_diffs();
+ db_up_error();
+ if ($res_array !== false) {
+ foreach ($res_array as $entry) {
+ db_upstream($entry['name']);
+ up_changes($entry['name']);
+ }
+ dehsqa_db();
+ }
+ $endtime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2);
+ $messaggio="Dehs executed successful\nBegin: $intime\nPackages processed: ".((!is_array($res_array))?'none':count($res_array))."\nEnd: $endtime";
+ mail($email_all, "DEHS update_new report", $messaggio,
+ "From: dehs-noreply@{$_SERVER['SERVER_NAME']}\r\n" .
+ "Reply-To: dehs-noreply@{$_SERVER['SERVER_NAME']}\r\n" .
+ "X-Mailer: PHP/" . phpversion());
+}
function die_status($msg = '', $status = 1) {
if (empty($msg)) {
die($status);
More information about the Dehs-devel
mailing list