From ad1203535a3c6f08b5f436a39c86bbabea3b38c4 Mon Sep 17 00:00:00 2001 From: xieminmin Date: Tue, 7 Nov 2023 11:27:49 +0000 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eisocut=E8=A3=81=E5=89=AA?= =?UTF-8?q?=E5=AE=9A=E5=88=B6=E5=8A=9F=E8=83=BD=E5=8F=82=E6=95=B0=E9=80=89?= =?UTF-8?q?=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xieminmin --- isocut/isocut.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/isocut/isocut.py b/isocut/isocut.py index bd94676..44a71e2 100644 --- a/isocut/isocut.py +++ b/isocut/isocut.py @@ -98,6 +98,7 @@ class IConfig(object): self.ks_file = None self.rpm_path = None self.install_pic_path = None + self.auto_cut = None self.temp_path = None self.temp_path_old_image = None self.temp_path_new_image = None @@ -207,6 +208,7 @@ def check_input(): parser.add_argument("-kickstart", metavar="kickstart_file_path", help="kickstart file path") parser.add_argument("-product", metavar="product_name", help="product name") parser.add_argument("-version", metavar="version_number", help="version number") + parser.add_argument("-auto_cut", metavar="auto_cut", help="auto cut, yes/no, default is no" ) args = parser.parse_args() ICONFIG.src_iso = args.source_iso @@ -217,6 +219,7 @@ def check_input(): ICONFIG.ks_file = args.kickstart ICONFIG.input_product_name = args.product ICONFIG.input_version_number = args.version + ICONFIG.auto_cut = args.auto_cut if ICONFIG.src_iso is None or ICONFIG.dest_iso is None: print("Must specify source iso image and destination iso image") @@ -226,12 +229,18 @@ def check_input(): print("Source iso image not exist!!") return 3 + if ICONFIG.auto_cut and ICONFIG.auto_cut.upper() == "YES": + ICONFIG.auto_cut = True + else: + ICONFIG.auto_cut = False + if ICONFIG.rpm_path is not None: if not os.path.exists(ICONFIG.rpm_path): print("RPM path do not exist!!") return 3 ICONFIG.rpm_path = os.path.realpath(ICONFIG.rpm_path) + if ICONFIG.install_pic_path is not None: if not os.path.exists(ICONFIG.install_pic_path): print("The anaconda pixmaps path do not exist!!") @@ -353,6 +362,13 @@ def create_repo_conf(): # 安装额外的RPM包 def select_rpm(): + if not ICONFIG.auto_cut: + cmd = "cp -ar {}/Packages/ {}".format(ICONFIG.temp_path_old_image, ICONFIG.temp_path_new_image) + ret = ICONFIG.run_cmd(cmd) + if ret[0] != 0: + print("Package list replication failed!!") + return 5 + cmd = "rm -rf {0}".format(ICONFIG.cache_path) ret = ICONFIG.run_cmd(cmd) os.makedirs(ICONFIG.cache_path) @@ -399,6 +415,13 @@ def indent(elem, level=0): elem.tail = i def regen_repodata(): + if not ICONFIG.auto_cut: + cmd = "cp -ar {}/repodata/ {}".format(ICONFIG.temp_path_old_image, ICONFIG.temp_path_new_image) + ret = ICONFIG.run_cmd(cmd) + if ret[0] != 0: + print('repodata replication failed') + return 6 + product_xml = ICONFIG.temp_path_new_image + \ "/" + EXCLUDE_DIR_REPODATA + "/product.xml" tree = ET.parse(ICONFIG.config_repodata_template) @@ -444,6 +467,10 @@ def regen_repodata(): # 检查裁剪的ISO所需的rpm包的依赖关系 def check_deps(): + if not ICONFIG.auto_cut: + print("Skip checking rpm deps!!") + return 0 + try: repo_conf = open(ICONFIG.repo_conf, "w+") repo_conf.write("[check_iso]\n") -- Gitee