change the date
[tools/build.git] / getbinaryid
1 #!/usr/bin/perl
2
3 ################################################################
4 #
5 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 or 3 as
9 # published by the Free Software Foundation.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program (see the file COPYING); if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 #
21 ################################################################
22
23 BEGIN {
24   unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
25 }
26
27 use Build;
28 use strict;
29
30 my $createmeta;
31 my $manifest;
32
33 while (@ARGV) {
34   if ($ARGV[0] eq '--createmeta')
35     {
36       shift @ARGV;
37       $createmeta = 1;
38       next;
39     }
40   if ($ARGV[0] eq '--manifest')
41     {
42       shift @ARGV;
43       $manifest = shift @ARGV;
44       next;
45     }
46   last;
47 }
48
49 my @files;
50 if ($manifest) {
51   if ($manifest eq '-') {
52     @files = <STDIN>;
53   } else {
54     local *F;
55     open(F, '<', $manifest) || die("$manifest: $!\n");
56     @files = <F>;
57     close F;
58   }
59   chomp @files;
60 }
61 push @files, @ARGV;
62
63 for my $file (@files) {
64   my $sig = Build::queryhdrmd5($file);
65   die("$file: no signature available\n") unless $sig;
66   if ($createmeta) {
67     local *F;
68     my $mf = $file;
69     $mf =~ s/\.[^\.]*$//;
70     $mf .= ".meta";
71     open(F, '>', $mf) || die("$mf: $!\n");
72     print F "$sig  sigmd5\n";
73     close(F) || die("$mf: $!\n");
74   } else {
75     print "$sig\n";
76   }
77 }