- fix bug in debian helper test
authorMichael Schröder <mls@suse.de>
Sun, 27 May 2007 20:56:39 +0000 (20:56 +0000)
committerMichael Schröder <mls@suse.de>
Sun, 27 May 2007 20:56:39 +0000 (20:56 +0000)
- add getbinaryid program

build
getbinaryid [new file with mode: 0755]

diff --git a/build b/build
index 710a924..42a6c90 100755 (executable)
--- a/build
+++ b/build
@@ -721,7 +721,7 @@ for SPECFILE in $SPECFILES ; do
        for f in $BUILD_ROOT$TOPDIR/SOURCES/debian.* ; do
            test -f $f && DEB_TRANSFORM=true
        done
-       if test -n $DEB_TRANSFORM ; then
+       if test -n "$DEB_TRANSFORM" ; then
            mkdir -p $BUILD_ROOT$TOPDIR/SOURCES.DEB
             debtransform $CHANGELOGARGS $BUILD_ROOT$TOPDIR/SOURCES $BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE $BUILD_ROOT$TOPDIR/SOURCES.DEB
            chroot $BUILD_ROOT su -c "dpkg-source -x $TOPDIR/SOURCES.DEB/*.dsc $TOPDIR/BUILD" - $BUILD_USER
diff --git a/getbinaryid b/getbinaryid
new file mode 100755 (executable)
index 0000000..2d899a0
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+BEGIN {
+  unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build');
+}
+
+use Build;
+use strict;
+
+my $createmeta;
+my $manifest;
+
+while (@ARGV) {
+  if ($ARGV[0] eq '--createmeta')
+    {
+      shift @ARGV;
+      $createmeta = 1;
+      next;
+    }
+  if ($ARGV[0] eq '--manifest')
+    {
+      shift @ARGV;
+      $manifest = shift @ARGV;
+      next;
+    }
+  last;
+}
+
+my @files;
+if ($manifest) {
+  if ($manifest eq '-') {
+    @files = <STDIN>;
+  } else {
+    local *F;
+    open(F, '<', $manifest) || die("$manifest: $!\n");
+    @files = <F>;
+    close F;
+  }
+  chomp @files;
+}
+push @files, @ARGV;
+
+for my $file (@files) {
+  my $sig = Build::queryhdrmd5($file);
+  die("$file: no signature available\n") unless $sig;
+  if ($createmeta) {
+    local *F;
+    my $mf = $file;
+    $mf =~ s/\.[^\.]*$//;
+    $mf .= ".meta";
+    open(F, '>', $mf) || die("$mf: $!\n");
+    print F "$sig  sigmd5\n";
+    close(F) || die("$mf: $!\n");
+  } else {
+    print "$sig\n";
+  }
+}
+