IMPALA-234: Add some library version validation logic to impalad when loading impala-lzo shared library

Change-Id: I51cdbbe5ed7af2f34b7079faf80d45ab9d4c3c35
This commit is contained in:
Skye Wanderman-Milne
2013-04-17 18:47:26 -07:00
committed by Henry Robinson
parent 21685d4f8f
commit 0ac303ad82
6 changed files with 55 additions and 43 deletions

View File

@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# This scrips generates be/src/common/version.cc which contains the build version based
# This script generates be/src/common/version.h which contains the build version based
# on the git hash.
import os
@@ -45,26 +45,42 @@ finally:
print '\n'.join([version, git_hash, build_time])
preamble = '\
// Copyright (c) 2012 Cloudera, Inc. All rights reserved.\n\
// This is a generated file, DO NOT EDIT IT.\n\
// To change this file, see impala/bin/gen_build_version.py\n\
\n\
#include "common/version.h"\n\
\n\
using namespace impala;\n\n'
# construct the build time (e.g. Thu, 04 Oct 2012 11:53:17 PST)
build_time = "%s %s" % (strftime("%a, %d %b %Y %H:%M:%S", localtime()), time.tzname[0])
RESULT_PATH = os.environ['IMPALA_HOME'] + '/be/src/common/version.cc'
version_string = "const char* Version::BUILD_VERSION = \"%s\";" % version;
hash_string = "const char* Version::BUILD_HASH = \"%s\";" % git_hash;
time_string = "const char* Version::BUILD_TIME = \"%s\";" % build_time;
file_contents = """
// Copyright 2012 Cloudera Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// This is a generated file, DO NOT EDIT IT.
// To change this file, see impala/bin/gen_build_version.py
#ifndef IMPALA_COMMON_VERSION_H
#define IMPALA_COMMON_VERSION_H
#define IMPALA_BUILD_VERSION "%(build_version)s"
#define IMPALA_BUILD_HASH "%(build_hash)s"
#define IMPALA_BUILD_TIME "%(build_time)s"
#endif
""" % {'build_version': version,
'build_hash': git_hash,
'build_time': build_time}
file_contents = file_contents.strip()
RESULT_PATH = os.environ['IMPALA_HOME'] + '/be/src/common/version.h'
version_file = open(RESULT_PATH, "w")
version_file.write(preamble)
version_file.write(version_string + "\n");
version_file.write(hash_string + "\n");
version_file.write(time_string + "\n");
version_file.write(file_contents)
version_file.close()