sign-and-queue-packages
#!/usr/bin/env genome-perl
use List::MoreUtils;
my @pkgs;
if (@ARGV) {
@pkgs = @ARGV;
}
else {
die "Usage: sign-and-queue-packages *.changes vendor/*.changes\n\nSigns all changes files and then queues that file and the other 3 in codesigner's incoming directory\n";
}
unless ($ENV{MYGPGKEY}) {
die "The environment variable MYGPGKEY is not set! Set it in your .bashrc.";
}
if (@pkgs == 0) {
die "no files in the pwd ending in .changes, and no .changes files specified on the cmdline!";
}
for my $changes_file (@pkgs) {
unless (-e $changes_file) {
warn "file: $changes_file not found! skipping...\n";
next;
}
my $prefix = $changes_file;
$prefix =~ s/_[^_]+.changes//;
my @all_files = glob("$prefix*");
my $cnt = scalar(@all_files);
unless ($cnt == 4) {
warn "Did not find exactly 4 files in the directory with prefix $prefix! This script only works on source packages with one binary package of the same name.";
next;
}
my @cmds = (
"debsign -k$ENV{MYGPGKEY} $changes_file" => '** signing files...',
"chmod 664 @all_files" => "** setting permissions...",
"chgrp info @all_files" => "** setting the group to info...",
"mv @all_files ~codesigner/incoming/lucid-genome-development/" => "** moving files to codesigner queue",
"ls -lt ~codesigner/incoming/lucid-genome-development/" => "** current codesigner queue is:",
);
while (@cmds) {
my $cmd = shift @cmds;
my $msg = shift @cmds;
print "$msg\n RUNNING: $cmd\n";
my $rv = system $cmd;
$rv/=256;
if ($rv) {
warn " ERROR: $msg (skipping $prefix): $!";
next;
}
}
}