补丁实战-IDE的使用
在日常大数据运维、组件适配甚至 Stack 集成过程中,使用补丁是高频动作。IntelliJ IDEA 高效工具 提供了非常友好的补丁生成与应用流程,非常适合代码联调、远程协作和多分支场景。
# 3.1 选择变更并生成补丁
操作流程一览 打开你的项目,确认已接入 Git/SVN 等版本管理。完成修改后,进入 IDEA 的版本控制工具窗口(一般在下方),选择你需要生成补丁的修改内容。
右键生成 Patch 鼠标右键点击,选择
Create Patch
。在弹窗中输入补丁名称、确认路径(建议 UTF-8 编码),确定即可自动导出补丁文件。
提示
一般建议补丁命名包含分支、功能点、作者、日期,方便归档和后续追溯。例如:feature-redis-stack-20240623.patch
# 3.2 查看和理解补丁文件
补丁本质是文本文件,内容记录了所有的增删改行,包括行号、上下文等。可用任何文本编辑器直接打开,也可直接通过命令行 diff 查看变化。
Subject: [PATCH] feat:3.3.0版本迁移ranger能力
---
Index: bigtop-packages/src/common/bigtop-select/distro-select
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bigtop-packages/src/common/bigtop-select/distro-select b/bigtop-packages/src/common/bigtop-select/distro-select
--- a/bigtop-packages/src/common/bigtop-select/distro-select (revision bc65999ea5d808543d9b0d4b7390d009aac224e0)
+++ b/bigtop-packages/src/common/bigtop-select/distro-select (date 1723598941576)
@@ -35,260 +35,325 @@
# The packages and where in the release they should point to
leaves = {
- "hadoop-client": "hadoop",
- "hadoop-hdfs-client": "hadoop-hdfs",
- "hadoop-hdfs-datanode": "hadoop-hdfs",
- "hadoop-hdfs-journalnode": "hadoop-hdfs",
- "hadoop-hdfs-namenode": "hadoop-hdfs",
- "hadoop-hdfs-secondarynamenode": "hadoop-hdfs",
- "hadoop-hdfs-zkfc": "hadoop-hdfs",
- "hadoop-yarn-client": "hadoop-yarn",
- "hadoop-yarn-resourcemanager": "hadoop-yarn",
- "hadoop-yarn-nodemanager": "hadoop-yarn",
- "hadoop-mapreduce-client": "hadoop-mapreduce",
- "hadoop-mapreduce-historyserver": "hadoop-mapreduce",
- "hbase-client": "hbase",
- "hbase-master": "hbase",
- "hbase-regionserver": "hbase",
- "tez-client": "tez",
- "hive-client": "hive",
- "hive-metastore": "hive",
- "hive-server2": "hive",
- "hive-webhcat": "hive-hcatalog",
- "kafka-broker": "kafka",
- "oozie-client": "oozie",
- "oozie-server": "oozie",
- "phoenix-client": "phoenix",
- "phoenix-server": "phoenix",
- "zeppelin-server": "zeppelin",
- "zookeeper-client": "zookeeper",
- "zookeeper-server": "zookeeper",
- "solr-server" : "solr",
- "flink-client" : "flink",
- "flink-historyserver" : "flink",
- "spark-client" : "spark",
- "spark-thriftserver" : "spark",
- "spark-historyserver" : "spark"
+ 'flink-client': 'flink',
+ 'flink-historyserver': 'flink',
+ 'hadoop-client': 'hadoop',
+ 'hadoop-hdfs-client': 'hadoop-hdfs',
+ 'hadoop-hdfs-datanode': 'hadoop-hdfs',
+ 'hadoop-hdfs-journalnode': 'hadoop-hdfs',
+ 'hadoop-hdfs-namenode': 'hadoop-hdfs',
+ 'hadoop-hdfs-nfs3': 'hadoop-hdfs',
+ 'hadoop-hdfs-portmap': 'hadoop-hdfs',
+ 'hadoop-hdfs-secondarynamenode': 'hadoop-hdfs',
+ 'hadoop-hdfs-zkfc': 'hadoop-hdfs',
+ 'hadoop-httpfs': 'hadoop-httpfs',
+ 'hadoop-mapreduce-client': 'hadoop-mapreduce',
+ 'hadoop-mapreduce-historyserver': 'hadoop-mapreduce',
+ 'hadoop-yarn-client': 'hadoop-yarn',
+ 'hadoop-yarn-nodemanager': 'hadoop-yarn',
+ 'hadoop-yarn-registrydns': 'hadoop-yarn',
+ 'hadoop-yarn-resourcemanager': 'hadoop-yarn',
+ 'hadoop-yarn-timelinereader': 'hadoop-yarn',
+ 'hadoop-yarn-timelineserver': 'hadoop-yarn',
+ 'hbase-client': 'hbase',
+ 'hbase-master': 'hbase',
+ 'hbase-regionserver': 'hbase',
+ 'hbase-thriftserver': 'hbase',
+ 'hive-client': 'hive',
+ 'hive-metastore': 'hive',
+ 'hive-server2': 'hive',
+ 'hive-server2-hive': 'hive',
+ 'hive-server2-hive2': 'hive2',
+ 'hive-webhcat': 'hive-hcatalog',
+ 'hive_warehouse_connector': 'hive_warehouse_connector',
+ 'kafka-broker': 'kafka',
+ 'livy-client': 'livy',
+ 'livy-server': 'livy',
+ 'livy2-client': 'livy2',
+ 'livy2-server': 'livy2',
+ 'phoenix-client': 'phoenix',
+ 'phoenix-server': 'phoenix',
+ 'ranger-admin': 'ranger-admin',
+ 'ranger-kms': 'ranger-kms',
+ 'ranger-tagsync': 'ranger-tagsync',
+ 'ranger-usersync': 'ranger-usersync',
+ 'solr-server': 'solr',
+ 'spark-atlas-connector': 'spark-atlas-connector',
+ 'spark-client': 'spark',
+ 'spark-historyserver': 'spark',
+ 'spark-schema-registry': 'spark-schema-registry',
+ 'spark-thriftserver': 'spark',
+ 'spark_llap': 'spark_llap',
+ 'sqoop-client': 'sqoop',
+ 'sqoop-server': 'sqoop',
+ 'tez-client': 'tez',
+ 'zeppelin-server': 'zeppelin',
+ 'zookeeper-client': 'zookeeper',
+ 'zookeeper-server': 'zookeeper'
}
# Define the aliases and the list of leaves they correspond to
aliases = {
- "all": leaves.keys(),
- "client" : ["hadoop-client",
- "hbase-client",
- "tez-client",
- "hive-client",
- "oozie-client",
- "phoenix-client",
- "zookeeper-client",
- "flink-client",
- "spark-client"],
- "hadoop-hdfs-server": ["hadoop-hdfs-datanode",
- "hadoop-hdfs-journalnode",
- "hadoop-hdfs-namenode",
- "hadoop-hdfs-zkfc",
- "hadoop-hdfs-secondarynamenode"],
- "hadoop-mapreduce-server": ["hadoop-mapreduce-historyserver"],
- "hadoop-yarn-server": ["hadoop-yarn-resourcemanager",
- "hadoop-yarn-nodemanager"],
- "hive-server": ["hive-metastore",
- "hive-server2",
- "hive-webhcat"],
+ "all": leaves.keys(),
+ "client": ["hadoop-client",
+ "hbase-client",
+ "oozie-client",
+ "phoenix-client",
+ "slider-client",
+ "sqoop-client",
+ "zookeeper-client",
+ "spark-client",
+ "flink-client",
+ "spark-schema-registry",
+ "spark_llap"],
+ "hadoop-hdfs-server": ["hadoop-hdfs-datanode",
+ "hadoop-hdfs-journalnode",
+ "hadoop-hdfs-namenode",
+ "hadoop-hdfs-zkfc",
+ "hadoop-hdfs-secondarynamenode",
+ "hadoop-hdfs-nfs3"],
+ "hadoop-mapreduce-server": ["hadoop-mapreduce-historyserver"],
+ "hadoop-yarn-server": ["hadoop-yarn-resourcemanager",
+ "hadoop-yarn-nodemanager",
+ "hadoop-yarn-timelineserver",
+ "hadoop-yarn-timelinereader",
+ "hadoop-yarn-registrydns"],
+ "hive-server": ["hive-metastore",
+ "hive-server2",
+ "hive-webhcat"],
}
locked_contexts = {
- "hadoop-client": [("hadoop-hdfs-client", "hadoop-hdfs"),
- ("hadoop-yarn-client", "hadoop-yarn"),
- ("hadoop-mapreduce-client", "hadoop-mapreduce"),
- ("hive-client", "hive"),
- ("tez-client", "tez"),
- ("spark-client", "spark")]
+ "hadoop-client": [
+ ("hadoop-hdfs-client", "hadoop-hdfs"),
+ ("hadoop-httpfs", "hadoop-httpfs"),
+ ("hadoop-yarn-client", "hadoop-yarn"),
+ ("hadoop-mapreduce-client", "hadoop-mapreduce"),
+ ("hive-client", "hive"),
+ ("tez-client", "tez"),
+ ("livy-client", "livy"),
+ ("livy2-client", "livy2"),
+ ("spark-schema-registry", "spark-schema-registry"),
+ ("spark_llap", "spark_llap"),
+ ("spark-client", "spark"),
+ ("flink-client", "flink")
+ ]
}
command_symlinks = {
- "hadoop" : "hadoop-client/../../bin/hadoop",
- "hdfs" : "hadoop-hdfs-client/../../bin/hdfs",
- "yarn" : "hadoop-yarn-client/../../bin/yarn",
- "mapred" : "hadoop-mapreduce-client/../../bin/mapred",
- "hbase" : "hbase-client/../../bin/hbase",
- "beeline" : "hive-client/../../bin/beeline",
- "hive" : "hive-client/../../bin/hive",
- "hiveserver2" : "hive-server2/../../bin/hiveserver2",
- "hcat" : "hive-webhcat/../../bin/hcat",
- "zookeeper-client" : "zookeeper-client/../../bin/zookeeper-client",
- "zookeeper-server" : "zookeeper-server/../../bin/zookeeper-server",
- "zookeeper-server-cleanup" : "zookeeper-server/../../bin/zookeeper-server-cleanup",
- "zookeeper-server-initialize" : "zookeeper-server/../../bin/zookeeper-server-initialize",
- "kafka-console-consumer.sh" : "kafka-broker/../../bin/kafka-console-consumer.sh",
- "kafka-console-producer.sh" : "kafka-broker/../../bin/kafka-console-producer.sh",
- "kafka-run-class.sh" : "kafka-broker/../../bin/kafka-run-class.sh",
- "kafka-topics.sh" : "kafka-broker/../../bin/kafka-topics.sh",
- "solrctl" : "solr-server/../../bin/solrctl",
- "flink" : "flink-client/../../bin/flink",
- "find-spark-home" : "spark-client/../../bin/find-spark-home",
- "spark-example" : "spark-client/../../bin/spark-example",
- "spark-class" : "spark-client/../../bin/spark-class",
- "spark-shell" : "spark-client/../../bin/spark-shell",
- "spark-sql" : "spark-client/../../bin/spark-sql",
- "spark-submit" : "spark-client/../../bin/spark-submit",
- "pyspark" : "spark-client/../../bin/pyspark"
+ "hadoop": "hadoop-client/../../bin/hadoop",
+ "hdfs": "hadoop-hdfs-client/../../bin/hdfs",
+ "yarn": "hadoop-yarn-client/../../bin/yarn",
+ "mapred": "hadoop-mapreduce-client/../../bin/mapred",
+ "hbase": "hbase-client/../../bin/hbase",
+ "beeline": "hive-client/../../bin/beeline",
+ "hive": "hive-client/../../bin/hive",
+ "hiveserver2": "hive-server2/../../bin/hiveserver2",
+ "hcat": "hive-webhcat/../../bin/hcat",
+ "zookeeper-client": "zookeeper-client/../../bin/zookeeper-client",
+ "zookeeper-server": "zookeeper-server/../../bin/zookeeper-server",
+ "zookeeper-server-cleanup": "zookeeper-server/../../bin/zookeeper-server-cleanup",
+ "zookeeper-server-initialize": "zookeeper-server/../../bin/zookeeper-server-initialize",
+ "kafka-console-consumer.sh": "kafka-broker/../../bin/kafka-console-consumer.sh",
+ "kafka-console-producer.sh": "kafka-broker/../../bin/kafka-console-producer.sh",
+ "kafka-run-class.sh": "kafka-broker/../../bin/kafka-run-class.sh",
+ "kafka-topics.sh": "kafka-broker/../../bin/kafka-topics.sh",
+ "solrctl": "solr-server/../../bin/solrctl",
+ "flink": "flink-client/../../bin/flink",
+ "find-spark-home": "spark-client/../../bin/find-spark-home",
+ "spark-example": "spark-client/../../bin/spark-example",
+ "spark-class": "spark-client/../../bin/spark-class",
+ "spark-shell": "spark-client/../../bin/spark-shell",
+ "spark-sql": "spark-client/../../bin/spark-sql",
+ "spark-submit": "spark-client/../../bin/spark-submit",
+ "pyspark": "spark-client/../../bin/pyspark",
+ "sqoop": "sqoop-client/bin/sqoop",
+ "sqoop-codegen": "sqoop-client/bin/sqoop-codegen",
+ "sqoop-create-hive-table": "sqoop-client/bin/sqoop-create-hive-table",
+ "sqoop-eval": "sqoop-client/bin/sqoop-eval",
+ "sqoop-export": "sqoop-client/bin/sqoop-export",
+ "sqoop-help": "sqoop-client/bin/sqoop-help",
+ "sqoop-import": "sqoop-client/bin/sqoop-import",
+ "sqoop-import-all-tables": "sqoop-client/bin/sqoop-import-all-tables",
+ "sqoop-job": "sqoop-client/bin/sqoop-job",
+ "sqoop-list-databases": "sqoop-client/bin/sqoop-list-databases",
+ "sqoop-list-tables": "sqoop-client/bin/sqoop-list-tables",
+ "sqoop-merge": "sqoop-client/bin/sqoop-merge",
+ "sqoop-metastore": "sqoop-server/bin/sqoop-metastore",
+ "sqoop-version": "sqoop-client/bin/sqoop-version",
+ "atlas-start": "atlas-server/bin/metadata-start.sh",
+ "atlas-stop": "atlas-server/bin/metadata-stop.sh",
+ "ranger-admin-start": "ranger-admin/ews/ranger-admin-start",
+ "ranger-admin-stop": "ranger-admin/ews/ranger-admin-stop",
+ "ranger-kms": "ranger-kms/ranger-kms",
+ "ranger-usersync-start": "ranger-usersync/ranger-usersync-start",
+ "ranger-usersync-stop": "ranger-usersync/ranger-usersync-stop",
+
}
# Given a package or alias name, get the full list of packages
-def getPackages( name ):
- if name == None:
- return leaves.keys()
- if name in aliases:
- return aliases[name]
- if name in leaves:
- return [ name ]
+def getPackages(name):
+ if name == None:
+ return leaves.keys()
+ if name in aliases:
+ return aliases[name]
+ if name in leaves:
+ return [name]
- print("ERROR: Invalid package - " + name)
- print('')
- printPackages()
- sys.exit(1)
+ print("ERROR: Invalid package - " + name)
+ print('')
+ printPackages()
+ sys.exit(1)
+
# Print the status of each of the given packages
-def listPackages( packages ):
- if packages == None:
- packages = leaves
+def listPackages(packages):
+ if packages == None:
+ packages = leaves
- packages.sort()
- for pkg in packages:
- linkname = current + "/" + pkg
- if os.path.isdir(linkname):
- print(pkg + " - " +
- os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(os.readlink(linkname))))))
- else:
- print(pkg + " - None")
+ packages.sort()
+ for pkg in packages:
+ linkname = current + "/" + pkg
+ if os.path.isdir(linkname):
+ print(pkg + " - " +
+ os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(os.readlink(linkname))))))
+ else:
+ print(pkg + " - None")
+
# Print the avaialable package names
def printPackages():
- packages = leaves.keys()
- packages.sort()
- print("Packages:")
- for pkg in packages:
- print(" " + pkg)
- groups = aliases.keys()
- groups.sort()
- print("Aliases:")
- for pkg in groups:
- print(" " + pkg)
+ packages = leaves.keys()
+ packages.sort()
+ print("Packages:")
+ for pkg in packages:
+ print(" " + pkg)
+ groups = aliases.keys()
+ groups.sort()
+ print("Aliases:")
+ for pkg in groups:
+ print(" " + pkg)
-#Print whether given package is supported or not
+
+# Print whether given package is supported or not
def isSupportedPacakge(package):
packages = leaves.keys()
if package in packages:
- print("%s" % package)
+ print("%s" % package)
else:
- print(None)
- sys.exit(1)
+ print(None)
+ sys.exit(1)
+
# Print the installed packages
def printVersions():
- result = {}
- for f in os.listdir(root):
- if f not in [".", "..", "current", "share", "lost+found"]:
- try:
- result[tuple(map(int, version_regex.split(f)))] = f
- except ValueError:
- print("ERROR: Unexpected file/directory found in %s: %s" % (root, f))
- sys.exit(1)
+ result = {}
+ for f in os.listdir(root):
+ if f not in [".", "..", "current", "share", "lost+found"]:
+ try:
+ result[tuple(map(int, version_regex.split(f)))] = f
+ except ValueError:
+ print("ERROR: Unexpected file/directory found in %s: %s" % (root, f))
+ sys.exit(1)
- keys = result.keys()
- keys.sort()
- for k in keys:
- print(result[k])
+ keys = result.keys()
+ keys.sort()
+ for k in keys:
+ print(result[k])
+
# Set the list of packages to the given version
def setPackages(packages, version, rpm_mode):
- if packages == None or version == None:
- print("ERROR: 'set' command must give both package and version")
- print('')
- printHelp()
- sys.exit(1)
+ if packages == None or version == None:
+ print("ERROR: 'set' command must give both package and version")
+ print('')
+ printHelp()
+ sys.exit(1)
- target = root + "/" + version + lib_root
- if not os.path.isdir(target):
- print("ERROR: Invalid version " + version)
- print('')
- print("Valid choices:")
- printVersions()
- sys.exit(1)
+ target = root + "/" + version + lib_root
+ if not os.path.isdir(target):
+ print("ERROR: Invalid version " + version)
+ print('')
+ print("Valid choices:")
+ printVersions()
+ sys.exit(1)
- if not os.path.isdir(current):
- os.mkdir(current, 0755)
+ if not os.path.isdir(current):
+ os.mkdir(current, 0755)
- packages.sort()
- for pkg in packages:
- linkname = current + "/" + pkg
- if os.path.islink(linkname) and rpm_mode:
- continue
- elif os.path.islink(linkname):
- os.remove(linkname)
+ packages.sort()
+ for pkg in packages:
+ linkname = current + "/" + pkg
+ if os.path.islink(linkname) and rpm_mode:
+ continue
+ elif os.path.islink(linkname):
+ os.remove(linkname)
- if os.path.exists(linkname):
- print("symlink target %s for %s already exists and it is not a symlink." % (linkname, leaves[pkg]))
- sys.exit(1)
+ if os.path.exists(linkname):
+ print("symlink target %s for %s already exists and it is not a symlink." % (linkname, leaves[pkg]))
+ sys.exit(1)
- os.symlink(target + "/" + leaves[pkg], linkname)
- if pkg in locked_contexts:
- for (kid, dir) in locked_contexts[pkg]:
- linkname = current + "/" + kid
- if os.path.islink(linkname):
- os.remove(linkname)
- os.symlink(target + "/" + dir, linkname)
+ os.symlink(target + "/" + leaves[pkg], linkname)
+ if pkg in locked_contexts:
+ for (kid, dir) in locked_contexts[pkg]:
+ linkname = current + "/" + kid
+ if os.path.islink(linkname):
+ os.remove(linkname)
+ os.symlink(target + "/" + dir, linkname)
+
# Create command symlinks
def createCommandSymlinks(packages, rpm_mode):
- work_packages = copy.copy(packages)
- for pkg in packages:
- if pkg in locked_contexts:
- for (child, dir) in locked_contexts[pkg]:
- work_packages.append(child)
- for symlink in command_symlinks:
- pkg = command_symlinks[symlink].split('/')[0]
- filename = bin_directory + "/" + symlink
- target = current + "/" + command_symlinks[symlink]
- if rpm_mode and os.path.lexists(filename):
- continue
- if pkg in work_packages:
- if not os.path.lexists(filename):
- os.symlink(target, filename)
- elif os.path.islink(filename):
- old_value = os.readlink(filename)
- if old_value != target:
- print("WARNING: Replacing link", filename, "from", old_value)
- os.remove(filename)
- os.symlink(target, filename)
- else:
- if os.path.basename(filename) not in spark_wrapper_scripts:
- print("ERROR:", filename, "is a regular file instead of symlink.")
- print('')
- print("Please ensure that the BIGTOP 2.1 (and earlier) packages are")
- print("removed.")
+ work_packages = copy.copy(packages)
+ for pkg in packages:
+ if pkg in locked_contexts:
+ for (child, dir) in locked_contexts[pkg]:
+ work_packages.append(child)
+ for symlink in command_symlinks:
+ pkg = command_symlinks[symlink].split('/')[0]
+ filename = bin_directory + "/" + symlink
+ target = current + "/" + command_symlinks[symlink]
+ if rpm_mode and os.path.lexists(filename):
+ continue
+ if pkg in work_packages:
+ if not os.path.lexists(filename):
+ os.symlink(target, filename)
+ elif os.path.islink(filename):
+ old_value = os.readlink(filename)
+ if old_value != target:
+ print("WARNING: Replacing link", filename, "from", old_value)
+ os.remove(filename)
+ os.symlink(target, filename)
+ else:
+ if os.path.basename(filename) not in spark_wrapper_scripts:
+ print("ERROR:", filename, "is a regular file instead of symlink.")
+ print('')
+ print("Please ensure that the BIGTOP 2.1 (and earlier) packages are")
+ print("removed.")
+
# Do a sanity check on the tables
def sanityCheckTables():
- for alias in aliases:
- for child in aliases[alias]:
- if not child in leaves:
- print("ERROR: Alias", alias, "has bad child", child)
- sys.exit(1)
- locked = set()
- for parent in locked_contexts:
- for (kid, dir) in locked_contexts[parent]:
- locked.add(kid)
- for symlink in command_symlinks:
- parts = command_symlinks[symlink].split('/')
- if not parts[0] in leaves and not parts[0] in locked:
- print("ERROR: command symlink", symlink, "points to an invalid package",\
- parts[0])
- sys.exit(1)
+ for alias in aliases:
+ for child in aliases[alias]:
+ if not child in leaves:
+ print("ERROR: Alias", alias, "has bad child", child)
+ sys.exit(1)
+ locked = set()
+ for parent in locked_contexts:
+ for (kid, dir) in locked_contexts[parent]:
+ locked.add(kid)
+ for symlink in command_symlinks:
+ parts = command_symlinks[symlink].split('/')
+ if not parts[0] in leaves and not parts[0] in locked:
+ print("ERROR: command symlink", symlink, "points to an invalid package", \
+ parts[0])
+ sys.exit(1)
+
def printHelp():
- print("""
+ print("""
usage: distro-select [-h] [<command>] [<package>] [<version>]
Set the selected version of BIGTOP.
@@ -310,16 +375,18 @@
supports : Check distro-select supports a specific package
""")
+
def checkCommandParameters(cmd, realLen, rightLen):
- if realLen != rightLen:
- print("ERROR:", cmd, "command takes", rightLen - 1,\
- "parameters, instead of", realLen - 1)
- printHelp()
- sys.exit(1)
+ if realLen != rightLen:
+ print("ERROR:", cmd, "command takes", rightLen - 1, \
+ "parameters, instead of", realLen - 1)
+ printHelp()
+ sys.exit(1)
- ############################
- #
- # Start of main
+
+############################
+#
+# Start of main
sanityCheckTables()
@@ -333,30 +400,30 @@
(options, args) = parser.parse_args()
if options.help:
- printHelp()
+ printHelp()
elif options.version:
- print(bigtop_version)
+ print(bigtop_version)
else:
- if len(args) == 0 or args[0] == 'status':
- if len(args) > 1:
- listPackages(getPackages(args[1]))
- else:
- listPackages(getPackages("all"))
- elif args[0] == "set":
- checkCommandParameters('set', len(args), 3)
- pkgs = getPackages(args[1])
- setPackages(pkgs, args[2], options.rpm_mode)
- createCommandSymlinks(pkgs, options.rpm_mode)
- elif args[0] == "versions":
- checkCommandParameters('versions', len(args), 1)
- printVersions()
- elif args[0] == "packages":
- checkCommandParameters('packages', len(args), 1)
- printPackages()
- elif args[0] == "supports":
- checkCommandParameters('support', len(args), 2)
- isSupportedPacakge(args[1])
- else:
- print("ERROR: Unknown command -", args[0])
- printHelp()
- sys.exit(1)
+ if len(args) == 0 or args[0] == 'status':
+ if len(args) > 1:
+ listPackages(getPackages(args[1]))
+ else:
+ listPackages(getPackages("all"))
+ elif args[0] == "set":
+ checkCommandParameters('set', len(args), 3)
+ pkgs = getPackages(args[1])
+ setPackages(pkgs, args[2], options.rpm_mode)
+ createCommandSymlinks(pkgs, options.rpm_mode)
+ elif args[0] == "versions":
+ checkCommandParameters('versions', len(args), 1)
+ printVersions()
+ elif args[0] == "packages":
+ checkCommandParameters('packages', len(args), 1)
+ printPackages()
+ elif args[0] == "supports":
+ checkCommandParameters('support', len(args), 2)
+ isSupportedPacakge(args[1])
+ else:
+ print("ERROR: Unknown command -", args[0])
+ printHelp()
+ sys.exit(1)
Index: bigtop-packages/src/common/bigtop-select/conf-select
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/bigtop-packages/src/common/bigtop-select/conf-select b/bigtop-packages/src/common/bigtop-select/conf-select
--- a/bigtop-packages/src/common/bigtop-select/conf-select (revision bc65999ea5d808543d9b0d4b7390d009aac224e0)
+++ b/bigtop-packages/src/common/bigtop-select/conf-select (date 1723599137520)
@@ -16,12 +16,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+import errno
import optparse
-import copy
import os
-import re
import sys
-import errno
from params import stack_root
# The global prefix and current directory
@@ -30,9 +28,16 @@
vconfroot = 'etc'
lib_root = "usr/lib"
vconf_name = "conf.dist"
-packages = ("hadoop", "hbase", "hive", "hive-hcatalog",
- "kafka", "oozie", "spark", "tez",
- "zookeeper", "zeppelin", "flink", "solr")
+packages = (
+ "solr", "hadoop",
+ "hbase", "hive", "hive-hcatalog",
+ "kafka", "ranger-admin",
+ "ranger-kms", "ranger-usersync", "ranger-tagsync",
+ "spark", "sqoop",
+ "tez", "livy2", "zookeeper", "zeppelin",
+ "hive2", "tez_hive2",
+ "hive_warehouse_connector", "spark_schema_registry", "flink"
+)
''' 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
'''
@@ -87,10 +92,10 @@
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")
+ print(confpath + " exist already")
sys.exit(1)
if method == "set" and not os.path.exists(confpath):
- print(confpath+" does not exist")
+ print(confpath + " does not exist")
sys.exit(1)
return True
@@ -115,7 +120,7 @@
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)
+ path = os.path.join(root, sver, vconfroot, confmapkey, vconf_name + '.' + cver)
print(path)
@@ -128,7 +133,7 @@
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)
+ path = os.path.join(root, sver, vconfroot, confmapkey, vconf_name + '.' + cver)
try:
os.makedirs(path)
print(path)
@@ -149,7 +154,7 @@
if os.path.exists(confdir) and os.path.islink(confdir):
print(confdir)
else:
- print(confdir+" does not exist")
+ print(confdir + " does not exist")
sys.exit(1)
@@ -162,7 +167,7 @@
# 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)
+ 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)
@@ -205,8 +210,6 @@
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:
1
2
3
4
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
2
3
4
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
内容会详细展示每个文件的具体变更,包括删除、添加和修改,方便回溯和线上 review。
笔记
大型集成补丁(如 Bigtop Stack/Redis/Hadoop 适配)建议使用多段补丁,拆分功能模块,便于合并和灰度发布。
# 3.3 实际应用:开发-测试-集成流转
在大数据平台适配场景下,我们常见这样一条补丁流转路径:
场景 | 典型动作 | 工具与说明 |
---|---|---|
本地调试/开发 | 代码变更 → 生成补丁 | IDEA/命令行生成 patch |
内部测试 | 补丁分发测试 → 修正细节 | patch/git apply/IDEA Apply |
交付或 PR | 多人协作,邮件/PR 提交 patch,Review 讨论 | GitHub/Gitee/邮件 |
运维上线 | 补丁归档、批量应用、上线跟踪 | 自动化脚本/补丁平台 |
实际项目中,补丁内容量大时建议拆分管理。每次变更独立一个补丁,回滚和定位问题会更省事。
- 01
- bigtop-select 打包缺 compat 报错修复 deb07-16
- 02
- bigtop-select 打包缺 control 文件报错修复 deb07-16
- 03
- 首次编译-环境初始化 必装07-16