[Dehs-devel] r65 - trunk
atomo64-guest at alioth.debian.org
atomo64-guest at alioth.debian.org
Sun Dec 9 01:31:36 UTC 2007
Author: atomo64-guest
Date: 2007-12-09 01:31:36 +0000 (Sun, 09 Dec 2007)
New Revision: 65
Modified:
trunk/dehs.sh
trunk/dehs_pg.php
Log:
dehs.sh: support different kind of update runs (all, new, bogus)
dehs_pg.php: added the necessary code for the above change
replaced all pg_errormessage calls with pg_last_error
Modified: trunk/dehs.sh
===================================================================
--- trunk/dehs.sh 2007-12-08 23:42:12 UTC (rev 64)
+++ trunk/dehs.sh 2007-12-09 01:31:36 UTC (rev 65)
@@ -19,6 +19,22 @@
echo $$ > $LOCK
+run_type="-update_all"
+
+if [ ! -z "$2" ]; then
+ case $2 in
+ all)
+ run_type="-update_all"
+ ;;
+ new)
+ run_type="-update_new"
+ ;;
+ bogus)
+ run_type="-update_bogus"
+ ;;
+ esac
+fi
+
#(cd /tmp/; svn export svn://svn/devscripts/trunk/scripts/uscan.pl && mv uscan.pl $WORKDIR/) || true
cd /tmp/
if svn export svn://svn/devscripts/trunk/scripts/uscan.pl 1>/dev/null; then
@@ -29,7 +45,7 @@
rm -f uscan.pl
fi
-$WORKDIR/dehs_pg.php -update_all 2>$WORKDIR/logs/stderr.log 1>$WORKDIR/logs/stdout.log
+$WORKDIR/dehs_pg.php $run_type 2>$WORKDIR/logs/stderr.log 1>$WORKDIR/logs/stdout.log
$WORKDIR/update_wwwal.sh &>/dev/null
rm /tmp/dehs.lock
Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php 2007-12-08 23:42:12 UTC (rev 64)
+++ trunk/dehs_pg.php 2007-12-09 01:31:36 UTC (rev 65)
@@ -58,7 +58,7 @@
}
}
-if (in_array("-db_add",$argv)) db_add($argv[2], false);
+if (in_array("-db_add",$argv)) db_add((isset($argv[2])?$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) || in_array("-download_sources",$argv)) download_sources();
@@ -67,6 +67,7 @@
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("-update_bogus",$argv)) update_bogus();
elseif (in_array("-check_db",$argv)) check_db();
elseif (in_array("-dehsqa_db",$argv)) dehsqa_db();
elseif (in_array("-clear_db",$argv)) clear_db();
@@ -172,7 +173,7 @@
check_db();
download_sources();
- $db = pg_pconnect($dbconn) or die_status(pg_errormessage($db));
+ $db = pg_pconnect($dbconn) or die_status(pg_last_error($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');
@@ -208,7 +209,7 @@
@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]')") ;
if (!$rst) {
- $rst=@pg_exec($db, "UPDATE pkgs SET name='$matches[1]',version='$matches[4]',maint='$matches[5]',dir='$matches[6]',md5_atsource='$matches[7]',bytes='$matches[8]',dist='$dist',section='$section',uploaders='$matches[10]' WHERE name='$matches[1]' AND dist='$dist'") OR die_status("\nDb adding error =>" . pg_errormessage() . "\n");
+ $rst=@pg_exec($db, "UPDATE pkgs SET name='$matches[1]',version='$matches[4]',maint='$matches[5]',dir='$matches[6]',md5_atsource='$matches[7]',bytes='$matches[8]',dist='$dist',section='$section',uploaders='$matches[10]' WHERE name='$matches[1]' AND dist='$dist'") OR die_status("\nDb adding error =>" . pg_last_error() . "\n");
}
$bin_names=split(",", $matches[2]);
foreach ($bin_names as $bin_name) {
@@ -229,13 +230,13 @@
gzclose($zp) ;
}
}
- if (!$clear_db)
+ if ($clear_db)
clear_db($db);
pg_close($db);
}
function db_query($pkg,$dist) {
global $dirs,$dbconn;
- $db = pg_pconnect($dbconn ) or die_status(pg_errormessage($db));
+ $db = pg_pconnect($dbconn ) or die_status(pg_last_error($db));
$rsql=pg_exec($db, "SELECT pkgs.* ,mpop_inst FROM (SELECT name,MAX(binpkgs.pop_inst) AS mpop_inst FROM binpkgs GROUP BY name)
AS binpkgs INNER JOIN pkgs ON pkgs.name=binpkgs.name
WHERE pkgs.name='$pkg' AND dist='$dist';");
@@ -360,7 +361,7 @@
function watch_stat() {
global $dirs,$dbconn;
- $db = pg_pconnect($dbconn) or die_status(pg_errormessage($db));
+ $db = pg_pconnect($dbconn) or die_status(pg_last_error($db));
$rsql=pg_exec ($db,"Select count(name) as totwatch FROM pkgs WHERE watch!=''");
$tot_watch=pg_fetch_array($rsql);
print "Total packages with Watch =>$tot_watch[0]\n";
@@ -389,7 +390,7 @@
}
function db_popcon($initial='') {
global $dirs,$dbconn;
- $db = pg_pconnect($dbconn) or die_status(pg_errormessage($db));
+ $db = pg_pconnect($dbconn) or die_status(pg_last_error($db));
$filename=$dirs[popcon_dir] . "/all-popcon-results.txt.gz";
$regexp="/Package:\s($initial\S*)\s+(\d+)\s+(\d+)/iS";
$zp = gzopen($filename, "r") or die_status("Could not open $filename");
@@ -421,7 +422,7 @@
}
function db_popcon_test() {
global $dirs,$dbconn;
- $db = pg_pconnect($dbconn) or die_status(pg_errormessage($db));
+ $db = pg_pconnect($dbconn) or die_status(pg_last_error($db));
$filename=$dirs[popcon_dir] . "/all-popcon-results.txt.gz";
$regexp="/Package:\s(\S+)\s+(\d+)\s+(\d+)/";
$zp = gzfile($filename, "r") or die_status("Could not open $filename");
@@ -876,6 +877,37 @@
"Reply-To: dehs-noreply@{$_SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" . phpversion());
}
+function update_bogus() {
+ 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 up_version='' AND watch!=''";
+ $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_bogus 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