source: trunk/util/arb_tgz2version.pl

Last change on this file was 18915, checked in by westram, 3 years ago
  • use uniform variable name 'cmd'.
  • Property svn:executable set to *
File size: 762 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6sub main() {
7  my $args = scalar(@ARGV);
8  if ($args != 1) { die "Usage: arb_tgz2version arbsrc.tgz\n"; }
9
10  my $tgz = $ARGV[0];
11  if (not -f $tgz) { die "No such file '$tgz'"; }
12
13  my $cmd = "tar --wildcards -Ozxf $tgz '*/SOURCE_TOOLS/version_info'";
14  open(PIPE,$cmd.'|') || die "failed to fork '$cmd' (Reason: $!)";
15
16  my $major = undef;
17  my $minor = undef;
18  foreach (<PIPE>) {
19    if (/^MAJOR=([0-9]+)$/) { $major = $1; }
20    if (/^MINOR=([0-9]+)$/) { $minor = $1; }
21  }
22  close(PIPE) || die "failed to execute '$cmd' (Reason: $! exitcode=$?)";
23
24  if (defined $major and defined $minor) {
25    print "ARB_VERSION=arb_$major.$minor\n";
26  }
27  else {
28    die "Failed to retrieve version from '$tgz'";
29  }
30}
31
32main();
Note: See TracBrowser for help on using the repository browser.