forked from pool/pesign-obs-integration
32 lines
568 B
Plaintext
32 lines
568 B
Plaintext
|
#!/usr/bin/perl
|
||
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
|
||
|
use Getopt::Long;
|
||
|
|
||
|
my $USAGE = "Usage: $0 [-r <build root>] <file>\n";
|
||
|
|
||
|
my $buildroot = "";
|
||
|
GetOptions("r|root=s" => \$buildroot) or die $USAGE;
|
||
|
if (scalar(@ARGV) != 1) {
|
||
|
die $USAGE;
|
||
|
}
|
||
|
if ($buildroot) {
|
||
|
$buildroot .= "/";
|
||
|
}
|
||
|
|
||
|
my $fn = shift @ARGV;
|
||
|
my $out = `sha512hmac "$buildroot$fn"`;
|
||
|
if ($?) {
|
||
|
exit 1;
|
||
|
}
|
||
|
my @t = split(" ", $out);
|
||
|
my $hmac = $t[0];
|
||
|
|
||
|
(my $hmacfn = "$buildroot$fn") =~ s|([^/]*)$|.$1.hmac|;
|
||
|
open(my $fd, '>', $hmacfn) or die "$0: Cannot open $hmacfn: $!\n";
|
||
|
print $fd "$hmac $fn\n";
|
||
|
close($fd);
|
||
|
exit 0;
|