4 # Copyright (C) 2006 Jonathan Zarate
6 # - update the build number for Tomato
9 use POSIX
qw(strftime);
13 print "\nuversion error: $@\n";
19 print "Usage: uversion --bump|--gen\n";
30 $path = "router/shared";
35 open(F
, "$path/tomato_version") || error
("opening tomato_version: $!");
37 if (!(($major, $minor, $build) = /^(\d+)\.(\d+)\.(\d+)$/)) {
38 error
("Invalid version: '$_'");
43 if ($ARGV[0] eq "--bump") {
45 open(F
, ">$path/tomato_version.~") || error
("creating temp file: $!");
46 printf F
"%d.%02d.%04d", $major, $minor, $build;
48 rename("$path/tomato_version.~", "$path/tomato_version") || error
("renaming: $!");
52 if ($ARGV[0] ne "--gen") {
56 $time = strftime
("%a, %d %b %Y %H:%M:%S %z", localtime());
57 $minor = sprintf("%02d", $minor);
58 $build = sprintf("%04d", $build);
60 open(F
, ">$path/tomato_version.h~") || error
("creating temp file: $!");
62 #ifndef __TOMATO_VERSION_H__
63 #define __TOMATO_VERSION_H__
64 #define TOMATO_MAJOR "$major"
65 #define TOMATO_MINOR "$minor"
66 #define TOMATO_BUILD "$build"
67 #define TOMATO_BUILDTIME "$time"
68 #define TOMATO_VERSION "$major.$minor.$build"
72 rename("$path/tomato_version.h~", "$path/tomato_version.h") || error
("renaming: $!");
74 print "Version: $major.$minor.$build ($time)\n";