[Dehs-devel] r144 - trunk
atomo64-guest at alioth.debian.org
atomo64-guest at alioth.debian.org
Thu Jul 3 20:57:08 UTC 2008
Author: atomo64-guest
Date: 2008-07-03 20:57:06 +0000 (Thu, 03 Jul 2008)
New Revision: 144
Modified:
trunk/dehs.config.inc
trunk/dehs_pg.php
trunk/update_wwwal.sh
Log:
Support fetching watch files from $VCS
Modified: trunk/dehs.config.inc
===================================================================
--- trunk/dehs.config.inc 2008-06-15 21:47:17 UTC (rev 143)
+++ trunk/dehs.config.inc 2008-07-03 20:57:06 UTC (rev 144)
@@ -37,12 +37,14 @@
$watchFormat = 'version=3' . "\n" . '%5$s' . "\n" . '%1$s%2$s%3$s-?_?([\d+\.]+|\d+)\.%4$s debian uupdate';
$fetchUpstreamChanges = false;
+$fetchWatchFromVCS = true;
$sendNotifications = true;
$notificationsMailFrom = 'Debian External Health System <dehs-devel at lists.alioth.debian.org>';
-$timeStamp_basedCheck = array('all');
+$timeStamp_basedCheck = array('all', 'vcs');
$minimumAge = 5;
+$minimumVCSAge = 6;
$_SERVER['SERVER_NAME']=shell_exec("hostname -f 2>&1");
?>
\ No newline at end of file
Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php 2008-06-15 21:47:17 UTC (rev 143)
+++ trunk/dehs_pg.php 2008-07-03 20:57:06 UTC (rev 144)
@@ -211,7 +211,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,homepage,vcs_browser,vcs_type,vcs,lastpkgsourcesupdate) VALUES ('$matches[1]','$matches[4]','$matches[4]','$matches[5]','$matches[6]','$matches[7]','$matches[8]','$dist','$section','$matches[10]','$matches[14]','$matches[16]','$matches[18]','$matches[19]',now())");
+ $rst=@pg_exec($db, "INSERT INTO pkgs (name,version,dversionmangled,maint,dir,md5_atsource,bytes,dist,section,uploaders,homepage,vcs_browser,vcs_type,vcs,vcsoversource,lastpkgsourcesupdate) VALUES ('$matches[1]','$matches[4]','$matches[4]','$matches[5]','$matches[6]','$matches[7]','$matches[8]','$dist','$section','$matches[10]','$matches[14]','$matches[16]','$matches[18]','$matches[19]','0',now())");
if (!$rst) {
$rsql=pg_exec($db, "SELECT pkgs.version FROM pkgs WHERE name='$matches[1]' AND dist='$dist';");
$version = $matches[4]; // just for safety
@@ -320,8 +320,8 @@
}
function md5_source($section,$dist) {
global $mirrors;
- $relase=file_get_contents ("ftp://$mirrors[$dist]" . remote_dist_dir($dist) . "/$dist/Release") or die_status("Failed to check MD5 of sources");
- preg_match ("/\s([^\s]+)\s+(\d+)\s$section\/source\/Sources\.gz/i", $relase,$matches);
+ $release=file_get_contents ("ftp://$mirrors[$dist]" . remote_dist_dir($dist) . "/$dist/Release") or die_status("Failed to check MD5 of sources");
+ preg_match ("/\s([^\s]+)\s+(\d+)\s$section\/source\/Sources\.gz/i", $release,$matches);
return array("md5"=>$matches[1],"bytes"=>$matches[2]);
# 183dea9ca3c2e35ffd6cf5eee9501c21 2941637 main/binary-i386/Packages.gz
}
@@ -350,7 +350,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, 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, 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));
@@ -987,6 +987,7 @@
echo __FUNCTION__ . ' started the ' . $intime . "\n";
db_add();
dl_diffs();
+ dl_from_vcs('%','%',in_array('vcs',$timeStamp_basedCheck));
db_up_error();
db_upstream('%', in_array('all', $timeStamp_basedCheck));
watch_wizard('%', in_array('all', $timeStamp_basedCheck));
@@ -1000,7 +1001,7 @@
"X-Mailer: PHP/" . phpversion());
}
function update_new() {
- global $email_all;
+ global $email_all, $timeStamp_basedCheck;
$intime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2);
echo __FUNCTION__ . ' started the ' . $intime . "\n";
db_add();
@@ -1020,6 +1021,7 @@
db_up_error();
if ($res_array !== false) {
foreach ($res_array as $entry) {
+ dl_from_vcs($entry['name'],'%',in_array('vcs',$timeStamp_basedCheck));
db_upstream($entry['name']);
up_changes($entry['name']);
watch_wizard($entry['name']);
@@ -1080,4 +1082,67 @@
return gmdate("Y-m-d H:i:s", $timestamp);
}
+function dl_from_vcs($package = '%', $dist = '%', $checkStamps = false, &$db = null) {
+ global $minimumVCSAge;
+ $local_db = false;
+
+ if (!$fetchWatchFromVCS) {
+ return false;
+ }
+
+ if ($db === null) {
+ $local_db = true;
+ $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 "
+ . ($checkStamps? "AND (lastvcsfetch IS NULL OR lastvcsfetch <='"
+ . (sqldate(time() - ($minimumVCSAge*24*3600)))."') "
+ : '');
+ $rsql=pg_exec($db, $sql);
+ while ($res = pg_fetch_array($rsql)) {
+ // avoid miss-parsed entries:
+ if ( count(explode('\n',$res['vcs_type'])) > 1
+ || count(explode('\n',$res['vcs'])) > 1)
+ continue;
+
+ $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'])
+ . ' -f debian/watch '
+ . escapeshellarg($res['vcs'])
+ . ' ' . escapeshellarg($tmp_dir))) {
+ $vcs_watch = implode('\n', file($tmp_dir . '/debian/watch'));
+ }
+
+ shell_exec('rm -rf ' . escapeshellarg($tmp_dir));
+
+ $dehs_opts = array();
+ $dehs_opts['vcs'] = 0;
+
+ if (preg_match('/#\s*DEHS\s*:\s*([\w\s,]+)/i', $vcs_watch, $matches)) {
+ $_dehs_opts = array_map('trim',explode(',', $matches[1]));
+ switch ($_dehs_opts) {
+ case 'vcs':
+ $dehs_opts['vcs'] = 1;
+ break;
+ case 'novcs':
+ $dehs_opts['vcs'] = 0;
+ break;
+ }
+ }
+
+ if ($vcs_watch != null) {
+ $vcs_watch = iconv('ISO-8859-1', 'UTF-8', $vcs_watch);
+ $vcs_watch = pg_escape_string($vcs_watch);
+ }
+
+ pg_exec($db, "UPDATE pkgs SET vcs_watch='" . $vcs_watch . "', lastvcsfetch = now(), vcsoversource='$dehs_opts[vcs]' WHERE name='$res[name]' AND dist='$res[dist]'") or die_status("Query error");
+ }
+
+ if ($local_db) pg_close($db);
+ return true;
+}
+
?>
\ No newline at end of file
Modified: trunk/update_wwwal.sh
===================================================================
--- trunk/update_wwwal.sh 2008-06-15 21:47:17 UTC (rev 143)
+++ trunk/update_wwwal.sh 2008-07-03 20:57:06 UTC (rev 144)
@@ -23,7 +23,7 @@
php4 -q $WORKDIR/www/no_upstream.php > ./no_upstream.html
php4 -q $WORKDIR/www/no_updated.php > ./no_updated.html
psql -A -q -c "SELECT name || ': N/A' FROM pkgs WHERE watch IS NULL OR watch='' AND dist='unstable' ORDER BY name ASC;" | egrep -v '\?column\?|rows\)' > ./no_watch.txt
- psql -A -q -c "SELECT name || ': Error' FROM pkgs WHERE up_version='' AND watch!='' AND dist='unstable' order by name asc;" | egrep -v '\?column\?|rows\)' > ./no_upstream.txt
+ psql -A -q -c "SELECT name || ': Error' FROM pkgs WHERE up_version='' AND watch!='' AND dist='unstable' AND watch_warn !='' order by name asc;" | egrep -v '\?column\?|rows\)' > ./no_upstream.txt
psql -A -q -c "SELECT name || ': ' || up_version FROM pkgs WHERE up_version!='' AND watch!='' AND dist='unstable' AND updated='0' order by name asc;" | egrep -v '\?column\?|rows\)' > ./no_updated.txt
psql -A -q -c "SELECT name || ': N/A' FROM pkgs WHERE watch IS NULL OR watch='' AND dist='unstable' UNION SELECT name || ': Error' FROM pkgs WHERE up_version='' AND watch!='' AND dist='unstable' UNION SELECT name || ': ' || up_version FROM pkgs WHERE up_version!='' AND watch!='' AND dist='unstable';" | egrep -v '\?column\?|rows\)' > ./dehs_debianqa.txt
psql -A -q -c "SELECT name,version,up_version,lastupvsdebsync FROM pkgs WHERE up_version!='' AND up_version IS NOT NULL AND watch!='' AND watch IS NOT NULL AND updated='0' AND dist='unstable'" | egrep -v '\?column\?|rows\)' | grep -v 'name|version|up_version|lastupvsdebsync' > ./ddpomail.txt
More information about the Dehs-devel
mailing list