[Debian-l10n-commits] ddtp branch master updated. 20080812.0-129-gbb62413

Martijn van Oosterhout kleptog-guest at moszumanska.debian.org
Mon Dec 23 16:51:46 UTC 2013


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "ddtp".

The branch, master has been updated
       via  bb62413b584368e84c849ae1e0f6cf74001ae50e (commit)
       via  829d82ee737e2765387e9f6ce18b4dba3511f376 (commit)
      from  356d35cd4ad0d4bea83f30a1299186c062e2ffa9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------

http://anonscm.debian.org/gitweb/?p=debian-l10n/ddtp.git;a=commitdiff;h=bb62413b584368e84c849ae1e0f6cf74001ae50e

commit bb62413b584368e84c849ae1e0f6cf74001ae50e
Author: Martijn van Oosterhout <kleptog at svana.org>
Date:   Mon Dec 23 17:13:30 2013 +0100

    Fix the importing of descriptions to verify md5.
    
    Really a backstop to catch bogus data getting into the DB. In theory
    shouldn't happen but various bugs over the years have caused problems
    of this ilk.


http://anonscm.debian.org/gitweb/?p=debian-l10n/ddtp.git;a=commitdiff;h=829d82ee737e2765387e9f6ce18b4dba3511f376

commit 829d82ee737e2765387e9f6ce18b4dba3511f376
Author: Martijn van Oosterhout <kleptog at svana.org>
Date:   Mon Dec 23 17:10:31 2013 +0100

    Only process files that have actually been sucessfully updated.
    
    Without this the processing of old files adds descriptions for
    packages that have been deleted.

-----------------------------------------------------------------------

Summary of changes:
 Packages2db.pl          | 25 +++++++++++++++++--------
 Packages2packages_tb.sh |  5 +++++
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/Packages2db.pl b/Packages2db.pl
index 5ea6a12..a4a2a28 100755
--- a/Packages2db.pl
+++ b/Packages2db.pl
@@ -59,6 +59,7 @@ sub scan_packages_file {
 	my $prioritize;
 	my $description;
 
+	my $descr_md5;
 	my $tag;
 	my $source;
 	my $priority;
@@ -81,13 +82,12 @@ sub scan_packages_file {
 		return $old_description_id;
 	}
 
-	sub get_description_id {
-		my $description_orig= shift(@_);
+	sub get_description_id_from_md5 {
+		my $description_md5= shift(@_);
 		my $description_id;
 
-		my $md5=md5_hex($description_orig);
 		my $sth = $dbh->prepare("SELECT description_id FROM description_tb WHERE description_md5=?");
-		$sth->execute($md5);
+		$sth->execute($description_md5);
 		($description_id) = $sth->fetchrow_array;
 		return $description_id;
 	}
@@ -266,8 +266,12 @@ sub scan_packages_file {
 		if ($_=~/^$/) {
 			my $description_orig=$description;
 			my @oldtranslang;
+			undef $description_id;
 			eval {
-				$description_id=get_description_id($description_orig);
+				if (!defined($descr_md5)) {
+					$descr_md5 = md5_hex($description_orig);
+				}
+				$description_id=get_description_id_from_md5($descr_md5);
 				if ($description_id) {
 					$description_tag_id=get_description_tag_id($description_id,$distribution);
 					if ($description_tag_id) {
@@ -294,9 +298,12 @@ sub scan_packages_file {
 							push @oldtranslang,$lang;
 						}
 					}
-					my $md5=md5_hex($description_orig);
-					$dbh->do("INSERT INTO description_tb (description_md5, description, package, source, prioritize) VALUES (?,?,?,?,?);", undef, $md5,$description,$package,$source,$prioritize);
-					$description_id=get_description_id($description_orig);
+					# Can only happen if Packages file refer to md5 not in Translation-en file and we don't already know it.
+					if( $descr_md5 ne md5_hex($description_orig) ) {
+						die "  skipped package $package ($source), description doesn't match md5 ($descr_md5)";
+					}
+					$dbh->do("INSERT INTO description_tb (description_md5, description, package, source, prioritize) VALUES (?,?,?,?,?);", undef, $descr_md5,$description,$package,$source,$prioritize);
+					$description_id=get_description_id_from_md5($descr_md5);
 					$dbh->do("INSERT INTO description_tag_tb (description_id, tag, date_begin, date_end) VALUES (?,?,CURRENT_DATE,CURRENT_DATE);", undef, $description_id,$distribution);
 					print "   add new description from $package ($source) with prio $prioritize\n" ;
 				}
@@ -342,6 +349,7 @@ sub scan_packages_file {
 			$source=$1;
 			$prioritize=40;
 			$version="1";
+			undef $descr_md5;
 			$prioritize -= 1 if $package =~ /^(linux|kernel)-/i;
 			$prioritize -= 1 if $package =~ /^(linux|kernel)-source/i;
 			$prioritize -= 2 if $package =~ /^(linux|kernel)-patch/i;
@@ -420,6 +428,7 @@ sub scan_packages_file {
 		}
 		if (/^Description-md5: (.*)/) { # new item
 		        my $md5 = $1;
+		        $descr_md5 = $md5;
 		        if (defined $description_en->{$md5}) {
 		                $description = $description_en->{$md5}{'Description-en'} . "\n";
                         }
diff --git a/Packages2packages_tb.sh b/Packages2packages_tb.sh
index 298324c..b40fbdd 100755
--- a/Packages2packages_tb.sh
+++ b/Packages2packages_tb.sh
@@ -55,6 +55,11 @@ do
 		do
 			file="Packages/Packages_${distribution}_${part}_${arch}.bz2"
 
+			# Skip files older than 2 days...
+			if [ -n "$(find "$file" -mtime +2)" ] ; then
+				echo "skipped $file, too old"
+				continue
+			fi
 			[ -f $file ] && echo -n `date`: $file
 			[ -f $file ] && bzcat $file | $INPORT2DB
 			[ -f $file ] || echo no $file
-----------------------------------------------------------------------


hooks/post-receive
-- 
ddtp



More information about the Debian-l10n-commits mailing list