#!/usr/bin/perl # Processes hints files in the specified directory. use strict; use warnings; my $dir=shift || die "need a hint directory\n"; my $fromsuite="etch-proposed-updates "; my $tosuite="etch"; my $archive="/org/secure-testing.debian.net/"; my $heidicmd="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 () { chomp; push @ret, $_; } close KID; } else { exec "dak", "ls", "-s", $suite, "-f", "heidi", "-S", $package or die "can't exec dak ls: $!"; } return @ret; } my $run_dinstall=0; print "dtsasync started at ".localtime(time)."\n\n"; foreach my $hint (glob "$dir/*") { next if $hint =~/\/README$/; if (! open (IN, $hint)) { print "Cannot read $hint\n"; next; } print "Processing $hint\n"; while () { chomp; s/#.*//; s/^\s+//; s/\s+$//; next unless length; if (/^sync\s+(.*)\/(.*)/) { my $sync_package=$1; my $sync_version=$2; print "Syncing $sync_package/$sync_version\n"; print "Current status:\n"; system("dak", "ls", "-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; 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; } if (! @toheidi) { print "In sync, doing nothing.\n"; next; } print "Syncing these:\n"; open(HEIDI, "| $heidicmd") || print "$heidicmd failed!\n"; foreach (@toheidi) { print "$_\n"; print HEIDI "$_\n"; } close HEIDI || print "$heidicmd exited nonzero!\n"; print "New status:\n"; system("dak", "ls", "-S", $sync_package); $run_dinstall=1; } else { print "$hint: parse failure on line $.\n"; } } close IN; } if ($run_dinstall) { system("touch", "$archive/RUN-DINSTALL"); }