mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-05-16 21:19:54 +08:00
新增命令“installapk”
This commit is contained in:
parent
20c32733c3
commit
27778259c2
14
AutoShell/command/installapk
Executable file
14
AutoShell/command/installapk
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# 加入路径
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||||
|
sys.path.append(f"{programPath}/../../")
|
||||||
|
import ConfigLanguareRunner
|
||||||
|
# 符号转移
|
||||||
|
argv = []
|
||||||
|
for i in sys.argv[1:]:
|
||||||
|
argv.append(i.replace(" ", "\\ "))
|
||||||
|
com = ConfigLanguareRunner.Command(f"{os.path.basename(sys.argv[0])} {' '.join(argv)}")
|
||||||
|
com.Run(com.GetCommandList(), os.getenv("WINEPREFIX"), os.getenv("WINE"))
|
||||||
|
sys.exit(int(ConfigLanguareRunner.programEnv[9][1]))
|
@ -12,6 +12,7 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
|
import uengineapi
|
||||||
import platform
|
import platform
|
||||||
import traceback
|
import traceback
|
||||||
import webbrowser
|
import webbrowser
|
||||||
@ -129,7 +130,8 @@ class Command():
|
|||||||
"installother",
|
"installother",
|
||||||
"decompressionbottle",
|
"decompressionbottle",
|
||||||
"programforum",
|
"programforum",
|
||||||
"installmsi"
|
"installmsi",
|
||||||
|
"installapk"
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, commandString: str) -> None:
|
def __init__(self, commandString: str) -> None:
|
||||||
@ -236,7 +238,7 @@ class Command():
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def StopDll(self) -> int:
|
def StopDll(self) -> int:
|
||||||
os.system(f"WINEPREFIX='{self.wineBottonPath}' '{self.wine}' reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v {os.path.splitext(self.command[1])[0]} /f")
|
return os.system(f"WINEPREFIX='{self.wineBottonPath}' '{self.wine}' reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v {os.path.splitext(self.command[1])[0]} /f")
|
||||||
|
|
||||||
def CreateBotton(self):
|
def CreateBotton(self):
|
||||||
self.command = ["bat", "exit"]
|
self.command = ["bat", "exit"]
|
||||||
@ -349,9 +351,11 @@ class Command():
|
|||||||
file = open(self.command[1], "r")
|
file = open(self.command[1], "r")
|
||||||
print(file.read())
|
print(file.read())
|
||||||
file.close()
|
file.close()
|
||||||
|
return 0
|
||||||
except:
|
except:
|
||||||
print("文件读取错误")
|
print("文件读取错误")
|
||||||
Debug()
|
Debug()
|
||||||
|
return 1
|
||||||
|
|
||||||
def Taskmgr(self):
|
def Taskmgr(self):
|
||||||
self.command = ["bat", "taskmgr"]
|
self.command = ["bat", "taskmgr"]
|
||||||
@ -362,7 +366,7 @@ class Command():
|
|||||||
return self.Bat()
|
return self.Bat()
|
||||||
|
|
||||||
def Killall(self):
|
def Killall(self):
|
||||||
os.system(f"killall -9 {self.command[1]}")
|
return os.system(f"killall -9 {self.command[1]}")
|
||||||
|
|
||||||
def KillallWineServer(self):
|
def KillallWineServer(self):
|
||||||
command = ["WINEPREFIX='($WINEPREFIX)'", "($WINE)", "-k"]
|
command = ["WINEPREFIX='($WINEPREFIX)'", "($WINE)", "-k"]
|
||||||
@ -385,19 +389,19 @@ class Command():
|
|||||||
|
|
||||||
def EnabledWineBottleCreateLink(self):
|
def EnabledWineBottleCreateLink(self):
|
||||||
self.command = ["bat", "reg", "delete", "HKEY_CURRENT_USER\Software\Wine\DllOverrides", "/v", "winemenubuilder.exe", "/f"]
|
self.command = ["bat", "reg", "delete", "HKEY_CURRENT_USER\Software\Wine\DllOverrides", "/v", "winemenubuilder.exe", "/f"]
|
||||||
self.Bat()
|
return self.Bat()
|
||||||
|
|
||||||
def DisbledWineBottleCreateLink(self):
|
def DisbledWineBottleCreateLink(self):
|
||||||
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Wine\DllOverrides", "/v", "winemenubuilder.exe", "/f"]
|
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Wine\DllOverrides", "/v", "winemenubuilder.exe", "/f"]
|
||||||
self.Bat()
|
return self.Bat()
|
||||||
|
|
||||||
def DisbledWineCrashDialog(self):
|
def DisbledWineCrashDialog(self):
|
||||||
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Wine\WineDbg", "/v", "ShowCrashDialog", "/t", "REG_DWORD", "/d", "00000000", "/f"]
|
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Wine\WineDbg", "/v", "ShowCrashDialog", "/t", "REG_DWORD", "/d", "00000000", "/f"]
|
||||||
self.Bat()
|
return self.Bat()
|
||||||
|
|
||||||
def EnabledWineCrashDialog(self):
|
def EnabledWineCrashDialog(self):
|
||||||
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Wine\WineDbg", "/v", "ShowCrashDialog", "/t", "REG_DWORD", "/d", "00000001", "/f"]
|
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Wine\WineDbg", "/v", "ShowCrashDialog", "/t", "REG_DWORD", "/d", "00000001", "/f"]
|
||||||
self.Bat()
|
return self.Bat()
|
||||||
|
|
||||||
def EnabledHttpProxy(self):
|
def EnabledHttpProxy(self):
|
||||||
proxyServerAddress = self.command[1]
|
proxyServerAddress = self.command[1]
|
||||||
@ -405,7 +409,7 @@ class Command():
|
|||||||
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "/v", "ProxyEnable", "/t", "REG_DWORD", "/d", "00000001", "/f"]
|
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "/v", "ProxyEnable", "/t", "REG_DWORD", "/d", "00000001", "/f"]
|
||||||
self.Bat()
|
self.Bat()
|
||||||
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "/v", "ProxyServer", "/d", f"{proxyServerAddress}:{port}", "/f"]
|
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "/v", "ProxyServer", "/d", f"{proxyServerAddress}:{port}", "/f"]
|
||||||
self.Bat()
|
return self.Bat()
|
||||||
|
|
||||||
def DecompressionBottle(self):
|
def DecompressionBottle(self):
|
||||||
tempDebDir = f"/tmp/wine-runner-unpack-deb-{random.randint(0, 1000)}"
|
tempDebDir = f"/tmp/wine-runner-unpack-deb-{random.randint(0, 1000)}"
|
||||||
@ -423,7 +427,7 @@ class Command():
|
|||||||
|
|
||||||
def DisbledHttpProxy(self):
|
def DisbledHttpProxy(self):
|
||||||
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "/v", "ProxyEnable", "/t", "REG_DWORD", "/d", "00000000", "/f"]
|
self.command = ["bat", "reg", "add", "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "/v", "ProxyEnable", "/t", "REG_DWORD", "/d", "00000000", "/f"]
|
||||||
self.Bat()
|
return self.Bat()
|
||||||
|
|
||||||
def InstallVB(self):
|
def InstallVB(self):
|
||||||
import InstallVisualBasicRuntime
|
import InstallVisualBasicRuntime
|
||||||
@ -435,11 +439,26 @@ class Command():
|
|||||||
|
|
||||||
def ProgramForum(self):
|
def ProgramForum(self):
|
||||||
webbrowser.open_new_tab("https://gfdgdxi.flarum.cloud/")
|
webbrowser.open_new_tab("https://gfdgdxi.flarum.cloud/")
|
||||||
|
return
|
||||||
|
|
||||||
def InstallMSI(self):
|
def InstallMSI(self):
|
||||||
self.command = ["bat", "msiexec", "/i", self.command[1]]
|
self.command = ["bat", "msiexec", "/i", self.command[1]]
|
||||||
return self.Bat()
|
return self.Bat()
|
||||||
|
|
||||||
|
def InstallApk(self):
|
||||||
|
apk = uengineapi.APK(self.command[1])
|
||||||
|
result = apk.install()
|
||||||
|
homePath = os.getenv("HOME")
|
||||||
|
|
||||||
|
if not os.path.exists(f"{homePath}/.local/share/applications/uengine"):
|
||||||
|
os.makedirs(f"{homePath}/.local/share/applications/uengine")
|
||||||
|
if not os.path.exists(f"{homePath}/.local/share/icons/hicolor/apps"):
|
||||||
|
os.makedirs(f"{homePath}/.local/share/icons/hicolor/apps")
|
||||||
|
package = apk.packageName()
|
||||||
|
apk.saveApkIcon(f"{homePath}/.local/share/icons/hicolor/apps/{package}.png")
|
||||||
|
apk.saveDesktopFile(f"{homePath}/.local/share/applications/uengine/{package}.desktop", f"{homePath}/.local/share/icons/hicolor/apps/{package}.png")
|
||||||
|
return result
|
||||||
|
|
||||||
# 可以运行的命令的映射关系
|
# 可以运行的命令的映射关系
|
||||||
# 可以被使用的命令的映射
|
# 可以被使用的命令的映射
|
||||||
commandList = {
|
commandList = {
|
||||||
@ -485,7 +504,8 @@ class Command():
|
|||||||
"installother": InstallOther,
|
"installother": InstallOther,
|
||||||
"decompressionbottle": DecompressionBottle,
|
"decompressionbottle": DecompressionBottle,
|
||||||
"programforum": ProgramForum,
|
"programforum": ProgramForum,
|
||||||
"installmsi": InstallMSI
|
"installmsi": InstallMSI,
|
||||||
|
"installapk": InstallApk
|
||||||
}
|
}
|
||||||
|
|
||||||
# 参数数列表
|
# 参数数列表
|
||||||
@ -533,7 +553,8 @@ class Command():
|
|||||||
"installother": [1],
|
"installother": [1],
|
||||||
"decompressionbottle": [2],
|
"decompressionbottle": [2],
|
||||||
"programforum": [0],
|
"programforum": [0],
|
||||||
"installmsi": [1]
|
"installmsi": [1],
|
||||||
|
"installapk": [1]
|
||||||
}
|
}
|
||||||
windowsUnrun = [
|
windowsUnrun = [
|
||||||
"createbotton",
|
"createbotton",
|
||||||
@ -548,7 +569,8 @@ class Command():
|
|||||||
"installdxvk",
|
"installdxvk",
|
||||||
"installfont",
|
"installfont",
|
||||||
"installsparkcorefont",
|
"installsparkcorefont",
|
||||||
"decompressionbottle"
|
"decompressionbottle",
|
||||||
|
"installapk"
|
||||||
]
|
]
|
||||||
# 解析
|
# 解析
|
||||||
def __init__(self, command: list, wineBottonPath: str, wine: str) -> int:
|
def __init__(self, command: list, wineBottonPath: str, wine: str) -> int:
|
||||||
|
2
Makefile
2
Makefile
@ -46,6 +46,8 @@ build:
|
|||||||
cp -rv DisabledOpengl.reg deb/opt/apps/deepin-wine-runner
|
cp -rv DisabledOpengl.reg deb/opt/apps/deepin-wine-runner
|
||||||
cp -rv EnabledOpengl.reg deb/opt/apps/deepin-wine-runner
|
cp -rv EnabledOpengl.reg deb/opt/apps/deepin-wine-runner
|
||||||
cp -rv geek.exe deb/opt/apps/deepin-wine-runner
|
cp -rv geek.exe deb/opt/apps/deepin-wine-runner
|
||||||
|
cp -rv uengineapi deb/opt/apps/deepin-wine-runner
|
||||||
|
cp -rv getxmlimg.py deb/opt/apps/deepin-wine-runner
|
||||||
cp -rv ProgramFen.py deb/opt/apps/deepin-wine-runner
|
cp -rv ProgramFen.py deb/opt/apps/deepin-wine-runner
|
||||||
cp -rv information.json deb/opt/apps/deepin-wine-runner
|
cp -rv information.json deb/opt/apps/deepin-wine-runner
|
||||||
cp -rv InstallMono.py deb/opt/apps/deepin-wine-runner
|
cp -rv InstallMono.py deb/opt/apps/deepin-wine-runner
|
||||||
|
Binary file not shown.
BIN
__pycache__/getxmlimg.cpython-37.pyc
Normal file
BIN
__pycache__/getxmlimg.cpython-37.pyc
Normal file
Binary file not shown.
@ -45,9 +45,9 @@ class APK:
|
|||||||
def __init__(self, apkPath):
|
def __init__(self, apkPath):
|
||||||
self.apkPath = apkPath
|
self.apkPath = apkPath
|
||||||
def install(self):
|
def install(self):
|
||||||
os.system("pkexec /usr/bin/uengine-session-launch-helper -- uengine install --apk='{}'".format(self.apkPath))
|
return os.system("uengine install --apk='{}'".format(self.apkPath))
|
||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
os.system("pkexec /usr/bin/uengine-session-launch-helper -- uengine uninstall --pkg='{}'".format(self.packageName()))
|
return os.system("uengine uninstall --pkg='{}'".format(self.packageName()))
|
||||||
def information(self):
|
def information(self):
|
||||||
return subprocess.getoutput("aapt dump badging '{}'".format(self.apkPath))
|
return subprocess.getoutput("aapt dump badging '{}'".format(self.apkPath))
|
||||||
def activityName(self):
|
def activityName(self):
|
||||||
@ -368,4 +368,5 @@ if __name__ == "__main__":
|
|||||||
quit()
|
quit()
|
||||||
|
|
||||||
if not ROOT.GetRoot():
|
if not ROOT.GetRoot():
|
||||||
print("请获取 ROOT 权限以便更好的使用该 API")
|
pass
|
||||||
|
#print("请获取 ROOT 权限以便更好的使用该 API")
|
0
uengine-api/__pycache__/__init__.cpython-310.pyc → uengineapi/__pycache__/__init__.cpython-310.pyc
0
uengine-api/__pycache__/__init__.cpython-310.pyc → uengineapi/__pycache__/__init__.cpython-310.pyc
BIN
uengine-api/__pycache__/__init__.cpython-37.pyc → uengineapi/__pycache__/__init__.cpython-37.pyc
BIN
uengine-api/__pycache__/__init__.cpython-37.pyc → uengineapi/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
0
uengine-api/__pycache__/getxmlimg.cpython-37.pyc → uengineapi/__pycache__/getxmlimg.cpython-37.pyc
0
uengine-api/__pycache__/getxmlimg.cpython-37.pyc → uengineapi/__pycache__/getxmlimg.cpython-37.pyc
Before ![]() (image error) Size: 35 KiB After ![]() (image error) Size: 35 KiB ![]() ![]() |
118
uengineapi/getxmlimg.py
Executable file
118
uengineapi/getxmlimg.py
Executable file
@ -0,0 +1,118 @@
|
|||||||
|
import PIL.Image as Image
|
||||||
|
import PIL.ImageDraw as ImageDraw
|
||||||
|
import zipfile
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
|
class getsavexml():
|
||||||
|
|
||||||
|
def savexml(self,apkFilePath,xmlpath,iconSavePath):
|
||||||
|
cmddumpid = "aapt dump xmltree "+ apkFilePath + " " + xmlpath
|
||||||
|
print(cmddumpid)
|
||||||
|
xmltree = subprocess.getoutput(cmddumpid)
|
||||||
|
xmls = xmltree.splitlines()
|
||||||
|
# find strs ,print next line
|
||||||
|
def FindStrs(lines,strs):
|
||||||
|
i=0
|
||||||
|
while i < len(lines):
|
||||||
|
if re.search(strs,lines[i]):
|
||||||
|
tmpstr = lines[i+1]
|
||||||
|
i += 1
|
||||||
|
Resultstr = tmpstr.split(":")[-1].split("=")[-1].split("0x")[-1]
|
||||||
|
return Resultstr
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
#从apk的信息中获取前后景图片的ID号
|
||||||
|
backimgid = FindStrs(xmls,"background")
|
||||||
|
foreimgid = FindStrs(xmls,"foreground")
|
||||||
|
print(backimgid)
|
||||||
|
print(foreimgid)
|
||||||
|
|
||||||
|
# 直接从apk resource文件获取前后两层图片路径及ID字符串
|
||||||
|
resource = subprocess.getoutput("aapt dump --values resources " + apkFilePath + "| grep -iE -A1 " + "\"" + backimgid + "|" + foreimgid + "\"")
|
||||||
|
resourcelines = resource.splitlines()
|
||||||
|
print(resourcelines)
|
||||||
|
|
||||||
|
# 从过滤出的字符串中获取所有相同ID的图片路径
|
||||||
|
def Findpicpath(lines,imgid):
|
||||||
|
i=0
|
||||||
|
Resultstr = []
|
||||||
|
while i < len(lines):
|
||||||
|
if re.search(imgid,lines[i]) and re.search("string8",lines[i+1]) :
|
||||||
|
print(lines[i+1])
|
||||||
|
tmpstr = lines[i+1].replace("\"","")
|
||||||
|
i += 1
|
||||||
|
Resultstr.append(tmpstr.split()[-1])
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
return Resultstr
|
||||||
|
|
||||||
|
#获取所有带前后图片ID的图片路径(相同背景或者前景的图片ID但分辨率不一样)
|
||||||
|
backimgs = Findpicpath(resourcelines,backimgid)
|
||||||
|
foreimgs = Findpicpath(resourcelines,foreimgid)
|
||||||
|
print(backimgs)
|
||||||
|
print(foreimgs)
|
||||||
|
#获取分辨率最高的图片路径
|
||||||
|
def getmaxsize(imgs):
|
||||||
|
j = 0
|
||||||
|
size=(0,0)
|
||||||
|
zipapk = zipfile.ZipFile(apkFilePath)
|
||||||
|
imgpath = ""
|
||||||
|
while j < len(imgs):
|
||||||
|
print(imgs[j])
|
||||||
|
img = Image.open(zipapk.open(imgs[j]))
|
||||||
|
print(imgs[j])
|
||||||
|
print(img.size)
|
||||||
|
if size < img.size:
|
||||||
|
size = img.size
|
||||||
|
imgpath = imgs[j]
|
||||||
|
j += 1
|
||||||
|
return imgpath
|
||||||
|
|
||||||
|
# 获取到文件列表后,进行比较分辨率,选取分辨率最高的张图片
|
||||||
|
iconbackpath = getmaxsize(backimgs)
|
||||||
|
iconforepath = getmaxsize(foreimgs)
|
||||||
|
print(iconbackpath + " " + iconforepath)
|
||||||
|
|
||||||
|
#从APK文件获取最终图片
|
||||||
|
zipapk = zipfile.ZipFile(apkFilePath)
|
||||||
|
iconback = zipapk.open(iconbackpath)
|
||||||
|
iconfore = zipapk.open(iconforepath)
|
||||||
|
|
||||||
|
|
||||||
|
# 叠加图片,mask 设置前景为蒙版
|
||||||
|
iconbackimg = Image.open(iconback).convert("RGBA")
|
||||||
|
iconforeimg = Image.open(iconfore).convert("RGBA")
|
||||||
|
iconbackimg.paste(iconforeimg,mask=iconforeimg)
|
||||||
|
|
||||||
|
|
||||||
|
# 圆角图片函数,网上拷贝的
|
||||||
|
def circle_corner(img, radii): #把原图片变成圆角,这个函数是从网上找的,原址 https://www.pyget.cn/p/185266
|
||||||
|
"""
|
||||||
|
圆角处理
|
||||||
|
:param img: 源图象。
|
||||||
|
:param radii: 半径,如:30。
|
||||||
|
:return: 返回一个圆角处理后的图象。
|
||||||
|
"""
|
||||||
|
# 画圆(用于分离4个角)
|
||||||
|
circle = Image.new('L', (radii * 2, radii * 2), 0) # 创建一个黑色背景的画布
|
||||||
|
draw = ImageDraw.Draw(circle)
|
||||||
|
draw.ellipse((0, 0, radii * 2, radii * 2), fill=255) # 画白色圆形
|
||||||
|
# 原图
|
||||||
|
img = img.convert("RGBA")
|
||||||
|
w, h = img.size
|
||||||
|
# 画4个角(将整圆分离为4个部分)
|
||||||
|
alpha = Image.new('L', img.size, 255)
|
||||||
|
alpha.paste(circle.crop((0, 0, radii, radii)), (0, 0)) # 左上角
|
||||||
|
alpha.paste(circle.crop((radii, 0, radii * 2, radii)), (w - radii, 0)) # 右上角
|
||||||
|
alpha.paste(circle.crop((radii, radii, radii * 2, radii * 2)), (w - radii, h - radii)) # 右下角
|
||||||
|
alpha.paste(circle.crop((0, radii, radii, radii * 2)), (0, h - radii)) # 左下角
|
||||||
|
# alpha.show()
|
||||||
|
img.putalpha(alpha) # 白色区域透明可见,黑色区域不可见
|
||||||
|
return img
|
||||||
|
|
||||||
|
# 圆角半径1/8边长,保存icon图片
|
||||||
|
w,h = iconbackimg.size
|
||||||
|
iconimg = circle_corner(iconbackimg,int(w/8))
|
||||||
|
iconimg.save(iconSavePath)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user