work around command line size limit
[platform/upstream/build.git] / signdummy
1 #!/usr/bin/perl
2
3 # simple "sign" replacement that does nothing but
4 # write a 2048 byte file with a fixed signature.
5 # sign is used in kiwi builds to sign repositories
6
7 my $mode;
8
9 while (@ARGV) {
10   if ($ARGV[0] =~ /^-([cdr])$/) {
11     $mode = $1;
12     shift @ARGV;
13     next;
14   }
15   if ($ARGV[0] eq '--') {
16     shift @ARGV;
17     last;
18   }
19   if ($ARGV[0] =~ /^-/) {
20     die("unsupported option $ARGV[0]\n");
21   }
22   last;
23 }
24 die("only detached mode possible\n") if !$mode || $mode ne 'd';
25 die("filter mode not supported\n") unless @ARGV;
26
27 for my $file (@ARGV) {
28   local *F;
29   open(F, '<', $file) || die("$file: $!\n");
30   my $buf = '';
31   1 while sysread(F, $buf, 16384, length($buf));
32   close(F) || die("$file: $!\n");
33   my $block = "sIGnMe!\n";
34   $block .= sprintf("%08x%08x\n", length($buf), unpack("%32C*", $buf));
35   $block .= "\0" x (2048 - length($block));
36   open(F, '>', "$file.asc") || die("$file.asc: $!\n");
37   (syswrite(F, $block) || 0) == 2048 || die("$file.asc: $!\n");
38   close(F) || die("$file.asc: $!\n");
39 }