https://github.com/genome/genome
Raw File
Tip revision: c3b127c4c75dcf2a6ef1ffab18fbef44511aaef3 authored by Feiyu Du on 16 June 2016, 15:03:42 UTC
Merge pull request #1458 from dufeiyu/trio
Tip revision: c3b127c
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;
        }
    }
}

back to top