- support tilde in rpm version comparison
[platform/upstream/build.git] / getbinaryid
1 #!/usr/bin/perl
2
3 BEGIN {
4   unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
5 }
6
7 use Build;
8 use strict;
9
10 my $createmeta;
11 my $manifest;
12
13 while (@ARGV) {
14   if ($ARGV[0] eq '--createmeta')
15     {
16       shift @ARGV;
17       $createmeta = 1;
18       next;
19     }
20   if ($ARGV[0] eq '--manifest')
21     {
22       shift @ARGV;
23       $manifest = shift @ARGV;
24       next;
25     }
26   last;
27 }
28
29 my @files;
30 if ($manifest) {
31   if ($manifest eq '-') {
32     @files = <STDIN>;
33   } else {
34     local *F;
35     open(F, '<', $manifest) || die("$manifest: $!\n");
36     @files = <F>;
37     close F;
38   }
39   chomp @files;
40 }
41 push @files, @ARGV;
42
43 for my $file (@files) {
44   my $sig = Build::queryhdrmd5($file);
45   die("$file: no signature available\n") unless $sig;
46   if ($createmeta) {
47     local *F;
48     my $mf = $file;
49     $mf =~ s/\.[^\.]*$//;
50     $mf .= ".meta";
51     open(F, '>', $mf) || die("$mf: $!\n");
52     print F "$sig  sigmd5\n";
53     close(F) || die("$mf: $!\n");
54   } else {
55     print "$sig\n";
56   }
57 }