[Secure-testing-commits] r1680 - bin

Joey Hess joeyh at costa.debian.org
Sat Aug 27 19:26:25 UTC 2005


Author: joeyh
Date: 2005-08-27 19:26:24 +0000 (Sat, 27 Aug 2005)
New Revision: 1680

Modified:
   bin/dtsasync
Log:
add change minimisation code


Modified: bin/dtsasync
===================================================================
--- bin/dtsasync	2005-08-27 19:12:28 UTC (rev 1679)
+++ bin/dtsasync	2005-08-27 19:26:24 UTC (rev 1680)
@@ -9,7 +9,27 @@
 my $tosuite="etch";
 my $archive="/org/secure-testing.debian.net/";
 my $heidicmd="sudo -u katie heidi -a $tosuite";
+			
+sub getlines {
+	my $suite=shift;
+	my $package=shift;
 
+	my @ret;
+	my $pid;
+	die "Can’t fork: $!" unless defined($pid = open(KID, "-|"));
+	if ($pid) {
+		while (<KID>) {
+			chomp;
+			push @ret, $_;
+		}
+		close KID || print "madison edited nonzero\n";
+	}
+	else {
+		exec "madison", "-s", $suite, "-f", "heidi", "-S", $package
+			or die "can't exec madison: $!";
+	}
+}
+
 my $run_dinstall=0;
 
 print "dtsasync started at ".localtime(time)."\n\n";
@@ -36,26 +56,24 @@
 			print "Current status:\n";
 			system("madison", "-S", $sync_package);
 			
+			my @fromlines=getlines($fromsuite, $sync_package);
+			if (! @fromlines) {
+				print "Not available in version $sync_version, doing nothing.\n";
+				next;
+			}
+			my @tolines=getlines($tosuite, $sync_package);
 			my @toheidi;
-			my $pid;
-			die "Can’t fork: $!" unless defined($pid = open(KID, "-|"));
-			if ($pid) {
-				while (<KID>) {
-					chomp;
-					my ($pkg, $version, $arch)=split(' ', 3);
-					next unless $version eq $sync_version;
-					push @toheidi, $_;
-				}
-				close KID || print "madison edited nonzero\n";
+
+			foreach my $line (@fromlines) {
+				next if grep { $_ eq $line } @tolines;
+				
+				my ($pkg, $version, $arch)=split(' ', $line, 3);
+				next unless $version eq $sync_version;
+				push @toheidi, $line;
 			}
-			else {
-				exec "madison", "-s", $fromsuite,
-					"-f", "heidi", "-S", $sync_package
-				or die "can't exec madison: $!";
-			}
-			
+
 			if (! @toheidi) {
-				print "Already in sync, doing nothing.\n";
+				print "In sync, doing nothing.\n";
 				next;
 			}
 			




More information about the Secure-testing-commits mailing list