From b1fb27ad9b063d758b2dbf65c4e5d93e789ce832 Mon Sep 17 00:00:00 2001 From: gfdgd_xi <3025613752@qq.com> Date: Wed, 14 Sep 2022 21:57:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AF=B9deb=E5=8C=85?= =?UTF-8?q?=E7=9A=84control=E6=96=87=E4=BB=B6=E8=A7=A3=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deepin-wine-packager.py | 46 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/deepin-wine-packager.py b/deepin-wine-packager.py index 4478998..1ddd81d 100755 --- a/deepin-wine-packager.py +++ b/deepin-wine-packager.py @@ -1067,6 +1067,43 @@ def UserPathSet(): return change = True +def ReadDeb(unzip = False): + # 获取路径 + debPath = QtWidgets.QFileDialog.getOpenFileName(window, "读取 deb 包", get_home(), "deb包(*.deb);;所有文件(*.*)")[0] + print(debPath) + # 分类讨论 + path = f"/tmp/deb-unzip-{random.randint(0, 1000)}" + # 新建文件夹 + os.system(f"mkdir -p '{path}'") + # 解包 control 文件 + os.system(f"dpkg -e '{debPath}' '{path}/DEBIAN'") + # 读取 control 文件 + file = open(f"{path}/DEBIAN/control", "r") + lists = file.read().splitlines() + # 控件映射表 + lnkMap = { + "Package": e1_text, + "Version": e2_text, + "Description": e3_text, + "Maintainer": e4_text + } + for i in lists: + # 遍历文件 + items = i.strip() + try: + lnkMap[items[:items.index(":")]].setText(items[items.index(":") + 1:].strip()) + except: + # 报错忽略 + print(f"{items}项忽略") + # 判断 postrm 文件是不是自动移除脚本 + # 解包主文件 + if not unzip: + # 只解压 control 文件的话,结束 + return + os.system(f"dpkg -x '{debPath}' '{path}'") + # 读取文件 + + ############### # 程序信息 ############### @@ -1228,12 +1265,18 @@ e12_text.textChanged.connect(UserPathSet) # 菜单栏 menu = window.menuBar() programmenu = menu.addMenu(QtCore.QCoreApplication.translate("U", "程序")) +debMenu = menu.addMenu(QtCore.QCoreApplication.translate("U", "deb 包")) help = menu.addMenu(QtCore.QCoreApplication.translate("U", "帮助")) exit = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "退出程序")) +debE = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "只读取 Control 信息")) +debX = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "读取所有(需解包,时间较久)")) tip = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "小提示")) exit.triggered.connect(window.close) tip.triggered.connect(helps) programmenu.addAction(exit) +debMenu.addAction(debE) +debMenu.addAction(debX) +debE.triggered.connect(lambda: ReadDeb(False)) help.addAction(tip) # 控件配置 try: @@ -1249,4 +1292,5 @@ window.setWindowTitle(f"wine 应用打包器 {version}") window.setWindowIcon(QtGui.QIcon(iconPath)) window.resize(int(window.frameSize().width() * 2.1), window.frameSize().height()) window.show() -sys.exit(app.exec_()) \ No newline at end of file +sys.exit(app.exec_()) +# Flag:解包只读control和解包全部读取 \ No newline at end of file