diff --git a/README.md b/README.md index 5acb47f..5ca052f 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,35 @@ (测试平台:UOS 家庭版,deepin 20.2.2,UOS 专业版 1040) (自己美术功底太差,图标直接用 anbox 的了) +## 安装前必读 ++ releases 里有两个 deb 包,**是一样的除了包名和打包标准不同**,**只能选择其中一个安装**,**两个都安装会产生冲突**,两个deb包的作用如下: + - 包名为`spark-uengine-runner`的,是旧包,按照**正常标准打包**,适用于从**星火应用商店安装**以及**从低版本(即1.3.2即以下版本升级上来的用户)升级**或者**之前就安装该版本的用户**甚至**想跨平台的用户**等等 + - 包名为`com.gitee.uengine.runner.spark`的,是按照**deepin/UOS的标准打包的**,适用于**之前就安装该版本并升级上来的用户**以及**希望按照该方法打包的用户**等等 ++ **近期升级的 UEngine 安装时会自动把要安装的 apk 删除**,如果这个 apk 文件非常重要请**拷贝一个备份版并安装这个备份版** + ### 更新内容 +#### V1.5.3(2021-12-12,DDUC11版,未完全完工): +##### 更新内容 +**※1、“添加/删除 UEngine 图标”窗口的写入按钮在目录**`~/.local/share/icons/hicolor/256x256/apps`**不存在时点击无反应,参考报错1.5.3-1** +**※2、修复了“UEngine APK 应用打包器”打包的deb包的.desktop文件的**`Icon`**和**`Exec`**字段有误的问题以及使用“使用前缀‘uengine-dc’”前缀的问题** +3、“UEngine APK 应用打包器”支持打包完后自动删除临时目录 +4、“UEngine APK 应用打包器”以及“添加/删除 UEngine 图标”支持在运行出现错误时显示报错 +##### 报错: +*1.5.3-1* +```bash +Exception in Tkinter callback +Traceback (most recent call last): + File "/usr/lib/python3.7/tkinter/__init__.py", line 1705, in __call__ + return self.func(*args) + File "/home/gfdgd_xi/Desktop/uengine-runner/main.py", line 865, in SaveDesktopLink + shutil.copy(programPath + "/defult.png", iconSavePath) + File "/usr/lib/python3.7/shutil.py", line 245, in copy + copyfile(src, dst, follow_symlinks=follow_symlinks) + File "/usr/lib/python3.7/shutil.py", line 121, in copyfile + with open(dst, 'wb') as fdst: +FileNotFoundError: [Errno 2] No such file or directory: '/home/gfdgd_xi/.local/share/icons/hicolor/256x256/apps/com.miHoYo.cloudgames.ys.png' +``` + #### V1.5.2(2021-11-28): **※1、支持安装和构建带 Root 的 UEngine 的镜像** 2、更新了反馈链接 diff --git a/UpdateApkProgram.py b/UpdateApkProgram.py new file mode 100644 index 0000000..27fb600 --- /dev/null +++ b/UpdateApkProgram.py @@ -0,0 +1,14 @@ +import ttkthemes +import tkinter as tk +import tkinter.ttk as ttk +window = tk.Tk() +win = tk.Frame(window) + +chooseFrame = ttk.Frame(win) +fiveStar = ttk.Radiobutton(chooseFrame, text="五星(正常安装、运行、卸载且无任何问题)") +fourStar = ttk.Radiobutton(chooseFrame, text="四星(正常安装、运行、卸载,但在运行时有小问题)") +threeStar = ttk.Radiobutton(chooseFrame, text="三星(正常安装、运行、卸载,但运行时体验不佳,很多功能有问题)") +twoStar = ttk.Radiobutton(chooseFrame, text="二星(正常安装、卸载,但运行难以使用甚至完全无法运行)") +oneStar = ttk.Radiobutton(chooseFrame, text="一星(无法正常安装、运行、卸载)") + +window.mainloop() \ No newline at end of file diff --git a/information.json b/information.json index 1cf40bb..50167aa 100755 --- a/information.json +++ b/information.json @@ -3,31 +3,32 @@ "https://gitee.com/gfdgd-xi/uengine-runner", "https://github.com/gfdgd-xi/uengine-runner" ], - "Version": "1.5.2", + "Version": "1.5.3", "System": "Linux(deepin/UOS)", "Tips": [ "更多可见:https://gitee.com/gfdgd-xi/uengine-runner/wikis", - "", "安装APK:点浏览按钮,选中需要安装的APK,然后点安装按钮", - "", "卸载APK:在卸载APK下面的输入框内输入需要卸载的APK包名,点卸载按钮,如果无法获取包名,可以通过浏览APK文件程序自动获取包名进行卸载。", - "", "保存APK图标:在安装APK下面的输入框浏览或输入APK的路径,然后点击“保存图标”按钮,选择保存位置即可", - "", "重置(删除)UEngine数据:点击菜单栏的“UEngine”的“清空UEngine数据”,输入密码重启即可", " 注意:如果任何安卓一遍打不开,多打开几遍应该就可以重新加载UEngine配置了", - "", "打开UEngine应用列表:打开系统已安装的应用列表(安卓界面)", - "", "提示:", - "1、需要你有使用 root 权限的能力;", - "2、需要安装 UEngine 才能使用;", - "3、提取 apk 图标的 apk 路径以“安装 apk”那栏为准;", - "4、如果想要使用adb连接UEngine或其他手机,请使用 1.2.0 以前的版本。(如需连接UEngine请安装adb补丁)" + "※1、近期升级的 UEngine 安装时会自动把要安装的 apk 删除,如果这个 apk 文件非常重要请拷贝一个备份版并安装这个备份版", + "2、需要你有使用 root 权限的能力;", + "3、需要安装 UEngine 才能使用;", + "4、提取 apk 图标的 apk 路径以“安装 apk”那栏为准;", + "5、如果想要使用adb连接UEngine或其他手机,请使用 1.2.0 以前的版本。(如需连接UEngine请安装adb补丁)" ], "Update": [ + "V1.5.3(未完全完工):", + "※1、“添加/删除 UEngine 图标”窗口的写入按钮在目录~/.local/share/icons/hicolor/256x256/apps不存在时点击无反应,参考报错", + "※2、修复了“UEngine APK应用打包器”打包的deb包的.desktop文件的Icon和Exec字段有误的问题以及使用“使用前缀‘uengine-dc’”前缀的问题", + "3、“UEngine APK应用打包器”支持打包完后自动删除临时目录", + "4、“UEngine APK应用打包器”以及“添加/删除UEngine图标”支持在运行出现错误时显示报错", + "", "V1.5.2:", - "※1、支持安装和构建带 Root 的 UEngine 的镜像", + "※1、支持安装和构建带Root的UEngine的镜像", "2、更新了反馈链接", "", "V1.5.1:", diff --git a/main.py b/main.py index f085329..45cc313 100755 --- a/main.py +++ b/main.py @@ -2,8 +2,8 @@ # 使用系统默认的 python3 运行 ########################################################################################### # 作者:gfdgd xi<3025613752@qq.com> -# 版本:1.5.1 -# 更新时间:2021年10月05日(国庆了) +# 版本:1.5.3 +# 更新时间:2021年12月12日(DDUC11了) # 感谢:anbox、deepin 和 UOS # 基于 Python3 的 tkinter 构建 # 更新:gfdgd xi<3025613752@qq.com>、actionchen<917981399@qq.com> @@ -104,15 +104,13 @@ def InstallApk(path: "apk 路径", quit: "是否静默安装" = False): os.makedirs("{}/.local/share/applications/uengine/".format(get_home())) print("start install apk") global findApkHistory - commandReturn = GetCommandReturn("pkexec /usr/bin/uengine-session-launch-helper -- uengine install --apk='{}'".format(path)) - print(commandReturn) print("start install apk12") iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), GetApkPackageName(path)) tempstr1 = iconSavePath print("start install apk1") iconSaveDir = os.path.dirname(iconSavePath) if not os.path.exists(iconSaveDir): - os.makedirs(iconSaveDir,exist_ok=True) + os.makedirs(iconSaveDir,exist_ok=True) SaveApkIcon(path, iconSavePath) print("start install apk2") BuildUengineDesktop(GetApkPackageName(path), GetApkActivityName(path), GetApkChineseLabel(path), iconSavePath, @@ -120,6 +118,8 @@ def InstallApk(path: "apk 路径", quit: "是否静默安装" = False): print("start install apk3") BuildUengineDesktop(GetApkPackageName(path), GetApkActivityName(path), GetApkChineseLabel(path), iconSavePath, "{}/.local/share/applications/uengine/{}.desktop".format(get_home(), GetApkPackageName(path))) + commandReturn = GetCommandReturn("pkexec /usr/bin/uengine-session-launch-helper -- uengine install --apk='{}'".format(path)) + print(commandReturn) print("\nprint install complete") if quit: print(commandReturn) @@ -857,31 +857,42 @@ class AddNewUengineDesktopLink(): # 添加快捷方式 def SaveDesktopLink(): - if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())): - if not messagebox.askokcancel(title="提示", message="文件已存在,确定要覆盖吗?"): - return - global activityName - iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), packageName.get()) - shutil.copy(programPath + "/defult.png", iconSavePath) - BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath, - "{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())) - BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath, - "{}/{}.desktop".format(get_desktop_path(), packageName.get())) - AddNewUengineDesktopLink.SaveHistory() - messagebox.showinfo(title="提示", message="创建完毕!") + try: + if os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())): + if not messagebox.askokcancel(title="提示", message="文件已存在,确定要覆盖吗?"): + return + if not os.path.exists("{}/.local/share/icons/hicolor/256x256/apps/".format(get_home())): + os.makedirs("{}/.local/share/icons/hicolor/256x256/apps/".format(get_home())) + global activityName + iconSavePath = "{}/.local/share/icons/hicolor/256x256/apps/{}.png".format(get_home(), packageName.get()) + shutil.copy(programPath + "/defult.png", iconSavePath) + BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath, + "{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())) + BuildUengineDesktop(packageName.get(), activityName, packageName.get(), iconSavePath, + "{}/{}.desktop".format(get_desktop_path(), packageName.get())) + AddNewUengineDesktopLink.SaveHistory() + messagebox.showinfo(title="提示", message="创建完毕!") + except: + traceback.print_exc() + messagebox.showerror(title="错误", message=traceback.format_exc()) + # 删除快捷方式 def DelDesktopLink(): - global packageName - if not os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())): - messagebox.showerror(title="错误", message="此包名对应的 UEngine 桌面快捷方式不存在!") - return - if not messagebox.askyesno(title="提示", message="你确定要删除吗?删除后将无法恢复!"): - return try: - os.remove("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())) - AddNewUengineDesktopLink.SaveHistory() - messagebox.showinfo(title="提示", message="已删除") + global packageName + if not os.path.exists("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())): + messagebox.showerror(title="错误", message="此包名对应的 UEngine 桌面快捷方式不存在!") + return + if not messagebox.askyesno(title="提示", message="你确定要删除吗?删除后将无法恢复!"): + return + try: + os.remove("{}/.local/share/applications/uengine/{}.desktop".format(get_home(), packageName.get())) + AddNewUengineDesktopLink.SaveHistory() + messagebox.showinfo(title="提示", message="已删除") + except: + traceback.print_exc() + messagebox.showerror(title="错误", message=traceback.format_exc()) except: traceback.print_exc() messagebox.showerror(title="错误", message=traceback.format_exc()) diff --git a/uengine-apk-builder b/uengine-apk-builder index c8a0a87..2b5fe8d 100755 --- a/uengine-apk-builder +++ b/uengine-apk-builder @@ -2,8 +2,8 @@ # 使用系统默认的 python3 运行 ########################################################################################### # 作者:gfdgd xi -# 版本:1.5.1 -# 更新时间:2021年10月06日 +# 版本:1.5.3 +# 更新时间:2021年12月12日(DDUC11了) # 感谢:anbox、deepin 和 统信 # 基于 Python3 的 tkinter 构建 ########################################################################################### @@ -43,12 +43,20 @@ def BuildDeb(): messagebox.showerror(title="提示", message="信息填写错误,无法继续打包 APK") return DisabledAndEnbled(True) - threading.Thread(target=BuildApkDeb, args=(combobox1.get(),)).start() + threading.Thread(target=GetBuildApkDebError, args=(combobox1.get(),)).start() def RunCommandShow(command): TextboxAddText1("$> {}".format(command)) TextboxAddText1(GetCommandReturn(command)) +def GetBuildApkDebError(apkPath): + try: + BuildApkDeb(apkPath) + except: + traceback.print_exc() + messagebox.showerror(title="错误", message=traceback.format_exc()) + DisabledAndEnbled(False) + def BuildApkDeb(apkPath): tempPath = "/tmp/uengine-apk-builder-{}".format(int(random.randint(0, 1024))) RunCommandShow("echo '======================================New===================================='") @@ -58,11 +66,12 @@ def BuildApkDeb(apkPath): RunCommandShow("mkdir -pv '{}/usr/share/uengine/apk'".format(tempPath)) RunCommandShow("mkdir -pv '{}/usr/share/uengine/icons'".format(tempPath)) RunCommandShow("echo '写入文件,因为写入过程过于复杂,不显示写入命令……'") - apkPackageName = GetApkPackageName(apkPath) + apkPackageName = GetApkPackageName(apkPath, False) + apkPackageNameNew = GetApkPackageName(apkPath, True) apkPackageVersion = GetApkVersion(apkPath) apkChineseLabel = GetApkChineseLabel(apkPath) apkActivityName = GetApkActivityName(apkPath) - iconSavePath = "{}/usr/share/uengine/icons/{}.png".format(tempPath, apkPackageName) + iconSavePath = "{}/usr/share/uengine/icons/{}.png".format(tempPath, apkPackageNameNew) debControl = '''Package: {} Version: {} Architecture: all @@ -70,82 +79,66 @@ Maintainer: {} Depends: deepin-elf-verify (>= 0.0.16.7-1), uengine (>= 1.0.1) Section: utils Priority: optional -Description: {}\n'''.format(apkPackageName, apkPackageVersion, apkChineseLabel, apkChineseLabel) +Description: {}\n'''.format(apkPackageNameNew, apkPackageVersion, apkChineseLabel, apkChineseLabel) debPostinst = '''#!/bin/sh APK_DIR="/usr/share/uengine/apk" -APK_NAME="{}.apk" +APK_NAME="{}" APK_PATH="$APK_DIR/$APK_NAME" -DESKTOP_FILE="/usr/share/applications/{}.desktop" -ICON_FILE="/usr/share/uengine/icons/{}.png" +DESKTOP_FILE="{}" + if [ -f $APK_PATH ]; then echo "Installing $APK_NAME" else - echo "ERROR: $APK_NAME file not found." - exit 1 + echo "ERROR: $APK_NAME does not exist." + exit 0 fi session_manager=`ps -ef | grep "uengine session-manager" | grep -v grep` if test -z "$session_manager"; then - echo "ERROR: app install failed(session-manager not start)." - #sudo rm -f $DESKTOP_FILE - #sudo rm -f $ICON_FILE - #sudo rm -f "$APK_PATH" - exit 1 + echo "ERROR: app install failed(session-manager is not running)." + sess_dir="/usr/share/uengine/session_install" + if [ ! -d $sess_dir ]; then + mkdir $sess_dir + chmod 777 $sess_dir + fi + apk_name=${{APK_PATH##*/}} + fileName="$sess_dir/$apk_name" + echo $DESKTOP_FILE > $fileName + abistr="" + if test -n "$abistr"; then + abi=`echo $abistr |awk -F \= '{{print $2}}'` + echo $abi >> $fileName + fi + chmod 766 $fileName fi -ret=`/usr/bin/uengine-session-launch-helper -- uengine install --apk="$APK_PATH"` -if [ $? -ne 0 ]; then - echo "ERROR: apk install error..." - #sudo rm -f $DESKTOP_FILE - #sudo rm -f $ICON_FILE - #sudo rm -f "$APK_PATH" - exit 1 -fi -chkfail=`echo $ret |grep "Failed"` -if test -n "$chkfail" ; then - echo "ERROR: $ret" - #sudo rm -f $DESKTOP_FILE - #sudo rm -f $ICON_FILE - #sudo rm -f "$APK_PATH" - exit 1 -fi +/usr/bin/uengine-session-launch-helper -- uengine install --apk="$APK_PATH" -sudo rm -f "$APK_PATH" - -exit 0'''.format(apkPackageName, apkPackageName, apkPackageName) +exit 0'''.format(apkPackageNameNew + ".apk", "/usr/share/applications/{}.desktop".format(apkPackageNameNew)) debPrerm = '''#!/bin/sh APP_NAME="{}" +DESKTOP_FILE="{}" session_manager=`ps -ef | grep "uengine session-manager" | grep -v grep` if test -z "$session_manager"; then - echo "ERROR: app install failed(session-manager not start)." - exit 1 + echo "ERROR: app uninstall failed(session-manager is not running)." + sess_dir="/usr/share/uengine/session_uninstall" + if [ ! -d $sess_dir ]; then + mkdir $sess_dir + chmod 777 $sess_dir + fi + fileName="$sess_dir/$APP_NAME" + echo $DESKTOP_FILE > $fileName + chmod 766 $fileName fi echo "Uninstalling $APP_NAME" -ret=`/usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg="$APP_NAME"` -if [ $? -ne 0 ]; then - echo "ERROR: app uninstall error..." - exit 1 -fi -chkfail=`echo $ret |grep "Failed"` -if test -n "$chkfail" ; then - echo "ERROR: $ret" - exit 1 -fi +/usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg="$APP_NAME" -cat /etc/passwd | awk -F: '$3>=1000' | cut -f 1 -d : | while read line -do - inifile="/home/$line/.config/uengineAppGeometry.ini" - if [ -f $inifile ]; then - sed -i "/$APP_NAME/d" $inifile - fi -done - -exit 0'''.format(apkPackageName) +exit 0'''.format(apkPackageName, "/usr/share/applications/{}.desktop".format(apkPackageNameNew)) desktopFile = '''[Desktop Entry] Categories=Other; Exec=uengine launch --action=android.intent.action.MAIN --package={} --component={} @@ -162,20 +155,22 @@ Name={} write_txt("{}/DEBIAN/postinst".format(tempPath), debPostinst) RunCommandShow("echo 正在写入文件:'{}/DEBIAN/prerm'".format(tempPath)) write_txt("{}/DEBIAN/prerm".format(tempPath), debPrerm) - RunCommandShow("echo 正在写入文件:'/usr/share/applications/{}.desktop'".format(apkPackageName)) - #write_txt("{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageName), desktopFile) - BuildUengineDesktop(apkPackageName, apkActivityName, apkChineseLabel, iconSavePath, - "{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageName)) + RunCommandShow("echo 正在写入文件:'/usr/share/applications/{}.desktop'".format(apkPackageNameNew)) + #write_txt("{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew), desktopFile) + BuildUengineDesktop(apkPackageName, apkActivityName, apkChineseLabel, "/usr/share/uengine/icons/{}.png".format(apkPackageNameNew), + "{}/usr/share/applications/{}.desktop".format(tempPath, apkPackageNameNew)) RunCommandShow("echo '复制文件'") RunCommandShow("echo '写入 APK 软件图标'") SaveApkIcon(apkPath, iconSavePath) RunCommandShow("echo '复制 APK 文件'") - RunCommandShow("cp -rv '{}' '{}/usr/share/uengine/apk/{}.apk'".format(apkPath, tempPath, apkPackageName)) + RunCommandShow("cp -rv '{}' '{}/usr/share/uengine/apk/{}.apk'".format(apkPath, tempPath, apkPackageNameNew)) RunCommandShow("echo '正在设置文件权限……'") RunCommandShow("chmod 0775 -vR '{}/DEBIAN/postinst'".format(tempPath)) RunCommandShow("chmod 0775 -vR '{}/DEBIAN/prerm'".format(tempPath)) RunCommandShow("echo '打包 deb 到桌面……'") - RunCommandShow("dpkg -b '{}' '{}/{}_{}.deb'".format(tempPath, get_desktop_path(),apkPackageName, apkPackageVersion)) + RunCommandShow("dpkg -b '{}' '{}/{}_{}.deb'".format(tempPath, get_desktop_path(),apkPackageNameNew, apkPackageVersion)) + RunCommandShow("echo '正在删除临时目录……'") + RunCommandShow("rm -rfv '{}'".format(tempPath)) RunCommandShow("echo '完成!'") findApkHistory.append(apkPath) combobox1['value'] = findApkHistory @@ -260,7 +255,7 @@ def GetApkActivityName(apkFilePath): line = line.replace("icon=", "") return line -def GetApkPackageName(apkFilePath): +def GetApkPackageName(apkFilePath, setting): # 提示:此函数有被为此程序适配而调整,如果需要最原始(无调整的)请使用主程序(此为附属组件)里的函数 info = GetApkInformation(apkFilePath) for line in info.split('\n'): @@ -271,7 +266,7 @@ def GetApkPackageName(apkFilePath): line = line.replace("'", "") line = line.replace(" ", "") # 此较为特殊,因为需要判断用户是否要添加前缀 - if qianZhui.get() == True: + if setting: return "uengine-dc-{}".format(line).lower() return line.lower() @@ -294,7 +289,7 @@ def BuildUengineDesktop(packageName, activityName, showName, iconPath, savePath) [Desktop Entry] Categories=app; Encoding=UTF-8 -Exec=/usr/bin/uengine launch.sh --action=android.intent.action.MAIN --package={} --component={} +Exec=/usr/bin/uengine launch --action=android.intent.action.MAIN --package={} --component={} GenericName={} Icon={} MimeType=