This is an automated email from the ASF dual-hosted git repository.
jialiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bigtop.git
The following commit(s) were added to refs/heads/master by this push:
new ebed06df3 BIGTOP-4063: Adapt bigtop-select to Python 3 (#1236)
ebed06df3 is described below
commit ebed06df36023889f5c61515688d190f681ac83d
Author: timyuer <[email protected]>
AuthorDate: Fri Aug 2 08:57:58 2024 +0800
BIGTOP-4063: Adapt bigtop-select to Python 3 (#1236)
* BIGTOP-4063: Adapt bigtop-select to Python 3
---
.../src/common/bigtop-select/conf-select | 224 ---------------------
.../src/common/bigtop-select/distro-select | 19 +-
.../src/common/bigtop-select/install_select.sh | 4 +-
.../src/rpm/bigtop-select/SPECS/bigtop-select.spec | 4 +-
4 files changed, 10 insertions(+), 241 deletions(-)
diff --git a/bigtop-packages/src/common/bigtop-select/conf-select
b/bigtop-packages/src/common/bigtop-select/conf-select
deleted file mode 100644
index b1189712f..000000000
--- a/bigtop-packages/src/common/bigtop-select/conf-select
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/usr/bin/env python2
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you 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.
-#
-import optparse
-import copy
-import os
-import re
-import sys
-import errno
-from params import stack_root
-
-# The global prefix and current directory
-root = stack_root
-current = root + "/current"
-vconfroot = 'etc'
-lib_root = "usr/lib"
-vconf_name = "conf.dist"
-packages = ("hadoop", "hbase", "hive", "hive-hcatalog",
- "kafka", "spark", "tez", "livy",
- "zookeeper", "zeppelin", "flink", "solr", "ranger-admin",
"ranger-usersync", "ranger-tagsync")
-''' conf link
-/usr/bigtop/3.2.0/usr/lib/${pname}/conf -> /etc/${pname}/conf ->
/etc/alternatives/${pname}-conf -> /usr/bigtop/3.2.0/etc/${pname}/conf.dist.0
-'''
-
-
-def printHelp():
- print("""
-usage: conf-select [-h] [<command>] --package --stack-version --conf-version
-arguments:
- <command> One of create-conf-dir, set-conf-dir
- <--package> package name to set
- <--stack-version> stack version number
- <--conf-version> conf version to set
-optional arguments:
- -h, --help show this help message and exit
-Commands:
- set-conf-dir : set the conf to a specified version
- create-conf-dir : create the specified conf directory
- dry-run-set : dry run for set conf
- dry-run-create : dry run for create conf
-""")
-
-
-def chkPkg(sver, pname):
- '''
- checks package name against the package tuple, check if the package
directory exists and returns True
- e.g. /usr/bigtop/3.2.0/usr/lib/zookeeper
- '''
- pkgdir = os.path.join(root, sver, lib_root, pname)
- if not os.path.isdir(pkgdir) or pname not in packages:
- print(pname + " not installed or incorrect package name")
- sys.exit(1)
- return True
-
-
-def chksVer(sver):
- '''
- returns True if the stack version number exists
- e.g. /usr/bigtop/3.2.0/usr/lib
- '''
- if not os.path.isdir(os.path.join(root, sver, lib_root)):
- print(sver + " Incorrect stack version")
- sys.exit(1)
- return True
-
-
-def chkPath(pname, sver, cver, method):
- '''
- e.g. /usr/bigtop/3.2.0/etc/zookeeper/conf.dist.0
- '''
- confpath = os.path.join(root, sver, vconfroot, pname, vconf_name)
- if cver:
- confpath = os.path.join(root, sver, vconfroot, pname, vconf_name + '.'
+ cver)
- if method == "create" and os.path.exists(confpath):
- print(confpath+" exist already")
- sys.exit(1)
- if method == "set" and not os.path.exists(confpath):
- print(confpath+" does not exist")
- sys.exit(1)
- return True
-
-
-def check(sver, pname, cver, method):
- '''
- Aggregates chksVer, chkPkg and checks if path exits.
- Returns True if all the conditions are met
- '''
- chksVer(sver)
- chkPkg(sver, pname)
- chkPath(pname, sver, cver, method)
-
-
-def drcrtConfDir(pname, sver, cver):
- '''
- # Not really executing
- # e.g. /usr/bigtop/3.2.0/etc/zookeeper/conf.dist.0
- '''
- chksVer(sver)
- chkPkg(sver, pname)
- for confmapkey, confmapval in confmap.items():
- path = os.path.join(root, sver, vconfroot, confmapkey, vconf_name)
- if cver:
- path = os.path.join(root, sver, vconfroot, confmapkey,
vconf_name+'.'+cver)
- print(path)
-
-
-def crtConfDir(pname, sver, cver):
- '''
- e.g. /usr/bigtop/3.2.0/etc/zookeeper/conf.dist.0
- '''
- path = os.path.join(root, sver, vconfroot, pname, vconf_name)
- check(sver, pname, cver, "create")
- for confmapkey, confmapval in confmap.items():
- path = os.path.join(root, sver, vconfroot, confmapkey, vconf_name)
- if cver:
- path = os.path.join(root, sver, vconfroot, confmapkey,
vconf_name+'.'+cver)
- try:
- os.makedirs(path)
- print(path)
- except OSError as exc:
- if exc.errno == errno.EACCES:
- print("Permission denied")
-
-
-def drsetConfDir(pname, sver):
- '''
- Not really executing
- '''
- chksVer(sver)
- chkPkg(sver, pname)
- for confmapkey, confmapval in confmap.items():
- # e.g. /usr/bigtop/3.2.0/usr/lib/hive/conf
- confdir = os.path.join(root, sver, lib_root, pname, confmapval)
- if os.path.exists(confdir) and os.path.islink(confdir):
- print(confdir)
- else:
- print(confdir+" does not exist")
- sys.exit(1)
-
-
-def setConfDir(pname, sver, cver):
- '''
- e.g. /usr/bigtop/3.2.0/usr/lib/zookeeper/conf -> /etc/zookeeper/conf ->
/usr/bigtop/3.2.0/etc/zookeeper/conf.dist.0
- '''
- check(sver, pname, cver, "set")
- for confmapkey, confmapval in confmap.items():
- # e.g. /usr/bigtop/3.2.0/etc/zookeeper/conf.dist.0
- path = os.path.join(root, sver, vconfroot, confmapkey, vconf_name)
- if cver:
- path = os.path.join(root, sver, vconfroot, confmapkey,
vconf_name+'.'+cver)
- # e.g. /usr/bigtop/3.2.0/usr/lib/zookeeper/conf
- confdir = os.path.join(root, sver, lib_root, pname, confmapval)
-
- if os.path.exists(confdir) and not os.path.islink(confdir):
- raise Exception("Expected confdir %s to be a symlink." % confdir)
-
- if os.path.islink(confdir) and not os.path.exists(confdir):
- os.remove(confdir)
-
- if os.path.exists(confdir):
- if path == os.readlink(confdir):
- return
- else:
- os.remove(confdir)
-
- os.symlink('/etc/{0}/conf'.format(pname), confdir)
- print(confdir + " -> " + '/etc/{0}/conf'.format(pname))
- print('alternatives --install /etc/{0}/conf {0}-conf {1}
30'.format(pname, path))
- os.system('alternatives --install /etc/{0}/conf {0}-conf {1}
30'.format(pname, path))
- os.system('alternatives --set {0}-conf {1}'.format(pname, path))
- print('/etc/{0}/conf'.format(pname) + " -> " + path)
-
-
-# Start of main
-parser = optparse.OptionParser(add_help_option=False)
-parser.add_option("-h", "--help", action="store_true", dest="help",
- help="print help")
-parser.add_option("-p", "--package", action="store", dest="pname",
- help="package name")
-parser.add_option("-s", "--stack-version", action="store", dest="sver",
- help="stack verison number")
-parser.add_option("-c", "--conf-version", action="store", dest="cver",
- help="conf verison number", default=None)
-
-(options, args) = parser.parse_args()
-'''default conf mapping'''
-confmap = {options.pname: "conf"}
-'''conf mapping if the pkg name is hive-hcatalog'''
-if options.pname == "hive-hcatalog":
- confmap = {"hive-hcatalog": "etc/hcatalog",
- "hive-webhcat": "etc/webhcat"}
-
-
-
-if options.help or len(args) == 0:
- printHelp()
-elif not options.pname or not options.sver:
- parser.error("Invalid option")
- printHelp()
-elif args[0] == 'create-conf-dir':
- crtConfDir(options.pname, options.sver, options.cver)
-elif args[0] == 'set-conf-dir':
- setConfDir(options.pname, options.sver, options.cver)
-elif args[0] == 'dry-run-set':
- drsetConfDir(options.pname, options.sver)
-elif args[0] == 'dry-run-create':
- drcrtConfDir(options.pname, options.sver, options.cver)
-else:
- printHelp()
diff --git a/bigtop-packages/src/common/bigtop-select/distro-select
b/bigtop-packages/src/common/bigtop-select/distro-select
index 3383fca2f..5a04205f8 100644
--- a/bigtop-packages/src/common/bigtop-select/distro-select
+++ b/bigtop-packages/src/common/bigtop-select/distro-select
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
@@ -71,7 +71,7 @@ leaves = {
"ranger-usersync" : "ranger-usersync",
"ranger-tagsync" : "ranger-tagsync",
"livy-server" : "livy",
- "livy-client" : "livy"
+ "livy-client" : "livy",
"alluxio": "alluxio",
"alluxio-master": "alluxio",
"alluxio-worker": "alluxio"
@@ -161,7 +161,7 @@ def listPackages( packages ):
if packages == None:
packages = leaves
- packages.sort()
+ packages = sorted(packages)
for pkg in packages:
linkname = current + "/" + pkg
if os.path.isdir(linkname):
@@ -172,13 +172,11 @@ def listPackages( packages ):
# Print the avaialable package names
def printPackages():
- packages = leaves.keys()
- packages.sort()
+ packages = sorted(leaves.keys())
print("Packages:")
for pkg in packages:
print(" " + pkg)
- groups = aliases.keys()
- groups.sort()
+ groups = sorted(aliases.keys())
print("Aliases:")
for pkg in groups:
print(" " + pkg)
@@ -203,8 +201,7 @@ def printVersions():
print("ERROR: Unexpected file/directory found in %s: %s" % (root, f))
sys.exit(1)
- keys = result.keys()
- keys.sort()
+ keys = sorted(result.keys())
for k in keys:
print(result[k])
@@ -225,9 +222,9 @@ def setPackages(packages, version, rpm_mode):
sys.exit(1)
if not os.path.isdir(current):
- os.mkdir(current, 0755)
+ os.mkdir(current, 0o755)
- packages.sort()
+ packages = sorted(packages)
for pkg in packages:
linkname = current + "/" + pkg
if os.path.islink(linkname) and rpm_mode:
diff --git a/bigtop-packages/src/common/bigtop-select/install_select.sh
b/bigtop-packages/src/common/bigtop-select/install_select.sh
index b5b88c954..f12aab531 100644
--- a/bigtop-packages/src/common/bigtop-select/install_select.sh
+++ b/bigtop-packages/src/common/bigtop-select/install_select.sh
@@ -79,15 +79,13 @@ CONF_DIR=${CONF_DIR:-/etc/bigtop-select/conf.dist}
STACK_ROOT_DIR=$(echo ${PARENT_DIR} | sed -e "s/\/${BIGTOP_BASE_VERSION}$//")
STACK_SELECTOR=distro-select
-CONF_SELECTOR=conf-select
# Install packages
install -d -p -m 755 $PREFIX${LIB_DIR}/
install -d -p -m 755 $PREFIX${PARENT_DIR}/
install -p -m 755 ${DISTRO_DIR}/${STACK_SELECTOR} $PREFIX${LIB_DIR}/
-install -p -m 755 ${DISTRO_DIR}/${CONF_SELECTOR} $PREFIX${LIB_DIR}/
cat > $PREFIX${LIB_DIR}/params.py <<EOF
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
diff --git a/bigtop-packages/src/rpm/bigtop-select/SPECS/bigtop-select.spec
b/bigtop-packages/src/rpm/bigtop-select/SPECS/bigtop-select.spec
index e62abdc25..ca7ccb8de 100644
--- a/bigtop-packages/src/rpm/bigtop-select/SPECS/bigtop-select.spec
+++ b/bigtop-packages/src/rpm/bigtop-select/SPECS/bigtop-select.spec
@@ -32,8 +32,7 @@ BuildRoot: %(mktemp -ud
%{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildArch: noarch
Source0: install_select.sh
Source1: LICENSE
-Source2: conf-select
-Source3: distro-select
+Source2: distro-select
Requires: bash
# "which" command is needed for a lot of projects.
@@ -53,7 +52,6 @@ This includes a collection of useful tools and files for
Bigtop and Ambari
install -p -m 755 %{SOURCE0} .
install -p -m 755 %{SOURCE1} .
install -p -m 755 %{SOURCE2} .
-install -p -m 755 %{SOURCE3} .
%build