[Dehs-devel] r59 - trunk
atomo64-guest at alioth.debian.org
atomo64-guest at alioth.debian.org
Sun Dec 2 02:18:56 UTC 2007
Author: atomo64-guest
Date: 2007-12-02 02:18:55 +0000 (Sun, 02 Dec 2007)
New Revision: 59
Modified:
trunk/dehs.config.inc
trunk/dehs_pg.php
Log:
Some code cleanup and functions renaming (calling options preserved for compatibility)
Fixed retrieval of upstream changes/changelog (but disabling it by default)
Fixed one of the watch wizard generators (the most successful one)
Fixed the subname-based watch wizard generator
Modified: trunk/dehs.config.inc
===================================================================
--- trunk/dehs.config.inc 2007-11-29 03:48:02 UTC (rev 58)
+++ trunk/dehs.config.inc 2007-12-02 02:18:55 UTC (rev 59)
@@ -15,7 +15,8 @@
$email="bluefuture at email.it,filippo at esaurito.net,atomo64 at gmail.com";
$uscan=$base.'/uscan.pl';
$sfIgnore = array('dl','download','prdownload','downloads','lists','cvs','svn','www');
-$watchFileExts = array('tar.*', 'tgz', 'zip');
+$watchFileExts = array('tar.*', 'tgz', 'zip', 'gz');
/*1: watch url, 2: $space, 3: name, 4: file ext*/
$watchFormat = 'version=3' . "\n" . '%1$s%2$s%3$s-?_?([\d+\.]+|\d+)\.%4$s debian uupdate';
+$fetchUpstreamChanges = false;
?>
\ No newline at end of file
Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php 2007-11-29 03:48:02 UTC (rev 58)
+++ trunk/dehs_pg.php 2007-12-02 02:18:55 UTC (rev 59)
@@ -59,18 +59,18 @@
if (in_array("-db_add",$argv)) db_add($argv[2]);
elseif (in_array("-db_query",$argv)) db_query($argv[2],$argv[3] );
- elseif (in_array("-keep_diff",$argv)) keep_diff($argv[2]);
+ 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("-db_popcon",$argv)) db_popcon($argv[2]);
- elseif (in_array("-keep_popcon",$argv)) keep_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("-check_db",$argv)) check_db();
elseif (in_array("-dehsqa_db",$argv)) dehsqa_db();
elseif (in_array("-clear_db",$argv)) clear_db();
elseif (in_array("-db_up_error",$argv)) db_up_error();
- elseif (in_array("-up_changes",$argv)) up_changes($argv[2]);
- elseif (in_array("-watchf",$argv)) watch_fill($argv[2]);
+ elseif (in_array("-up_changes",$argv)) up_changes($argv[2], true);
+ elseif (in_array("-watchf",$argv) || in_array("-wwiz",$argv)) watch_wizard($argv[2]);
elseif (in_array("-kb_total",$argv)) print "Diff
#stat_up_error();
#stat_up_error();to download Kb => " . kb_total($argv[2]) . "\n" ;
@@ -88,7 +88,7 @@
$zp=gzopen($file,"r") or die_status("Fail to open $file");
while (!gzeof($zp)) {
$line = gzgets ($zp,4096);
- if (preg_match("/\+\+\+\s.+\/debian\/watch/",$line)) {
+ if (preg_match('/\+\+\+\s.+\/debian\/watch$/',$line)) {
$line = gzgets ($zp,4096);
preg_match ("/.+\+\d+\,(\d+)\s/",$line,$watch_lenght);
for ($i = 1; $i <= $watch_lenght[1]; $i++) {
@@ -115,7 +115,7 @@
return $conn_id;
}
}
-function keep_diff($initial = '') {
+function dl_diffs($initial = '') {
global $dirs,$dbconn,$mirrors;
check_db();
$conn_normal=ftp_cn("anonymous","bo at bo.org",$mirrors['unstable']);
@@ -282,9 +282,10 @@
if (ftp_get($conn_id,$localfile,$remotefile,FTP_BINARY)) {
print "Done\n";
if(md5_of_file($localfile)==$sources_info[md5]) print "MD5 => OK\n";
+ else print "MD5 => no match\n";
}
else {
- unlink("$localfile");
+ unlink($localfile);
print "Fail\n";
die_status ("Error in source file");
}
@@ -302,14 +303,6 @@
}
function vers_conv($debvers) {
- /* preg_match("/(.+:)?([^-]+)(ds|dsfg|debian)/",$debvers,$matches);
- if (!$matches[3]) {
- unset($matches);
- preg_match("/(.+:)?([^-]+)/",$debvers,$matches);
- }
- if (substr($matches[2],-1)=='.') $matches[2]=substr($matches[2],0,-1);
- return $matches[2];
- */
// Strip off the epoch
$pos = strpos($debvers, ':');
if ( $pos !== FALSE) {
@@ -436,7 +429,7 @@
}
@pg_close($db);
}
-function keep_popcon() {
+function dl_popcon() {
global $dirs,$dbconn;
$localfile=$dirs[popcon_dir] . "/all-popcon-results.txt.gz";
$remotefile="http://popcon.debian.org/all-popcon-results.txt.gz";
@@ -459,7 +452,7 @@
if($uscan_res[1] !=null) $uscan_res[1]=addslashes($uscan_res[1]);
#print $uscan_res[0] . "\n Name => $res_array[name]\n";
$version=$res_array[version];
- print "Version=>" . $uscan_res[3] . "\n";
+ print "\rVersion=>" . $uscan_res[3];
if ($uscan_res[3]!=null) $version=$uscan_res[3];
#$updated=is_updated($uscan_res[0],$res_array[version]);
$updated=$uscan_res[4];
@@ -470,7 +463,7 @@
$watch_warn=iconv("ISO-8859-1","UTF-8",$uscan_res[1]);
pg_exec($db, "UPDATE pkgs SET up_version='" . $up_version . "',up_url='" . $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");
#print "\rUpdated " . $res_array['name'] . " => $updated Up Version => ". $uscan_res[0];
- print "\rUpstream left => " . $tot --;
+ print "\tUpstream left => " . $tot --;
# }
# else print "Added ". $res_array['name'] ."\n";
# if ($great==0) {
@@ -521,8 +514,14 @@
return true;
}
-function up_changes($src_name='%') {
- global $dbconn;
+function up_changes($src_name='%', $force = false) {
+ global $dbconn, $fetchUpstreamChanges;
+
+ if (!$fetchUpstreamChanges && !$force) {
+ print "\nSkipping download of upstream sources to grab changelogs\n";
+ return;
+ }
+
$changes_files=array("CHANGES","NEWS","Changelog","ChangeLog","changelog");
$db = pg_pconnect($dbconn) ;
$rsql=pg_exec($db, "SELECT id,up_url FROM pkgs WHERE up_url!='' AND keep_changes='t' AND name LIKE '$src_name%'");
@@ -542,7 +541,7 @@
continue;
}
foreach($changes_files as $filename) {
- $command="tar -zxOf " . $localfile . " *$filename 2>/dev/null";
+ $command="tar --wildcards -zxOf " . $localfile . " *$filename 2>/dev/null";
exec($command,$up_changes,$cmdres);
$up_changes=rtrim(implode("\n",$up_changes));
if ($cmdres==0 AND strlen($up_changes)>20) {
@@ -604,35 +603,34 @@
check_db();
$db = pg_connect($dbconn) ;
$bugurl="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=tag&data=upstream&archive=no&show_list_header=no&pend-exc=done";
- print "Downloading bugs list =>";
+ print "\nDownloading bugs list =>";
$ferrors=file_get_contents($bugurl) or die_status ("I can't keep error page from bugs.debian.org");
print "Done\n";
$ferrors=explode("<li>",$ferrors);
$totline=count($ferrors);
#$errors[]=array();
#array_pop($errors);
- print "Total line => $totline\n";
+ print "Total lines => $totline\n";
foreach ($ferrors as $line) {
# print $line . "\n";
- $founded=preg_match("/Package:.+?>([^<]+)<\/a>.+<strong>((\d+)\syear\sand\s|)(\d+)\sdays/sS",$line,$matches);
- if ($founded) {
+ if (preg_match("/Package:.+?>([^<]+)<\/a>.+<strong>((\d+)\syear\sand\s|)(\d+)\sdays/sS",$line,$matches)) {
$errors[$matches[1]][err_tot]++;
$errors[$matches[1]][days]+=$matches[3]*365+$matches[4];
#if ($matches[3]) print "Anni $matches[3]";
#print "Giorni $matches[4]\n";
}
- print "\rLine left => " . $totline--;
+ print "\rLines left => " . $totline--;
}
#arsort($errors);
$total=count($errors);
- foreach ($errors as $error=>$value) {
- pg_exec($db, "UPDATE binpkgs SET up_error=" . $value[err_tot] . ",avg_error_date=" . $value[days]/$value[err_tot] . " WHERE bin_name='$error'") or die_status("Error in upstream error query");
+ foreach ($errors as $pkg_name=>$value) {
+ pg_exec($db, "UPDATE binpkgs SET up_error=" . $value[err_tot] . ",avg_error_date=" . $value[days]/$value[err_tot] . " WHERE bin_name='$pkg_name'") or die_status("Error in upstream bug query");
#print "Pkg: $error Errori: $value[err_tot] Average Days: " . $value[days]/$value[err_tot] . "\n";
- print "\rErrors left => " . $total--;
+ print "\rBugs left => " . $total--;
}
pg_close($db);
}
-function watch_fill($src_name='%'){
+function watch_wizard($src_name='%'){
global $dirs,$dbconn,$sfIgnore,$watchFileExts,$watchFormat;
$db = pg_pconnect($dbconn) or die_status ("Db error");
$checked=$errors=$notfound=$verok=$notmatch=0;
@@ -679,7 +677,7 @@
}
- if (preg_match ('#((ftp://|http://|https://)\S+(html|htm|/(?(?=.+(tar|tgz|zip))|[^>\s\)\a]+)))#i',$contents,$matches)) {
+ if (preg_match ('#((ftp://|http://|https://)\S+(html|htm|/(?(?=.+(tar|tgz|zip|gz))|[^>\s\)\a]+)))#i',$contents,$matches)) {
$final=substr($matches[1],-1);
if ($final=='.') {
$matches[1]=substr($matches[1],0,-1);
@@ -690,10 +688,10 @@
} elseif ($final!='/') {
$matches[1].='/';
}
- $generatedWatches[]=preg_replace("#((http|https|ftp)://.+):(.*)#i",'$1' . '$3', $matches[1],1);
+ $generatedWatches[]=array('url' => preg_replace("#((http|https|ftp)://.+):(.*)#i",'$1' . '$3', $matches[1],1), 'space' => $space);
}
- if (preg_match ('#((ftp|http)\.\S+(html|htm|/(?(?=.+(tar|tgz|zip))|[^>\s\)\a]+)))#i',$contents,$matches)) {
+ if (preg_match ('#((ftp|http)\.\S+(html|htm|/(?(?=.+(tar|tgz|zip|gz))|[^>\s\)\a]+)))#i',$contents,$matches)) {
$final=substr($matches[1],-1);
if ($final=='.') {
$matches[1]=substr($matches[1],0,-1);
@@ -705,7 +703,7 @@
} elseif ($final!='/') {
$matches[1].='/';
}
- $generatedWatches[]=array('url'=>preg_replace("#((http|ftp)\.(.+)):(.*)#i",'$2://$2.$3' . '$4', $matches[1],1), 'space'=>$space);
+ $generatedWatches[]=array('url'=>preg_replace('#(http|ftp)\.(.+)#i','$1://$0', $matches[1],1), 'space'=>$space);
}
if (empty($generatedWatches)) {
@@ -719,6 +717,10 @@
foreach ($generatedWatches as $tWatch) {
+ if (!is_array($tWatch)) {
+ $tWatch = array($tWatch);
+ }
+
$tWatch = array_merge($defs, $tWatch);
foreach ($watchFileExts as $ext) {
@@ -754,7 +756,7 @@
" OK: $verok Error: $errors Not Matched: $notmatch\r";
}
print "\nCopyright files not found: $notfound\n";
- print "Automatic genereted watch file failure: $errors\n";
+ print "Automatic generated watch file failures: $errors\n";
pg_close($db);
}
function dbqa_conn ($dbname,$mode) {
@@ -765,8 +767,6 @@
return $id;
}
function dehsqa_db () {
- #to complete!!!
- #print phpinfo();
global $dirs,$dbconn;
$dir1='/org/alioth.debian.org/chroot/home/groups/dehs/htdocs/';
$dir2="/org/qa.debian.org/data/dehs/";
@@ -782,7 +782,6 @@
elseif (!$res_array[up_version]) $version="Error";
else $version=$res_array[up_version];
- //watch, error, notmatch
if ($res_array['wwiz_type']=="watch") $wwiz=$res_array['wwiz_version'];
else $wwiz=$res_array[wwiz_type];
@@ -809,12 +808,12 @@
global $email;
$intime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2);
db_add();
- keep_popcon();
+ dl_popcon();
db_popcon();
- keep_diff();
+ dl_diffs();
db_up_error();
db_upstream();
- watch_fill();
+ watch_wizard();
up_changes();
dehsqa_db();
$endtime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2);
More information about the Dehs-devel
mailing list