[Dehs-devel] r149 - trunk

atomo64-guest at alioth.debian.org atomo64-guest at alioth.debian.org
Thu Jul 10 02:02:52 UTC 2008


Author: atomo64-guest
Date: 2008-07-10 02:02:51 +0000 (Thu, 10 Jul 2008)
New Revision: 149

Modified:
   trunk/dehs_pg.php
Log:
Some code cleanup, bug fixes, and the introduction of failures_count


Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php	2008-07-10 01:54:52 UTC (rev 148)
+++ trunk/dehs_pg.php	2008-07-10 02:02:51 UTC (rev 149)
@@ -66,6 +66,7 @@
     elseif (in_array("-db_popcon",$argv))  db_popcon();
     elseif (in_array("-dl_popcon",$argv) || in_array("-keep_popcon",$argv))  dl_popcon();
     elseif (in_array("-db_upstream",$argv))  db_upstream((!empty($argv[2])?$argv[2]:'%'));
+    elseif (in_array("-dl_from_vcs",$argv))  dl_from_vcs((!empty($argv[2])?$argv[2]:'%'),(!empty($argv[3])?$argv[3]:'%'));
     elseif (in_array("-update_all",$argv))  update_all();
     elseif (in_array("-update_new",$argv))  update_new();
     elseif (in_array("-update_bogus",$argv))  update_bogus();
@@ -350,7 +351,7 @@
     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, lastcheck timestamp, homepage text, vcs text,  vcs_type text, vcs_browser text,vcs_watch text, vcsoversource bool,vcs_up_version text,vcs_dversionmangled text,vcs_up_url text, vcs_watch_warn text, vcs_updated bool, lastvcsfetch timestamp, lastupvsdebsync timestamp, lastpkgsourcesupdate timestamp, pop_inst numeric,pop_vote numeric)") or die_status('Error creating table pkgs\n');
+        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 text,  vcs_type text, vcs_browser text,vcs_watch text, vcsoversource bool,vcs_up_version text,vcs_dversionmangled text,vcs_up_url text, vcs_watch_warn text, vcs_updated bool, lastvcsfetch timestamp, lastupvsdebsync timestamp, lastpkgsourcesupdate timestamp, failures_count numeric, pop_inst numeric,pop_vote numeric)") 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));
         pg_exec($db, "CREATE INDEX updatex on pkgs (lastcheck,lastpkgsourcesupdate);") or die_status('Errore creating index - ' . pg_last_error($db));
@@ -504,7 +505,7 @@
     	$postORDER = 'LIMIT ' . $limit;
     }
 
-    $rsql=pg_exec($db, "SELECT id, name,dist,up_version,version,watch,lastupvsdebsync FROM pkgs WHERE watch is not null AND name LIKE '$initial' $postWHERE ORDER BY lastcheck DESC $postORDER");
+    $rsql=pg_exec($db, "SELECT id, name,dist,up_version,version,watch,lastupvsdebsync,failures_count FROM pkgs WHERE watch is not null AND name LIKE '$initial' $postWHERE ORDER BY lastcheck DESC $postORDER");
     $tot=pg_numrows($rsql);
 
     while ($res_array=pg_fetch_array($rsql)) {
@@ -517,6 +518,15 @@
         $lastupvsdebsync = $res_array['lastupvsdebsync'];
         $mangle = true;
 
+        /* Do not increase the number of failures if uscan didn't throw any warning
+            because it might be that the watch file is "empty"
+        */
+        if (!$uscan_res['uversion'] && $uscan_res['warnings']) {
+            $res_array['failures_count']++;
+        } else {
+            $res_array['failures_count'] = 0;
+        }
+
         print "\rVersion=>" . $uscan_res['dversion'];
         if ($uscan_res['dversion']!=null) $version=$uscan_res['dversion'];
         if ($uscan_res['dversionmangled']!=null && $uscan_res['dversionmangled'] != vers_conv($res_array['version'])) {
@@ -534,7 +544,7 @@
         }
 
         if (!$updated) {
-            events::newVersion($res_array['name'], $res_array['version'], $uscan_res['uversion'], $res_array['dist'], $up_url);
+            events::newVersion($res_array['name'], $res_array['version'], $up_version, $res_array['dist'], $up_url);
         } else {
             $lastupvsdebsync = sqldate();
         }
@@ -543,15 +553,28 @@
             $lastupvsdebsync = sqldate(0);
         }
 
-        if ($uscan_res['uversion']!=$res_array[up_version]) ($keep_changes=1);
-        else $keep_changes=0;
+        $keep_changes = (int) ($up_version != $res_array['up_version']);
 
         $watch_warn='';
         if($uscan_res['warnings'] != null) {
             $watch_warn=pg_escape_string(iconv("ISO-8859-1","UTF-8", $uscan_res['warnings']));
         }
 
-        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");
+        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,
+                                    failures_count=$res_array[failures_count],
+                                    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['uversion'];
         print "\t Upstream left => " . $tot --;
         #				}
@@ -1082,7 +1105,7 @@
         return gmdate("Y-m-d H:i:s", $timestamp);
 }
 
-function dl_from_vcs($package = '%', $dist = '%', $checkStamps = false, &$db = null) {
+function dl_from_vcs($package = '%', $dist = '%', $checkStamps = false, $db = null) {
     global $minimumVCSAge;
     $local_db = false;
 
@@ -1095,8 +1118,8 @@
         $db = pg_pconnect($dbconn)  or  die_status(pg_last_error($db));
     }
 
-    $sql="SELECT name,dist,vcs_type,vcs FROM pkgs WHERE name LIKE '$package' AND '
-    . 'dist LIKE '$dist' AND vcs!='' AND vcs IS NOT NULL AND vcs_type!='' AND vcs_type IS NOT NULL "
+    $sql="SELECT name,dist,vcs_type,vcs FROM pkgs WHERE name LIKE '$package' AND "
+    . "dist LIKE '$dist' AND vcs!='' AND vcs IS NOT NULL AND vcs_type!='' AND vcs_type IS NOT NULL "
     . ($checkStamps? "AND (lastvcsfetch IS NULL OR lastvcsfetch <='"
                     . (sqldate(time() - ($minimumVCSAge*24*3600)))."') "
                     : '');
@@ -1107,6 +1130,8 @@
             || count(explode('\n',$res['vcs'])) > 1)
             continue;
 
+        print "Fetching watch file of $res[name] (type: $res[vcs_type]) from $[vcs]\n";
+
         $tmp_dir = shell_exec('mktemp -d') or die_status("mktemp failed to create directory!");
         $vcs_watch = null;
         if (exec('debcheckout.pl -t ' . escapeshellarg($res['vcs_type'])




More information about the Dehs-devel mailing list