[Dehs-devel] r95 - in trunk: . tpls www
atomo64-guest at alioth.debian.org
atomo64-guest at alioth.debian.org
Wed Jan 23 21:23:42 UTC 2008
Author: atomo64-guest
Date: 2008-01-23 21:23:41 +0000 (Wed, 23 Jan 2008)
New Revision: 95
Modified:
trunk/dehs_pg.php
trunk/tpls/new_version.mail.tpl
trunk/update_wwwal.sh
trunk/www/maintainer.php
trunk/www/no_updated.php
Log:
dehs_pg.php:
Finished new version notifier code: added _recordEvent, _searchEvent
Made the database 'updated' column store true when updated and false when not updated
update_wwwal.sh:
Updated accordingly for the 'updated' change
Added updated_real_count* to stats.txt
www/*
Updated accordingly for the 'updated' change
tpls/new_version.mail.tpl:
Updated the message and destinations
Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php 2008-01-23 20:01:12 UTC (rev 94)
+++ trunk/dehs_pg.php 2008-01-23 21:23:41 UTC (rev 95)
@@ -132,7 +132,7 @@
#if ($res_array['dist']=='non-US') $conn_id = $conn_non_us;
#else
$conn_id = $conn_normal;
- if ($localfile=download_diffs($conn_id,$res_array[name],$res_array[version],$res_array['dir'],$res_array[md5_diff],$res_array[md5_atsource],$res_array[bytes],$res_array[dist])) {
+ if ($localfile=download_diff($conn_id,$res_array[name],$res_array[version],$res_array['dir'],$res_array[md5_diff],$res_array[md5_atsource],$res_array[bytes],$res_array[dist])) {
$watch=ext_watch($localfile,$res_array[name],$res_array[version]);
unlink($localfile);
if ($watch!=NULL) {
@@ -150,7 +150,7 @@
pg_close($db);
return "Fatto\n";
}
-function download_diffs(&$conn_id,$pkg,$version,$directory,$md5_diff,$md5_atsource,$diff_kb,$dist) {
+function download_diff(&$conn_id,$pkg,$version,$directory,$md5_diff,$md5_atsource,$diff_kb,$dist) {
global $dirs,$mirrors;
$localfile=$dirs[diffs_dir] . "/$pkg" . "_" . "$version.diff.gz";
#if ($dist=="non-US") $remotefile="/debian-non-US/$directory/$pkg" . "_" . "$version.diff.gz";
@@ -207,7 +207,7 @@
$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,dversionmangled,maint,dir,md5_atsource,bytes,dist,section,uploaders) VALUES ('$matches[1]','$matches[4]','$matches[4]','$matches[5]','$matches[6]','$matches[7]','$matches[8]','$dist','$section','$matches[10]')") ;
+ $rst=@pg_exec($db, "INSERT INTO pkgs (name,version,dversionmangled,maint,dir,md5_atsource,bytes,dist,section,uploaders) VALUES ('$matches[1]','$matches[4]','$matches[4]','$matches[5]','$matches[6]','$matches[7]','$matches[8]','$dist','$section','$matches[10]')");
if (!$rst) {
$rsql=pg_exec($db, "SELECT pkgs.version FROM pkgs WHERE name='$matches[1]' AND dist='$dist';");
$version = $matches[4]; // just for safety
@@ -339,21 +339,23 @@
function check_db() {
global $dirs,$dbconn;
$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, dversionmangled 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');
+ if (!pg_table_exists($db, "pkgs")) {
+ pg_exec($db, "CREATE TABLE pkgs (id serial PRIMARY KEY,name text,version text, dversionmangled 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, lastcheck timestamp, homepage text, vcs_browser text, lastupvsdebsync timestamp)") 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));
+ pg_exec($db, "CREATE INDEX checkx on pkgs (lastcheck)") or die_status('Errore creating index - ' . pg_last_error($db));
$sw=true;
}
- if (!pg_table_exists($db,"binpkgs")){
+ if (!pg_table_exists($db, "binpkgs")) {
pg_exec($db, "CREATE TABLE binpkgs (id serial PRIMARY KEY, name text,bin_name text,dist text, pop_inst numeric,pop_vote numeric, up_error numeric,avg_error_date numeric)") or die_status('Error creating table binpkgs\n');
pg_exec($db, "CREATE UNIQUE INDEX idxbin on binpkgs (name,bin_name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
$sw=true;
}
- /*if (!pg_table_exists($db,"events")){
- pg_exec($db, "CREATE TABLE events (id serial PRIMARY KEY, name text,type text, dist text)") or die_status('Error creating table binpkgs\n');
+ if (!pg_table_exists($db, "events")) {
+ pg_exec($db, "CREATE TABLE events (id serial PRIMARY KEY, name text,type text, dist text, stamp timestamp, content text)") or die_status('Error creating table binpkgs\n');
pg_exec($db, "CREATE UNIQUE INDEX idxevents on events (name,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
+ pg_exec($db, "CREATE INDEX pkgxeventtype on events (name,type,dist)") or die_status('Errore creating index - ' . pg_last_error($db));
$sw=true;
- }*/
+ }
#if (!pg_table_exists($db,"upstream")){
# pg_exec($db, "CREATE TABLE upstream (name text,dist text,up_version text,watch_warn text,updated bool)") or die_status('Errore nel creare la tabella');
# pg_exec($db, "CREATE UNIQUE INDEX idxupstrm on upstream (name,dist)") or die_status('Errore nel creare gli indici ' . pg_last_error($db));
@@ -445,43 +447,54 @@
@file_put_contents($localfile,file_get_contents($remotefile),'w') or die_status("Errore nello scaricare il file popcon\n");
}
function is_updated ($up_vers,$debian_vers) {
- if ($up_vers=='') return 0;
+ if ($up_vers=='') return true;
passthru("dpkg --compare-versions '".escapeshellarg($up_vers)."' le '" . escapeshellarg(vers_conv($debian_vers)) . "'",$great);
- if ($great!=0) return 1;
- else return 0;
+ return !($great);
}
function db_upstream($initial='%') {
global $dirs,$dbconn;
check_db();
$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");
+ events::DB($db);
+ $rsql=pg_exec($db, "SELECT id, name,dist,up_version,version,watch,lastupvsdebsync 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)) {
+
$uscan_res=uscan_foo($res_array['name'],$res_array['version'],$res_array['watch']);
+
#print $uscan_res[0] . "\n Name => $res_array[name]\n";
- $version=$res_array[version];
- $dversionmangled=$res_array['version'];
+ $version = $res_array['version'];
+ $dversionmangled = $res_array['version'];
+ $lastupvsdebsync = $res_array['lastupvsdebsync'];
+
print "\rVersion=>" . $uscan_res[3];
if ($uscan_res[3]!=null) $version=$uscan_res[3];
if ($uscan_res[5]!=null && $uscan_res[5] != vers_conv($res_array['version'])) $dversionmangled=$uscan_res[5];
- $updated=$uscan_res[4];
- if ($updated) {
- $updated=is_updated($uscan_res[0],$dversionmangled);
+
+ $updated = $uscan_res[4];
+
+ /*if (!$updated)*/ {
+ $updated=is_updated($uscan_res[0], $dversionmangled);
}
if (!$updated) {
events::newVersion($res_array['name'], $res_array['version'], $uscan_res[0], $res_array['dist']);
+ } else {
+ $lastupvsdebsync = sqldate();
}
if ($uscan_res[0]!=$res_array[up_version]) ($keep_changes=1);
else $keep_changes=0;
+
$up_url=iconv("ISO-8859-1","UTF-8",$uscan_res[2]);
$up_version=iconv("ISO-8859-1","UTF-8",$uscan_res[0]);
+
$watch_warn='';
if($uscan_res[1] != null) {
- $watch_warn=pg_escape_string(iconv("ISO-8859-1","UTF-8",$uscan_res[1]));
+ $watch_warn=pg_escape_string(iconv("ISO-8859-1","UTF-8", $uscan_res[1]));
}
- pg_exec($db, "UPDATE pkgs SET up_version='" . pg_escape_string($up_version) . "', dversionmangled='".pg_escape_string($dversionmangled)."',up_url='" . pg_escape_string($up_url) . "', watch_warn='" . $watch_warn . "',keep_changes='$keep_changes', wwiz_version=NULL, wwiz_type=NULL, wwiz=NULL, updated='$updated' WHERE id=$res_array[id]") or die_status("Error in update pkgs upstream");
+
+ pg_exec($db, "UPDATE pkgs SET up_version='" . pg_escape_string($up_version) . "', dversionmangled='".pg_escape_string($dversionmangled)."',up_url='" . pg_escape_string($up_url) . "', watch_warn='" . $watch_warn . "',keep_changes='$keep_changes', wwiz_version=NULL, wwiz_type=NULL, wwiz=NULL, updated='$updated', lastcheck=now(), lastupvsdebsync='$lastupvsdebsync' WHERE id=$res_array[id]") or die_status("Error in update pkgs upstream");
#print "\rUpdated " . $res_array['name'] . " => $updated Up Version => ". $uscan_res[0];
print "\t Upstream left => " . $tot --;
# }
@@ -538,7 +551,7 @@
global $dbconn, $fetchUpstreamChanges;
if (!$fetchUpstreamChanges && !$force) {
- print "\nSkipping download of upstream sources to grab changelogs\n";
+ //print "\nSkipping download of upstream sources to grab changelogs\n";
return;
}
@@ -609,8 +622,8 @@
$warnings=$vals[$index['WARNINGS'][0]][value];
$updated=$vals[$index['STATUS'][0]][value];
- if ($updated=="up to date") $updated=0;
- else $updated=1;
+ if ($updated=="up to date") $updated=1;
+ else $updated=0;
if ($upstream=='') $upstream=null;
if ($up_url=='') $up_url=null;
@@ -816,16 +829,16 @@
$dversionmangled = $res_array[version];
if ($uscan_res[5]!=null && $uscan_res[5] != vers_conv($res_array['version'])) $dversionmangled=$uscan_res[5];
- $updated=$uscan_res[4];
- if ($updated) {
- $updated=is_updated($uscan_res[0],$dversionmangled);
+ $updated = $uscan_res[4];
+ /*if ($updated)*/ {
+ $updated = is_updated($uscan_res[0], $dversionmangled);
}
/*if (!$updated) {
events::newVersion($res_array['name'], $res_array['version'], $uscan_res[0], $res_array['dist']);
}*/
- pg_exec($db, "UPDATE pkgs SET wwiz='" . pg_escape_string($watch) ."', wwiz_type='watch', wwiz_version='" . pg_escape_string($uscan_res[0]) . "',dversionmangled='".pg_escape_string($dversionmangled)."', up_url='" . pg_escape_string($uscan_res[2]) . "', keep_changes='$keep_changes', updated='$updated' where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
+ pg_exec($db, "UPDATE pkgs SET wwiz='" . pg_escape_string($watch) ."', wwiz_type='watch', wwiz_version='" . pg_escape_string($uscan_res[0]) . "',dversionmangled='".pg_escape_string($dversionmangled)."', up_url='" . pg_escape_string($uscan_res[2]) . "', keep_changes='$keep_changes', updated='$updated', lastcheck=now() where name='" . pg_escape_string($res_array[name]) . "' AND dist='" . $res_array[dist] ."'");
}
}
} else {
@@ -983,6 +996,17 @@
class events
{
+
+ function DB($db = null)
+ {
+ static $_db;
+
+ if ($db === null) {
+ return $_db;
+ }
+ $_db = $db;
+ }
+
function newVersion($sourcePackage, $currentVersion, $newVersion, $distribution, $downloadLink = '')
{
global $base, $sendNotifications;
@@ -991,6 +1015,13 @@
return null;
}
+ $eventsId = events::_searchEvent(__FUNCTION__, $sourcePackage, $newVersion);
+
+ if (empty($eventsId)) {
+ echo "Skipping ".__FUNCTION__." event for v$newVersion of $sourcePackage; already sent";
+ return null;
+ }
+
$tpl = file_get_contents($base . '/tpls/new_version.mail.tpl');
$search = array();
@@ -1004,15 +1035,22 @@
$replace[] = $newVersion;
$search [] = '#DISTRO#';
$replace[] = $distribution;
+ $search [] = '#LINK#';
+ $replace[] = $downloadLink;
$message = str_replace($search, $replace, $tpl);
$subject = events::_extractHeader('subject', $message);
$to = events::_extractHeader('to', $message);
+ $bcc = events::_extractHeader('bcc', $message);
- $extraHeaders = events::_getTefaultExtraHeaders();
+ $extraHeaders = events::_getDefaultExtraHeaders();
$extraHeaders[] = 'X-DEHS-UVERSION: ' . $newVersion;
+ $extraHeaders[] = 'BCC: ' . $bcc;
- return mail($to, $subject, $message, implode("\r\n", $extraHeaders));
+ if (!mail($to, $subject, $message, implode("\r\n", $extraHeaders)))
+ return false;
+
+ events::_recordEvent(__FUNCTION__, $sourcePackage, $distribution, $newVersion);
}
function _extractHeader($header, &$message)
@@ -1034,7 +1072,7 @@
return false;
}
- function _getTefaultExtraHeaders()
+ function _getDefaultExtraHeaders()
{
global $notificationsMailFrom;
$headers = array();
@@ -1046,6 +1084,34 @@
return $headers;
}
+ function _recordEvent($eventType, $packageName, $distribution, $content)
+ {
+ $db = events::DB();
+
+ $eventType = pg_escape_string($eventType);
+ $packageName = pg_escape_string($packageName);
+ $distribution = pg_escape_string($distribution);
+ $content = pg_escape_string($content);
+
+ pg_exec($db, "INSERT INTO events (name,type,dist,content,stamp) VALUES ('$packageName','$eventType','$distribution','$content',now())") OR die_status("Failed to record event: $packageName|$eventType|$distribution|$content");
+ }
+
+ function _searchEvent($eventType, $packageName, $contentSearch, $distribution = '')
+ {
+ $db = events::DB();
+
+ $eventType = pg_escape_string($eventType);
+ $packageName = pg_escape_string($packageName);
+
+ $result = pg_exec($db, "SELECT id FROM events WHERE name='$packageName' and type='$eventType' ".($distribution? "and dist='$distribution'":'')." and content LIKE '$contentSearch'");
+ return pg_fetch_all($result);
+ }
+
}
+function sqldate($timestamp=null) {
+ if ($timestamp===null) $timestamp=time();
+ return gmdate("Y-m-d H:i:s", $timestamp);
+}
+
?>
\ No newline at end of file
Modified: trunk/tpls/new_version.mail.tpl
===================================================================
--- trunk/tpls/new_version.mail.tpl 2008-01-23 20:01:12 UTC (rev 94)
+++ trunk/tpls/new_version.mail.tpl 2008-01-23 21:23:41 UTC (rev 95)
@@ -1,9 +1,10 @@
Subject: #PACKAGE#: New upstream version available
-To: #PACKAGE#_newversion at packages.qa.debian.org
+To: #PACKAGE#@packages.qa.debian.org
+Bcc: #PACKAGE#_summary at packages.qa.debian.org, atomo64+debian at gmail.com
Hello,
The Debian External Health System (a.k.a. DEHS) has found a new upstream version
- of your package #PACKAGE# in the #DISTRO# distribution.
+ of the package #PACKAGE# in the #DISTRO# distribution.
The current package version is #DVERSION# and latest by upstream is #UVERSION#.
If you are the maintainer or a co-maintainer of the package
Modified: trunk/update_wwwal.sh
===================================================================
--- trunk/update_wwwal.sh 2008-01-23 20:01:12 UTC (rev 94)
+++ trunk/update_wwwal.sh 2008-01-23 21:23:41 UTC (rev 95)
@@ -43,16 +43,22 @@
echo -n 'wwiz_count_experimental:' >> $STATS.new
psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE wwiz_type='watch' AND dist='experimental';" | egrep -v '[^0-9]' >> $STATS.new
echo -n 'updated_count:' >> $STATS.new
-psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f';" | egrep -v '[^0-9]' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1';" | egrep -v '[^0-9]' >> $STATS.new
echo -n 'updated_count_unstable:' >> $STATS.new
-psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f' AND dist='unstable';" | egrep -v '[^0-9]' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1' AND dist='unstable';" | egrep -v '[^0-9]' >> $STATS.new
echo -n 'updated_count_experimental:' >> $STATS.new
-psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f' AND dist='experimental';" | egrep -v '[^0-9]' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1' AND dist='experimental';" | egrep -v '[^0-9]' >> $STATS.new
+echo -n 'updated_real_count:' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1' AND version!='';" | egrep -v '[^0-9]' >> $STATS.new
+echo -n 'updated_real_count_unstable:' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1' AND version!='' AND dist='unstable';" | egrep -v '[^0-9]' >> $STATS.new
+echo -n 'updated_real_count_experimental:' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1' AND version!='' AND dist='experimental';" | egrep -v '[^0-9]' >> $STATS.new
echo -n 'updated_wwiz_count:' >> $STATS.new
-psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f' AND wwiz_type='watch';" | egrep -v '[^0-9]' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1' AND wwiz_type='watch';" | egrep -v '[^0-9]' >> $STATS.new
echo -n 'updated_wwiz_count_unstable:' >> $STATS.new
-psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f' AND dist='unstable' AND wwiz_type='watch';" | egrep -v '[^0-9]' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1' AND dist='unstable' AND wwiz_type='watch';" | egrep -v '[^0-9]' >> $STATS.new
echo -n 'updated_wwiz_count_experimental:' >> $STATS.new
-psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='f' AND dist='experimental' AND wwiz_type='watch';" | egrep -v '[^0-9]' >> $STATS.new
+psql -A -q -d dehs -c "SELECT COUNT(id) FROM pkgs WHERE updated='1' AND dist='experimental' AND wwiz_type='watch';" | egrep -v '[^0-9]' >> $STATS.new
mv $STATS.new $STATS
php4 -q $WORKDIR/www/stats.html > /org/alioth.debian.org/chroot/home/groups/dehs/htdocs/stats.html "$STATS"
Modified: trunk/www/maintainer.php
===================================================================
--- trunk/www/maintainer.php 2008-01-23 20:01:12 UTC (rev 94)
+++ trunk/www/maintainer.php 2008-01-23 21:23:41 UTC (rev 95)
@@ -62,10 +62,10 @@
as binpkgs using(name,dist) where up_version='' AND watch!='' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' order by mpop_inst desc;",
no_updated=>"Select id,mpop_inst,name,section,version,tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,up_url,dversionmangled from pkgs
INNER join (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
-where updated='1' AND up_version!='' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name'
+where updated='0' AND up_version!='' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name'
order by mpop_inst desc;",ok=>"Select id,mpop_inst,name,section,version,tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,up_url,dversionmangled from pkgs
INNER join (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
-where updated='0' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' AND (up_version != '' AND up_version IS NOT NULL)
+where updated='1' AND (maint LIKE '$maint' OR uploaders LIKE '%$maint%') AND name LIKE '$name' AND (up_version != '' AND up_version IS NOT NULL)
order by mpop_inst desc;");
foreach($sql as $key => $value) {
$rs=pg_exec($db,$value) OR Die("Error on query");
Modified: trunk/www/no_updated.php
===================================================================
--- trunk/www/no_updated.php 2008-01-23 20:01:12 UTC (rev 94)
+++ trunk/www/no_updated.php 2008-01-23 21:23:41 UTC (rev 95)
@@ -35,7 +35,7 @@
$rsql=pg_exec($db,
"Select id,mpop_inst,name,version,bytes, tot_up_error,tot_avg_error_date,pkgs.dist,up_version,watch_warn, up_changes,dversionmangled from pkgs
INNER join (Select max(pop_inst) as mpop_inst,SUM(up_error) as tot_up_error,AVG(avg_error_date) as tot_avg_error_date,name,dist FROM binpkgs GROUP BY name,dist) as binpkgs using(name,dist)
-where updated='1' AND up_version!=''
+where updated='0' AND up_version!=''
order by mpop_inst desc;") OR Die("Error on query");;
$rsql2=pg_exec($db, "SELECT count(name) from pkgs WHERE up_version IS NOT NULL") OR Die("Errore on query");
$totnowatch=pg_numrows($rsql);
More information about the Dehs-devel
mailing list