File: version.pl

package info (click to toggle)
syslinux 2:4.05+dfsg-6+deb7u1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 25,684 kB
  • sloc: ansic: 276,159; asm: 9,973; pascal: 9,907; perl: 3,492; makefile: 1,736; sh: 626; python: 266; xml: 39
file content (39 lines) | stat: -rwxr-xr-x 927 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl
#
# Read the "version" file and produce some macro declarations
#

use Fcntl;

sub defx($$$) {
    my($def, $name, $val) = @_;

    $def =~ s/\</${name}/g;
    $def =~ s/\@/${val}/g;

    return $def."\n";
}

($vfile, $vout, $def) = @ARGV;
sysopen(VERSION, $vfile, O_RDONLY) or die "$0: Cannot open $vfile\n";
$vfile = <VERSION>;
chomp $vfile;
close(VERSION);

unless ( $vfile =~ /^(([0-9]+)\.([0-9]+))\s+([0-9]+)$/ ) {
    die "$0: Cannot parse version format\n";
}
$version = $1;
$vma = $2+0;
$vmi = $3+0;
$year = $4;

sysopen(VI, $vout, O_WRONLY|O_CREAT|O_TRUNC)
    or die "$0: Cannot create $vout: $!\n";
print VI defx($def, 'VERSION',       $version);
print VI defx($def, 'VERSION_STR',   '"'.$version.'"');
print VI defx($def, 'VERSION_MAJOR', $vma);
print VI defx($def, 'VERSION_MINOR', $vmi);
print VI defx($def, 'YEAR',          $year);
print VI defx($def, 'YEAR_STR',      '"'.$year.'"');
close(VI);