summaryrefslogtreecommitdiff
path: root/release/src/btools/uversion.pl
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-01-03 13:58:15 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2015-01-03 13:58:15 +0100
commit4aca87515a5083ae0e31ce3177189fd43b6d05ac (patch)
tree7b1d9a31393ca090757dc6f0d3859b4fcd93f271 /release/src/btools/uversion.pl
parent008d0be72b2f160382c6e880765e96b64a050c65 (diff)
downloadtomato-4aca87515a5083ae0e31ce3177189fd43b6d05ac.tar.gz
tomato-4aca87515a5083ae0e31ce3177189fd43b6d05ac.tar.bz2
patch to Vanilla Tomato 1.28
Diffstat (limited to 'release/src/btools/uversion.pl')
-rwxr-xr-xrelease/src/btools/uversion.pl75
1 files changed, 75 insertions, 0 deletions
diff --git a/release/src/btools/uversion.pl b/release/src/btools/uversion.pl
new file mode 100755
index 00000000..1e22b5d3
--- /dev/null
+++ b/release/src/btools/uversion.pl
@@ -0,0 +1,75 @@
+#!/usr/bin/perl
+#
+# uversion.pl
+# Copyright (C) 2006 Jonathan Zarate
+#
+# - update the build number for Tomato
+#
+
+use POSIX qw(strftime);
+
+sub error
+{
+ print "\nuversion error: $@\n";
+ exit(1);
+}
+
+sub help
+{
+ print "Usage: uversion --bump|--gen\n";
+ exit(1);
+}
+
+#
+#
+
+if ($#ARGV != 0) {
+ help();
+}
+
+$path = "router/shared";
+$major = 0;
+$minor = 0;
+$build = 0;
+
+open(F, "$path/tomato_version") || error("opening tomato_version: $!");
+$_ = <F>;
+if (!(($major, $minor, $build) = /^(\d+)\.(\d+)\.(\d+)$/)) {
+ error("Invalid version: '$_'");
+}
+close(F);
+
+
+if ($ARGV[0] eq "--bump") {
+ ++$build;
+ open(F, ">$path/tomato_version.~") || error("creating temp file: $!");
+ printf F "%d.%02d.%04d", $major, $minor, $build;
+ close(F);
+ rename("$path/tomato_version.~", "$path/tomato_version") || error("renaming: $!");
+ exit(0);
+}
+
+if ($ARGV[0] ne "--gen") {
+ help();
+}
+
+$time = strftime("%a, %d %b %Y %H:%M:%S %z", localtime());
+$minor = sprintf("%02d", $minor);
+$build = sprintf("%04d", $build);
+
+open(F, ">$path/tomato_version.h~") || error("creating temp file: $!");
+print F <<"END";
+#ifndef __TOMATO_VERSION_H__
+#define __TOMATO_VERSION_H__
+#define TOMATO_MAJOR "$major"
+#define TOMATO_MINOR "$minor"
+#define TOMATO_BUILD "$build"
+#define TOMATO_BUILDTIME "$time"
+#define TOMATO_VERSION "$major.$minor.$build"
+#endif
+END
+close(F);
+rename("$path/tomato_version.h~", "$path/tomato_version.h") || error("renaming: $!");
+
+print "Version: $major.$minor.$build ($time)\n";
+exit(0);