| 1 |
#!/usr/bin/perl
|
| 2 |
# Processes hints files in the specified directory.
|
| 3 |
use strict;
|
| 4 |
use warnings;
|
| 5 |
|
| 6 |
my $dir=shift || die "need a hint directory\n";
|
| 7 |
|
| 8 |
my $fromsuite="etch-proposed-updates ";
|
| 9 |
my $tosuite="etch";
|
| 10 |
my $archive="/org/secure-testing.debian.net/";
|
| 11 |
my $heidicmd="sudo -u katie heidi -a $tosuite";
|
| 12 |
|
| 13 |
my $run_dinstall=0;
|
| 14 |
|
| 15 |
print "dtsasync started at ".localtime(time)."\n\n";
|
| 16 |
|
| 17 |
foreach my $hint (glob "$dir/*") {
|
| 18 |
next if $hint =~/\/README$/;
|
| 19 |
if (! open (IN, $hint)) {
|
| 20 |
print "Cannot read $hint\n";
|
| 21 |
next;
|
| 22 |
}
|
| 23 |
print "Processing $hint\n";
|
| 24 |
while (<IN>) {
|
| 25 |
chomp;
|
| 26 |
s/#.*//;
|
| 27 |
s/^\s+//;
|
| 28 |
s/\s+$//;
|
| 29 |
next unless length;
|
| 30 |
|
| 31 |
if (/^sync\s+(.*)\/(.*)/) {
|
| 32 |
my $sync_package=$1;
|
| 33 |
my $sync_version=$2;
|
| 34 |
|
| 35 |
print "Syncing $sync_package/$sync_version";
|
| 36 |
print "Current status:\n";
|
| 37 |
system("madison", "-S", $sync_package);
|
| 38 |
|
| 39 |
my @toheidi;
|
| 40 |
my $pid;
|
| 41 |
die "Can’t fork: $!" unless defined($pid = open(KID, "-│"));
|
| 42 |
if ($pid) {
|
| 43 |
while (<KID>) {
|
| 44 |
chomp;
|
| 45 |
my ($pkg, $version, $arch)=split(' ', 3);
|
| 46 |
next unless $version eq $sync_version;
|
| 47 |
push @toheidi, $_;
|
| 48 |
}
|
| 49 |
close KID || print "madison edited nonzero\n";
|
| 50 |
}
|
| 51 |
else {
|
| 52 |
exec "madison", "-s", $fromsuite,
|
| 53 |
"-f", "heidi", "-S", $sync_package
|
| 54 |
or die "can't exec madison: $!";
|
| 55 |
}
|
| 56 |
|
| 57 |
if (! @toheidi) {
|
| 58 |
print "Already in sync, doing nothing.\n";
|
| 59 |
next;
|
| 60 |
}
|
| 61 |
|
| 62 |
open(HEIDI, "| $heidicmd") || print "$heidicmd failed!\n";
|
| 63 |
foreach (@toheidi) {
|
| 64 |
print HEIDI "$_\n";
|
| 65 |
}
|
| 66 |
close HEIDI || print "$heidicmd exited nonzero!\n";
|
| 67 |
$run_dinstall=1;
|
| 68 |
}
|
| 69 |
else {
|
| 70 |
print "$hint: parse failure on line $.\n";
|
| 71 |
}
|
| 72 |
}
|
| 73 |
close IN;
|
| 74 |
}
|
| 75 |
|
| 76 |
if ($run_dinstall) {
|
| 77 |
system("touch", "$archive/RUN-DINSTALL");
|
| 78 |
}
|