| Line | |
|---|
| 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | |
|---|
| 6 | sub 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 $command = "tar --wildcards -Ozxf $tgz '*/SOURCE_TOOLS/version_info'"; |
|---|
| 14 | open(PIPE,$command.'|') || die "can't execute '$command' (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); |
|---|
| 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 | |
|---|
| 32 | main(); |
|---|
Note: See
TracBrowser
for help on using the repository browser.