diff --git a/Download.py b/Download.py new file mode 100755 index 0000000..5e27126 --- /dev/null +++ b/Download.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +import sys +import base64 +import requests +print(requests.get(base64.b64decode("aHR0cDovLzEyMC4yNS4xNTMuMTQ0L3VlbmdpbmUtcnVubmVyL0luc3RhbGwucGhwP1ZlcnNpb249").decode("utf-8") + sys.argv[1]).text) \ No newline at end of file diff --git a/Makefile b/Makefile index deca946..fc6dd1e 100755 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ build: cp -rv api new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/ cp -rv Help new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/ cp -rv pkexec/* new-deb-build/usr/share/polkit-1/actions + python3 RemovePycacheFile.py dpkg -b new-deb-build com.gitee.uengine.runner.spark.deb install: diff --git a/RemovePycacheFile.py b/RemovePycacheFile.py new file mode 100755 index 0000000..70da418 --- /dev/null +++ b/RemovePycacheFile.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import os +def Remove(path): + for i in os.listdir(path): + nowPath = f"{path}/{i}" + if os.path.isdir(nowPath): + if i == "__pycache__": + os.system(f"rm -rfv '{nowPath}'") + else: + Remove(nowPath) +programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string +debPath = f"{programPath}/new-deb-build" +Remove(debPath) \ No newline at end of file diff --git a/__pycache__/getxmlimg.cpython-37.pyc b/__pycache__/getxmlimg.cpython-37.pyc index 2639b87..883cdf7 100644 Binary files a/__pycache__/getxmlimg.cpython-37.pyc and b/__pycache__/getxmlimg.cpython-37.pyc differ diff --git a/com.gitee.uengine.runner.spark.deb b/com.gitee.uengine.runner.spark.deb new file mode 100644 index 0000000..17d7a9b Binary files /dev/null and b/com.gitee.uengine.runner.spark.deb differ diff --git a/getxmlimg.py b/getxmlimg.py index af59a70..de43365 100755 --- a/getxmlimg.py +++ b/getxmlimg.py @@ -1,10 +1,50 @@ import PIL.Image as Image import PIL.ImageDraw as ImageDraw +import xml.etree.ElementTree as ET import zipfile import subprocess import re +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +'''import xml.etree.ElementTree as ET + +def xml2svg(xml_file): + tree = ET.parse(xml_file) + root = tree.getroot() + svg_str = '<svg>' + for child in root: + svg_str += '<' + child.tag + for attr in child.attrib: + svg_str += ' ' + attr + '="' + child.attrib[attr] + '"' + svg_str += '>' + for sub_child in child: + svg_str += '<' + sub_child.tag + for attr in sub_child.attrib: + svg_str += ' ' + attr + '="' + sub_child.attrib[attr] + '"' + svg_str += '/>' + svg_str += '</' + child.tag + '>' + svg_str += '</svg>' + return svg_str''' class getsavexml(): + '''def xml2svg(xml_file): + tree = ET.parse(xml_file) + root = tree.getroot() + svg_str = '<svg>' + for child in root: + svg_str += '<' + child.tag + for attr in child.attrib: + svg_str += ' ' + attr + '="' + child.attrib[attr] + '"' + svg_str += '>' + for sub_child in child: + svg_str += '<' + sub_child.tag + for attr in sub_child.attrib: + svg_str += ' ' + attr + '="' + sub_child.attrib[attr] + '"' + svg_str += '/>' + svg_str += '</' + child.tag + '>' + svg_str += '</svg>' + return svg_str''' def savexml(self,apkFilePath,xmlpath,iconSavePath): cmddumpid = "aapt dump xmltree "+ apkFilePath + " " + xmlpath @@ -70,18 +110,37 @@ class getsavexml(): return imgpath # 获取到文件列表后,进行比较分辨率,选取分辨率最高的张图片 - iconbackpath = getmaxsize(backimgs) - iconforepath = getmaxsize(foreimgs) - print(iconbackpath + " " + iconforepath) + # /home/gfdgd_xi/Downloads/MT2.12.2.apk + try: + iconbackpath = getmaxsize(backimgs) + iconforepath = getmaxsize(foreimgs) + except: + if len(backimgs): + iconbackpath = backimgs[0] + else: + iconbackpath = "" + if len(foreimgs): + iconforepath = foreimgs[0] + else: + iconforepath = "" + print(iconbackpath, iconforepath) #从APK文件获取最终图片 zipapk = zipfile.ZipFile(apkFilePath) - iconback = zipapk.open(iconbackpath) - iconfore = zipapk.open(iconforepath) - + try: + iconback = zipapk.open(iconbackpath) + except: + iconback = None + try: + iconfore = zipapk.open(iconforepath) + except: + iconfore = None # 叠加图片,mask 设置前景为蒙版 - iconbackimg = Image.open(iconback).convert("RGBA") + try: + iconbackimg = Image.open(iconback).convert("RGBA") + except: + pass iconforeimg = Image.open(iconfore).convert("RGBA") iconbackimg.paste(iconforeimg,mask=iconforeimg) diff --git a/information.json b/information.json index d8075e9..46b65c9 100755 --- a/information.json +++ b/information.json @@ -5,7 +5,7 @@ "https://github.com/gfdgd-xi/uengine-runner", "https://gitlink.org.cn/gfdgd_xi/uengine-runner" ], - "Version": "1.8.2", + "Version": "1.8.3", "System": "Linux(deepin/UOS)", "Tips": [ "更多可见:https://gitee.com/gfdgd-xi/uengine-runner/wikis 或程序的更多帮助", diff --git a/new-deb-build/DEBIAN/control b/new-deb-build/DEBIAN/control index ef6b1e6..fda2753 100755 --- a/new-deb-build/DEBIAN/control +++ b/new-deb-build/DEBIAN/control @@ -1,22 +1,17 @@ Package: com.gitee.uengine.runner.spark Source: com.gitee.uengine.runner.spark Replaces: spark-uengine-runner, com.gitee.uengine.runner.spark.ubuntu -Version: 1.8.3-spark +Version: 1.8.3 Architecture: all Section: utils -Installed-Size: 1600 +Installed-Size: 1636 Maintainer: gfdgd xi <3025613752@qq.com>, actionchen<917981399@qq.com>, 柚子<https://gitee.com/Limexb>, 为什么您不喜欢熊出没和阿布呢<https://weibo.com/u/7755040136>, 星空露光<https://gitee.com/Cynorkyle>, shenmo<jifengshenmo@outlook.com> Depends: python3, python3-tk, python3-pip, aapt, python3-setuptools, deepin-terminal, curl, python3-pil, python3-requests, adb, fonts-noto-cjk, python3-numpy, wget, inotify-tools, aria2, python3-pyqt5, python3-matplotlib, python3-urllib3 Recommends: uengine, deepin-elf-verify (>= 0.0.16.7-1) Priority: optional Conflicts: spark-uengine-apk-builder, com.gitee.uengine.runner.spark.ubuntu Homepage: [https://gitee.com/gfdgd-xi/uengine-runner, https://github.com/gfdgd-xi/uengine-runner, https://www.gitlink.org.cn/gfdgd_xi/uengine-runner] -Description: UEngine 运行器,1.8.2 更新内容: - ※1、重新恢复 uengine-installer For Ubuntu - ※2、修复 postrm 的问题 - ※3、修复“添加UEngine应用快捷方式出现问题”的问题 - ※4、修复打包器无参数问题 - ※5、打包器默认勾选“使用 uengine-dc 前缀” - 6、修复Python主版本号判断时潜在的问题(By Bail) - 7、新增部分资源入口 +Description: UEngine 运行器,1.8.3 更新内容: + ※1、修复安装/打包程序时出现找不到图标的问题; + ※2、修复部分无法正确获取程序中文名和 Activity 的问题 开发/参与者:gfdgd xi <3025613752@qq.com>, actionchen<917981399@qq.com>, 柚子<https://gitee.com/Limexb>, 为什么您不喜欢熊出没和阿布呢<https://weibo.com/u/7755040136>, 星空露光<https://gitee.com/Cynorkyle>, shenmo<jifengshenmo@outlook.com> diff --git a/new-deb-build/DEBIAN/postinst b/new-deb-build/DEBIAN/postinst index 944f8de..55b1af3 100755 --- a/new-deb-build/DEBIAN/postinst +++ b/new-deb-build/DEBIAN/postinst @@ -1,9 +1,11 @@ #!/bin/sh # 使用 pip 安装所需库 +echo 安装组件 python3 -m pip install --upgrade pip --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple python3 -m pip install --upgrade ttkthemes --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple python3 -m pip install --upgrade pyautogui --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple python3 -m pip install --upgrade keyboard --trusted-host https://repo.huaweicloud.com -i https://repo.huaweicloud.com/repository/pypi/simple +echo 执行完成 # 建立软链接 ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner /usr/bin/uengine-runner ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-apk-builder /usr/bin/uengine-apk-builder @@ -21,4 +23,4 @@ ln -s /opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner-applist-laun # 因为 Ubuntu 的问题,省略 gtk-update-icon-cache /usr/share/icons/bloom > /dev/null | true # 向服务器返回安装数加1(不显示内容且忽略错误) -curl https://304626p927.goho.co/uengine-runner/Install.php?Version=1.8.2 -s > /dev/null | true +python3 /opt/apps/com.gitee.uengine.runner.spark/files/Download.py 1.8.3 > /dev/null | true diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/__pycache__/getxmlimg.cpython-37.pyc b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/__pycache__/getxmlimg.cpython-37.pyc deleted file mode 100755 index 75289c7..0000000 Binary files a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/__pycache__/getxmlimg.cpython-37.pyc and /dev/null differ diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/__init__.cpython-310.pyc b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index d5c6100..0000000 Binary files a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/__init__.cpython-310.pyc and /dev/null differ diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/__init__.cpython-37.pyc b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/__init__.cpython-37.pyc deleted file mode 100755 index 2bd853a..0000000 Binary files a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/__init__.cpython-37.pyc and /dev/null differ diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/getxmlimg.cpython-37.pyc b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/getxmlimg.cpython-37.pyc deleted file mode 100755 index 79021ab..0000000 Binary files a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/api/__pycache__/getxmlimg.cpython-37.pyc and /dev/null differ diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/defult.png b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/defult.png new file mode 100755 index 0000000..c836b68 Binary files /dev/null and b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/defult.png differ diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/getxmlimg.py b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/getxmlimg.py index af59a70..de43365 100755 --- a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/getxmlimg.py +++ b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/getxmlimg.py @@ -1,10 +1,50 @@ import PIL.Image as Image import PIL.ImageDraw as ImageDraw +import xml.etree.ElementTree as ET import zipfile import subprocess import re +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +'''import xml.etree.ElementTree as ET + +def xml2svg(xml_file): + tree = ET.parse(xml_file) + root = tree.getroot() + svg_str = '<svg>' + for child in root: + svg_str += '<' + child.tag + for attr in child.attrib: + svg_str += ' ' + attr + '="' + child.attrib[attr] + '"' + svg_str += '>' + for sub_child in child: + svg_str += '<' + sub_child.tag + for attr in sub_child.attrib: + svg_str += ' ' + attr + '="' + sub_child.attrib[attr] + '"' + svg_str += '/>' + svg_str += '</' + child.tag + '>' + svg_str += '</svg>' + return svg_str''' class getsavexml(): + '''def xml2svg(xml_file): + tree = ET.parse(xml_file) + root = tree.getroot() + svg_str = '<svg>' + for child in root: + svg_str += '<' + child.tag + for attr in child.attrib: + svg_str += ' ' + attr + '="' + child.attrib[attr] + '"' + svg_str += '>' + for sub_child in child: + svg_str += '<' + sub_child.tag + for attr in sub_child.attrib: + svg_str += ' ' + attr + '="' + sub_child.attrib[attr] + '"' + svg_str += '/>' + svg_str += '</' + child.tag + '>' + svg_str += '</svg>' + return svg_str''' def savexml(self,apkFilePath,xmlpath,iconSavePath): cmddumpid = "aapt dump xmltree "+ apkFilePath + " " + xmlpath @@ -70,18 +110,37 @@ class getsavexml(): return imgpath # 获取到文件列表后,进行比较分辨率,选取分辨率最高的张图片 - iconbackpath = getmaxsize(backimgs) - iconforepath = getmaxsize(foreimgs) - print(iconbackpath + " " + iconforepath) + # /home/gfdgd_xi/Downloads/MT2.12.2.apk + try: + iconbackpath = getmaxsize(backimgs) + iconforepath = getmaxsize(foreimgs) + except: + if len(backimgs): + iconbackpath = backimgs[0] + else: + iconbackpath = "" + if len(foreimgs): + iconforepath = foreimgs[0] + else: + iconforepath = "" + print(iconbackpath, iconforepath) #从APK文件获取最终图片 zipapk = zipfile.ZipFile(apkFilePath) - iconback = zipapk.open(iconbackpath) - iconfore = zipapk.open(iconforepath) - + try: + iconback = zipapk.open(iconbackpath) + except: + iconback = None + try: + iconfore = zipapk.open(iconforepath) + except: + iconfore = None # 叠加图片,mask 设置前景为蒙版 - iconbackimg = Image.open(iconback).convert("RGBA") + try: + iconbackimg = Image.open(iconback).convert("RGBA") + except: + pass iconforeimg = Image.open(iconfore).convert("RGBA") iconbackimg.paste(iconforeimg,mask=iconforeimg) diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/information.json b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/information.json index 2ae4043..46b65c9 100755 --- a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/information.json +++ b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/information.json @@ -5,7 +5,7 @@ "https://github.com/gfdgd-xi/uengine-runner", "https://gitlink.org.cn/gfdgd_xi/uengine-runner" ], - "Version": "1.8.2", + "Version": "1.8.3", "System": "Linux(deepin/UOS)", "Tips": [ "更多可见:https://gitee.com/gfdgd-xi/uengine-runner/wikis 或程序的更多帮助", @@ -23,6 +23,10 @@ "5、如果想要使用adb连接UEngine或其他手机,请使用 1.2.0 以前的版本。(如需连接UEngine请安装adb补丁)" ], "Update": [ + "<b>V1.8.3:</b>", + "※1、修复安装/打包程序时出现找不到图标的问题;", + "※2、修复部分无法正确获取程序中文名和 Activity 的问题", + "", "<b>V1.8.2:</b>", "※1、重新恢复 uengine-installer For Ubuntu", "※2、修复 postrm 的问题", diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-apk-builder b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-apk-builder index 7f1d5a0..501244a 100755 --- a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-apk-builder +++ b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-apk-builder @@ -293,6 +293,7 @@ def GetApkActivityName(apkFilePath): line = line.replace("label=", "") line = line.replace("icon=", "") return line + return f"{GetApkPackageName(apkFilePath)}.Main" def GetApkPackageName(apkFilePath, setting): # 提示:此函数有被为此程序适配而调整,如果需要最原始(无调整的)请使用主程序(此为附属组件)里的函数 @@ -341,13 +342,20 @@ Type=Application '''.format(packageName, activityName, showName, iconPath, showName, showName) write_txt(savePath, things) -def GetApkChineseLabel(apkFilePath): +# 获取软件的中文名称 +def GetApkChineseLabel(apkFilePath)->"获取软件的中文名称": info = GetApkInformation(apkFilePath) + name = None for line in info.split('\n'): + if "application-label-zh:" in line: + line = line.replace("application-label-zh:", "") + line = line.replace("'", "") + return line if "application-label:" in line: line = line.replace("application-label:", "") line = line.replace("'", "") - return line + name = line + return name #合并两个函数到一起 def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标": @@ -367,11 +375,11 @@ def SaveApkIcon(apkFilePath, iconSavePath)->"获取 apk 文件的图标": saveIconFile.write(iconData) return print("Show defult icon") - shutil.copy(programPath + "/defult.png", iconSavePath) + shutil.copy(programPath + "/defult.svg", iconSavePath) except: traceback.print_exc() print("Error, show defult icon") - shutil.copy(programPath + "/defult.png", iconSavePath) + shutil.copy(programPath + "/defult.svg", iconSavePath) def TextboxAddText1(message): global textbox1 diff --git a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner index 0fe2796..2b88b6e 100755 --- a/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner +++ b/new-deb-build/opt/apps/com.gitee.uengine.runner.spark/files/uengine-runner @@ -411,6 +411,7 @@ def GetApkActivityName(apkFilePath: "apk 所在路径")->"获取 apk Activity": line = line.replace("label=", "") line = line.replace("icon=", "") return line + return f"{GetApkPackageName(apkFilePath)}.Main" # 获取 apk 包名 def GetApkPackageName(apkFilePath: "apk 所在路径")->"获取 apk 包名": @@ -483,11 +484,17 @@ Type=Application # 获取软件的中文名称 def GetApkChineseLabel(apkFilePath)->"获取软件的中文名称": info = GetApkInformation(apkFilePath) + name = None for line in info.split('\n'): + if "application-label-zh:" in line: + line = line.replace("application-label-zh:", "") + line = line.replace("'", "") + return line if "application-label:" in line: line = line.replace("application-label:", "") line = line.replace("'", "") - return line + name = line + return name # 保存apk图标 def SaveApkIcon(apkFilePath, iconSavePath)->"保存 apk 文件的图标":