setbuildinfo.in 1.15 KB
Newer Older
1 2 3
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
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 40 41 42 43 44 45 46 47 48 49 50 51 52
# All rights reserved.
#
# Set the version and build info into the DB, at a toplevel install.
#
use English;
use Getopt::Std;
use POSIX qw(strftime);

#
# Configure variables
#
my $DBNAME    = '@TBDBNAME@';
my $DBMIGRATE = "@top_srcdir@/sql/database-migrate.txt";

#
# We use the bare Mysql module instead of the testbed libdb, so that this
# script can run from a first-time installation, before the latter is
# installed.
#
use Mysql;

#
# Build a list of tables to export
#
my $dbh = Mysql->connect('localhost', $DBNAME, undef, undef);
if (!$dbh) {
    die("*** $0:\n".
	"    Unable to connect to mysqld\n");
}

#
# Easy, get the build version which is simply today's date. 
#
my $buildinfo = POSIX::strftime("%m/%d/20%y", localtime());
$buildinfo = $dbh->quote($buildinfo);

#
# And store into the appropriate sitevar.
#
my $query_result =
    $dbh->query("update sitevariables set value=$buildinfo ".
		"where name='general/version/build'");
if (!$query_result) {
    die("*** $0:\n".
	"    Unable to set sitevar 'general/version/build' to $buildinfo\n");
}

exit(0);