From 4aca87515a5083ae0e31ce3177189fd43b6d05ac Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sat, 3 Jan 2015 13:58:15 +0100 Subject: patch to Vanilla Tomato 1.28 --- release/src/btools/uversion.pl | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100755 release/src/btools/uversion.pl (limited to 'release/src/btools/uversion.pl') 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: $!"); +$_ = ; +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); -- cgit v1.2.3-54-g00ecf